{"name":"@opentelemetry/instrumentation-bunyan","version":"0.16.0","keywords":["opentelemetry","logging","nodejs","tracing","profiling","instrumentation","bunyan"],"author":{"name":"OpenTelemetry Authors"},"license":"Apache-2.0","_id":"@opentelemetry/instrumentation-bunyan@0.16.0","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"}],"homepage":"https://github.com/open-telemetry/opentelemetry-js-contrib#readme","bugs":{"url":"https://github.com/open-telemetry/opentelemetry-js-contrib/issues"},"dist":{"shasum":"75571d0527e56e03e54330f638657cceae3d703e","tarball":"http://registry-npm.ywwl.com/@opentelemetry/instrumentation-bunyan/download/@opentelemetry/instrumentation-bunyan-0.16.0.tgz","fileCount":11,"integrity":"sha512-AUVVQBhuYVRME/yZc8Ur/WrMEmOEqfq4KrMh6oGW+BgZzScXfhZjQrNyDyFtihmSpVS2J35J2OIsx0a3XKWqMw==","signatures":[{"sig":"MEYCIQDiUiU6H/JfQWzxshy7siXOTpga65jBPMd2E42+gV7FNQIhAN8n8BUI8vZ5L2Yf7n3zhD5tj3Ok+pmI7ZpZ5u8Wrwzd","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23664,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJghsZYCRA9TVsSAnZWagAA5JEP/jTQ15N5yOyc0Vzh58nN\n4ji2uj/YP1DonI656JDnZqdkYe9PZLFPwb1FfNp47mJJjsv7t5uPxjza9oXN\nrhy1WKiHYFc69+8LggglMsiqj0AMq0w6Q5UDWueQXOnQzhCfK763tv4x22rQ\nghh7mSOpUyPMo6qqNxu0sXTu43FEhXlpHPrbstcvdleWdqtCEPA9lWYuc88W\nxAnxqMMssyopU8x/mF7136mdUrKSbOIz1+fyHCr05xjA6po6b+TVEF11iPqk\nlrtRPXQfP6rzBj7zzsQDHHoQyRuMMfw5Qg8nLFJKhvuaWsSADQ5Kx8bitilc\nKFBZLytUORA8oY+VavKt7UR7LtOETyhk9P5Q8H75b+y1cIKaDcQEmVXI7ZvO\nHg50Y8vMYXmoDBOteOM40Fc44iTBfKzSsrViwzMhW/cPkGfuOEFg/oQZyX2t\nVoAe3jS2vniS/0uBePUQvvWoshqt1/NVvGzgP52K7B3ogiqRzyfG2sHh8K3f\nJzSM3mpsOp3h6KHXmBj1WMIs8T45FVjqmbY3n0f0Js21z2FtJzjS29N63f7M\nArZP2QvgJcTYwE8GSaLr74oXSpFmQOfg2Rl6d44FNtuKrp8XN9bTGxUxmTNV\nMgarGLOJAaGLBpifsjqaXzpIJYPk3uqwRzp0nJUVPg6z9uOrRPEw/VuB1Ar/\nGlw0\r\n=9dZS\r\n-----END PGP SIGNATURE-----\r\n","size":7442,"noattachment":false,"key":"/@opentelemetry/instrumentation-bunyan/-/@opentelemetry/instrumentation-bunyan-0.16.0.tgz"},"main":"build/src/index.js","types":"build/src/index.d.ts","engines":{"node":">=8.5.0"},"gitHead":"5ecccc916e8f4eecaf6629a0350fc672edcba1be","scripts":{"tdd":"npm run test -- --watch-extensions ts --watch","lint":"eslint . --ext .ts","test":"nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'","clean":"rimraf build/*","codecov":"nyc report --reporter=json && codecov -f coverage/*.json -p ../../","compile":"npm run version:update && tsc -p .","prepare":"npm run compile","lint:fix":"eslint . --ext .ts --fix","precompile":"tsc --version","version:update":"node ../../../scripts/version-update.js"},"_npmUser":{"name":"dyladan","email":"dyladan@gmail.com"},"repository":{"url":"git+https://github.com/open-telemetry/opentelemetry-js-contrib.git","type":"git"},"_npmVersion":"lerna/3.22.1/node@v14.8.0+x64 (darwin)","description":"OpenTelemetry instrumentation for bunyan","directories":{},"_nodeVersion":"14.8.0","dependencies":{"@opentelemetry/api":"^1.0.0-rc.0","@opentelemetry/instrumentation":"^0.19.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"gts":"3.1.0","nyc":"15.1.0","mocha":"7.2.0","sinon":"9.0.2","bunyan":"1.8.15","rimraf":"3.0.2","codecov":"3.7.2","ts-mocha":"8.0.0","typescript":"4.1.3","@types/node":"14.0.27","@types/mocha":"7.0.2","@types/sinon":"9.0.4","@types/bunyan":"1.8.6","@opentelemetry/node":"0.19.0","@opentelemetry/tracing":"0.19.0","tslint-microsoft-contrib":"6.2.0","tslint-consistent-codestyle":"1.16.0","@opentelemetry/context-async-hooks":"0.19.0"},"_npmOperationalInternal":{"tmp":"tmp/instrumentation-bunyan_0.16.0_1619445336545_0.04182574523718352","host":"s3://npm-registry-packages"},"readme":"# OpenTelemetry instrumentation for bunyan\n\n[![NPM Published Version][npm-img]][npm-url]\n[![Apache License][license-image]][license-image]\n\nThis module provides automatic instrumentation of the [`bunyan`](https://www.npmjs.com/package/bunyan) module to inject trace-context into Bunyan log records (log correlation) and to send Bunyan 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-bunyan\n```\n\n## Supported Versions\n\n- `bunyan@^1.0.0`\n\n## Usage\n\n```js\nconst { NodeSDK, tracing, logs, api } = require('@opentelemetry/sdk-node');\nconst { BunyanInstrumentation } = require('@opentelemetry/instrumentation-bunyan');\nconst sdk = new NodeSDK({\n  spanProcessor: new tracing.SimpleSpanProcessor(new tracing.ConsoleSpanExporter()),\n  logRecordProcessor: new logs.SimpleLogRecordProcessor(new logs.ConsoleLogRecordExporter()),\n  instrumentations: [\n    new BunyanInstrumentation({\n      // See below for Bunyan instrumentation options.\n    }),\n  ]\n})\nsdk.start();\n\nconst bunyan = require('bunyan');\nconst logger = bunyan.createLogger({name: 'example'});\n\nlogger.info('hi');\n// 1. Log records will be sent to the SDK-registered log record processor, if any.\n//    This is called \"log sending\".\n\nconst tracer = api.trace.getTracer('example');\ntracer.startActiveSpan('manual-span', span => {\n  logger.info('in a span');\n  // 2. Fields identifying the current span will be added to log records:\n  //    {\"name\":\"example\",...,\"msg\":\"in a span\",\"trace_id\":\"d61b4e4af1032e0aae279d12f3ab0159\",\"span_id\":\"d140da862204f2a2\",\"trace_flags\":\"01\"}\n  //    This is called \"log correlation\".\n})\n```\n\n### Log sending\n\nCreation of a Bunyan Logger will automatically add a [Bunyan stream](https://github.com/trentm/node-bunyan#streams) that sends log records to the OpenTelemetry Logs SDK. 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 added stream will be a no-op.\n\nLog sending can be disabled with the `disableLogSending: true` option.\n\n### Log correlation\n\nBunyan 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\n  logHook: (span, record) => {\n    record['resource.service.name'] = provider.resource.attributes['service.name'];\n  }\n```\n\nWhen no span context is active or the span context is invalid, injection is skipped.\nLog injection can be disabled with the `disableLogCorrelation: true` option.\n\n### Bunyan 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 Bunnyan 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### Using OpenTelemetryBunyanStream without instrumentation\n\nThis package exports the Bunyan stream class that is used to send records to the\nOpenTelemetry Logs SDK. It can be used directly when configuring a Bunyan logger\nif one is not using the `BunyanInstrumentation` for whatever reason. For\nexample:\n\n```js\nconst { OpenTelemetryBunyanStream } = require('@opentelemetry/instrumentation-bunyan');\nconst bunyan = require('bunyan');\n\n// You must register an OpenTelemetry LoggerProvider, otherwise log records will\n// be sent to a no-op implementation. \"examples/telemetry.js\" shows one way\n// to configure one.\n// ...\n\nconst logger = bunyan.createLogger({\n  name: 'my-logger',\n  streams: [\n    {\n      type: 'raw',\n      stream: new OpenTelemetryBunyanStream()\n    }\n  ],\n});\n```\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-bunyan\n[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Finstrumentation-bunyan.svg\n","publish_time":1619445336664,"_cnpm_publish_time":1619445336664,"dist-tags":{"latest":"0.70.0"}}