winston-context-logger-apm-storage
v1.2.0
Published
Open telemetry integration with context-logger
Downloads
5
Readme
Context provider for winston-context-logger implemented by using a elastic-apm-nodejs transaction. With this context provider, it is possible to have a fully contextualized logger where all the context is tied to apm transactions, and the correlationid generated will be the traceparent, contributing even to a trace distribution over a micro service scenario done completely by the apm api.
How to Install
npm i winston-context-logger-apm-storage
How to use it
Just pass it to ContextLogger during instantiation and you're done.
new ContextLogger(logger, apmContextProvider);
You can also create sub custom contexts that will inherit all the metadata from the parents:
await apmContextProvider.subContext('my sub routine', async () => {
// Do something here
logger.addMeta('newOne', 'new metadata');
logger.info('Log with all the inherited metadata and the newOne');
});
logger.info('Log without the newOne metadata');
License
Licensed under MIT.