-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Context building slog sender (#10300)
closes: #10269 ## Description Adds a slog sender which will build various contexts along the way and report them along with the slogs for better logs querying and identification ### Security Considerations None ### Scaling Considerations This uses a json file storage ### Documentation Considerations This is a new slogger which can be opted into ### Testing Considerations This will be deployed on testnets (already deployed on one of the testnets and log link is added in a comment below) ### Upgrade Considerations This can be configured on existing deployments by bumping the telemetry package
- Loading branch information
1 parent
7ae1f27
commit acbd3ae
Showing
5 changed files
with
607 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* eslint-env node */ | ||
|
||
import { makeFsStreamWriter } from '@agoric/internal/src/node/fs-stream.js'; | ||
import { makeContextualSlogProcessor } from './context-aware-slog.js'; | ||
import { serializeSlogObj } from './serialize-slog-obj.js'; | ||
|
||
/** | ||
* @param {import('./index.js').MakeSlogSenderOptions} options | ||
*/ | ||
export const makeSlogSender = async options => { | ||
const { CHAIN_ID, CONTEXTUAL_SLOGFILE } = options.env || {}; | ||
if (!CONTEXTUAL_SLOGFILE) | ||
return console.warn( | ||
'Ignoring invocation of slogger "context-aware-slog-file" without the presence of "CONTEXTUAL_SLOGFILE"', | ||
); | ||
|
||
const stream = await makeFsStreamWriter(CONTEXTUAL_SLOGFILE); | ||
|
||
if (!stream) | ||
return console.error( | ||
`Couldn't create a write stream on file "${CONTEXTUAL_SLOGFILE}"`, | ||
); | ||
|
||
const contextualSlogProcessor = makeContextualSlogProcessor({ | ||
'chain-id': CHAIN_ID, | ||
}); | ||
|
||
/** | ||
* @param {import('./context-aware-slog.js').Slog} slog | ||
*/ | ||
const slogSender = slog => { | ||
const contextualizedSlog = contextualSlogProcessor(slog); | ||
|
||
// eslint-disable-next-line prefer-template | ||
stream.write(serializeSlogObj(contextualizedSlog) + '\n').catch(() => {}); | ||
}; | ||
|
||
return Object.assign(slogSender, { | ||
forceFlush: () => stream.flush(), | ||
shutdown: () => stream.close(), | ||
}); | ||
}; |
Oops, something went wrong.