{"name":"@opentelemetry/instrumentation-winston","version":"0.20.0","description":"OpenTelemetry instrumentation for winston","main":"build/src/index.js","types":"build/src/index.d.ts","repository":{"type":"git","url":"git+https://github.com/open-telemetry/opentelemetry-js-contrib.git"},"scripts":{"test":"nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'","tdd":"npm run test -- --watch-extensions ts --watch","clean":"rimraf build/*","lint":"eslint . --ext .ts","lint:fix":"eslint . --ext .ts --fix","codecov":"nyc report --reporter=json && codecov -f coverage/*.json -p ../../","precompile":"tsc --version","prepare":"npm run compile","version:update":"node ../../../scripts/version-update.js","compile":"npm run version:update && tsc -p ."},"keywords":["opentelemetry","logging","nodejs","tracing","profiling","instrumentation","winston"],"author":{"name":"OpenTelemetry Authors"},"license":"Apache-2.0","engines":{"node":">=8.5.0"},"publishConfig":{"access":"public"},"devDependencies":{"@opentelemetry/context-async-hooks":"0.20.0","@opentelemetry/node":"0.20.0","@opentelemetry/tracing":"0.20.0","@types/mocha":"7.0.2","@types/node":"14.17.2","@types/sinon":"9.0.11","codecov":"3.8.2","gts":"3.1.0","mocha":"7.2.0","nyc":"15.1.0","rimraf":"3.0.2","sinon":"9.2.4","ts-mocha":"8.0.0","typescript":"4.3.2","winston":"3.3.3","winston2":"npm:winston@2.4.5"},"dependencies":{"@opentelemetry/api":"^0.20.0","@opentelemetry/instrumentation":"^0.20.0"},"gitHead":"5d73dc2d11a8fd57b21a0c6286861cb992556ca1","bugs":{"url":"https://github.com/open-telemetry/opentelemetry-js-contrib/issues"},"homepage":"https://github.com/open-telemetry/opentelemetry-js-contrib#readme","_id":"@opentelemetry/instrumentation-winston@0.20.0","_nodeVersion":"14.17.0","_npmVersion":"lerna/3.22.1/node@v14.17.0+x64 (linux)","dist":{"integrity":"sha512-o0j31uJjHvp7MlBUCUDaAamw+lwhaPB0CfxVeOdJUFNAlVzSiX99d3uNy15XoT+AoGxbJp/tV73G6HqFtmXtuw==","shasum":"9e613d8c98ba35cba749e96c369f6be91eb3ff46","tarball":"http://registry-npm.ywwl.com/@opentelemetry/instrumentation-winston/download/@opentelemetry/instrumentation-winston-0.20.0.tgz","fileCount":11,"unpackedSize":26434,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgulnaCRA9TVsSAnZWagAActAP/1Hxq30pZn0PZGKmtPDA\nR7l/vSI6kAWPel1gJAKG4kXM3HGhASrkQHELNOl5zsKWunUIonGYiiWPXgBn\nGYtpxAv5Pd8A9e4ZoKB1qO5cMAHq/PZgDIk9xJRCTKQ4SjWDfqM3mZHyOn4F\nUNRMK6qijgve3lbvg4kWsLn3bZvLWVMMapz/FvqLxOXiB+Ua5R3fW0jvRTX3\nzhLWe+wUSJFu7upIyFNgRO5e9ZJVIP5uumynL5CBNX6l4uvRB0HgqrixOZZA\nxuTlaKidhk5yrSzUN5Wc9dTCqy3vTXV3oPFYl5Gu/6dYkLzh7HIZS3nB33Kl\naZs4hE5ZFhiKA2zGOr4+8AEm8HR615PhYJKXf7K5JcYZsFDekRcgo6TzLFPI\nuDiWRLOLb+BN1UhVWwjaXv/Gd64AnaeOcBTPM0ryMeymVRoP1Es7J492N+N4\n4DwDE0TGcl3oWgc5sR1kdB/u6x9iqVWzR+Yjq/XUMaVUjZWC4JuUW9duHcSu\nt3C61uCLWCkepJinb2Uyii2JdTMT+WIs0SAq+TiFCylqXbJnMLfA/Zw3jqVP\ns9gj8w0u6tXg2MqAknG0rYJiYEZ8GDezMwsb34V2Ci6y7SIVWlvodv1FzF5G\nChzb7uvmRuk9eLqztN7NZMzlF1awA+W57q3V+EnDlC+IB5Xi87E2jNdkuoF8\n2lCe\r\n=up8x\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCinqEtOSa+h4tltul65MkuQXoSOKg5aC4PGjvrYuYHOQIhAJmvqtZ5LtOvAmjJkSfcHG37SSxaJEEDlcekmYhNeZgq"}],"size":7832,"noattachment":false,"key":"/@opentelemetry/instrumentation-winston/-/@opentelemetry/instrumentation-winston-0.20.0.tgz"},"_npmUser":{"name":"dyladan","email":"dyladan@gmail.com"},"directories":{},"maintainers":[{"name":"mayurkale22","email":"mayurkale22@gmail.com"},{"name":"bogdandrutu","email":"bogdandrutu@gmail.com"},{"name":"dyladan","email":"dyladan@gmail.com"},{"name":"obecny","email":"bobecny@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/instrumentation-winston_0.20.0_1622825434542_0.11825810345377463"},"_hasShrinkwrap":false,"readme":"# OpenTelemetry instrumentation for winston\n\n[![NPM Published Version][npm-img]][npm-url]\n[![Apache License][license-image]][license-image]\n\nThis module provides automatic instrumentation of the [`winston`](https://www.npmjs.com/package/winston) module to inject trace-context into Winston log records (log correlation) and to send Winston logging to the OpenTelemetry Logging SDK (log sending). It may be loaded using the [`@opentelemetry/sdk-trace-node`](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-sdk-trace-node) package and is included in the [`@opentelemetry/auto-instrumentations-node`](https://www.npmjs.com/package/@opentelemetry/auto-instrumentations-node) bundle.\n\nIf total installation size is not constrained, it is recommended to use the [`@opentelemetry/auto-instrumentations-node`](https://www.npmjs.com/package/@opentelemetry/auto-instrumentations-node) bundle with [@opentelemetry/sdk-node](`https://www.npmjs.com/package/@opentelemetry/sdk-node`) for the most seamless instrumentation experience.\n\nCompatible with OpenTelemetry JS API and SDK `1.0+`.\n\n## Installation\n\n```bash\nnpm install --save @opentelemetry/instrumentation-winston\n```\n\n## Usage\n\n```js\nconst { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node');\nconst logsAPI = require('@opentelemetry/api-logs');\nconst {\n    LoggerProvider,\n    SimpleLogRecordProcessor,\n    ConsoleLogRecordExporter,\n} = require('@opentelemetry/sdk-logs');\nconst { WinstonInstrumentation } = require('@opentelemetry/instrumentation-winston');\nconst { registerInstrumentations } = require('@opentelemetry/instrumentation');\n\nconst tracerProvider = new NodeTracerProvider();\ntracerProvider.register();\n\n// To start a logger, you first need to initialize the Logger provider.\nconst loggerProvider = new LoggerProvider();\n// Add a processor to export log record\nloggerProvider.addLogRecordProcessor(\n    new SimpleLogRecordProcessor(new ConsoleLogRecordExporter())\n);\nlogsAPI.logs.setGlobalLoggerProvider(loggerProvider);\n\nregisterInstrumentations({\n    instrumentations: [\n        new WinstonInstrumentation({\n            // See below for Winston instrumentation options.\n        }),\n    ],\n});\n\nconst winston = require('winston');\nconst logger = winston.createLogger({\n    transports: [new winston.transports.Console()],\n})\nlogger.info('foobar');\n// {\"message\":\"foobar\",\"trace_id\":\"e21c7a95fff34e04f77c7bd518779621\",\"span_id\":\"b7589a981fde09f4\",\"trace_flags\":\"01\", ...}\n```\n\n### Winston instrumentation options\n\n| Option                  | Type              | Description |\n| ----------------------- | ----------------- | ----------- |\n| `disableLogSending`      | `boolean`         | Whether to disable [log sending](#log-sending). Default `false`. |\n| `logSeverity`           | `SeverityNumber`  | Control severity level for [log sending](#log-sending). Default `SeverityNumber.UNSPECIFIED`, it will use Winston Logger's current level when unspecified. |\n| `disableLogCorrelation` | `boolean`         | Whether to disable [log correlation](#log-correlation). Default `false`. |\n| `logHook`               | `LogHookFunction` | An option hook to inject additional context to a log record after trace-context has been added. This requires `disableLogCorrelation` to be false. |  \n\n### Log sending\n\nWinston Logger will automatically send log records to the OpenTelemetry Logs SDK if not explicitly disabled in config and @opentelemetry/winston-transport npm package is installed in the project. The OpenTelemetry SDK can be configured to handle those records, for example, sending them on to an OpenTelemetry collector for log archiving and processing. The example above shows a minimal configuration that emits OpenTelemetry log records to the console for debugging.\n\nIf the OpenTelemetry SDK is not configured with a Logger provider, then this will be a no-op.\n\nLog sending can be disabled with the `disableLogSending: true` option. Log sending is only available for Winston version 3 and later.\n\n```bash\nnpm install --save @opentelemetry/winston-transport\n```\n\n### Log correlation\n\nWinston logger calls in the context of a tracing span will have fields\nidentifying the span added to the log record. This allows\n[correlating](https://opentelemetry.io/docs/specs/otel/logs/#log-correlation)\nlog records with tracing data. The added fields are\n([spec](https://opentelemetry.io/docs/specs/otel/compatibility/logging_trace_context/)):\n\n- `trace_id`\n- `span_id`\n- `trace_flags`\n\nAfter adding these fields, the optional `logHook` is called to allow injecting additional fields. For example:\n\n```js\nlogHook: (span, record) => {\n  record['resource.service.name'] = provider.resource.attributes['service.name'];\n}\n```\n\nLog injection can be disabled with the `disableLogCorrelation: true` option.\n\n### Supported versions\n\n`1.x`, `2.x`, `3.x`\n\nLog sending\n\n`3.x`\n\n## Semantic Conventions\n\nThis package does not currently generate any attributes from semantic conventions.\n\n## Useful links\n\n- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>\n- For more about OpenTelemetry JavaScript: <https://github.com/open-telemetry/opentelemetry-js>\n- For help or feedback on this project, join us in [GitHub Discussions][discussions-url]\n\n## License\n\nApache 2.0 - See [LICENSE][license-url] for more information.\n\n[discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions\n[license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/LICENSE\n[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat\n[npm-url]: https://www.npmjs.com/package/@opentelemetry/instrumentation-winston\n[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Finstrumentation-winston.svg\n","publish_time":1622825434662,"_cnpm_publish_time":1622825434662,"dist-tags":{"latest":"0.70.0"}}