{"name":"@opentelemetry/instrumentation-bunyan","version":"0.30.1","keywords":["bunyan","instrumentation","logging","nodejs","opentelemetry","profiling","tracing"],"author":{"name":"OpenTelemetry Authors"},"license":"Apache-2.0","_id":"@opentelemetry/instrumentation-bunyan@0.30.1","maintainers":[{"name":"bogdandrutu","email":"bogdandrutu@gmail.com"},{"name":"dyladan","email":"dyladan@gmail.com"}],"homepage":"https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-bunyan#readme","bugs":{"url":"https://github.com/open-telemetry/opentelemetry-js-contrib/issues"},"dist":{"shasum":"c819b70e2a3c9068aec58b062bd4e00918304929","tarball":"http://registry-npm.ywwl.com/@opentelemetry/instrumentation-bunyan/download/@opentelemetry/instrumentation-bunyan-0.30.1.tgz","fileCount":15,"integrity":"sha512-IoOJ5wEQlUixfk5YyjKPBoc28nQwn7GuhBwsATKb5Bss2LXkXeWu4p/GxrDN4tPnrCMFtLlmeXhxbGsdx73hAQ==","signatures":[{"sig":"MEQCIA/z9TYvtjmsCxaKhErb1k2U+r4Vr8vzVRiD/qJEBBMHAiAyyttdKlHXIV+B5ZnB+NvanhByJ9dgFg4YDkkpfjcAtA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":26622,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjYnRaACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp3VA//TtStLUcnXpTyLlw0f2QlThEKdv0DgQwI9ltQMH7EXgpMGT/D\r\nC/Enyx8DHH8M3qXw5HpXrN1+9rX4OBrFbjEWjADtS2XH1bf7Dns/MdxbZOua\r\nNuQYvrWzskd+vsNBmXsJElyQneJH7lmnLlnk1sUlAGBRD4yUklsSCRKRqTCa\r\ncngx+ieDaHzyi+PzcRwHOVbhwacDFXzLieFqrpZuhm/wogd8wpZm8ZvyQuSU\r\nWIldy2XlW3/MF6OKAxWxyCDVIuIAVnvESNpFsi6Ro3MfBEhPLBybvskKNWjA\r\nCqpBfkYC1lzM8qfr85UlLO432dLRSDz6K7rDQrDa3YQ0oqKBK2cuutjv2UT9\r\n+5jxOoBO9m+KBBxOtUxcwm7eJSCCmJM+/6d5o+j+secYKD6XHvWKQYqa3djR\r\ndLTc1ALrNZx6krrxi1aSWcCzZjOswcUBNMrQyHfchm4u74rqk8jSIdStmnrY\r\nmd9bza//kswGy9nT05jTpYAy9zviewMxOVyGboAZcxWZDOobdXGJqe+Hl7Sj\r\n5g2UWY2xtR8lib6wad0eNgVqIAyW4GEFx5JLbvHI5U6b8CBOTWP1rlCTK/Fx\r\neZRo/GVPditFAApLePPRYeeOtDJpCVyE4t4vsbfGMFJim3hNeKHghPUozM5t\r\nLEBcpJ/SB5XFFSlT8CnKzM9jB71fLZ41mnI=\r\n=S86A\r\n-----END PGP SIGNATURE-----\r\n","size":8488,"noattachment":false,"key":"/@opentelemetry/instrumentation-bunyan/-/@opentelemetry/instrumentation-bunyan-0.30.1.tgz"},"main":"build/src/index.js","types":"build/src/index.d.ts","engines":{"node":">=14"},"gitHead":"bd79bd04cba3f16658caf37d9a5c65e5bd5980f6","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/*","compile":"tsc -p .","prepare":"npm run compile","lint:fix":"eslint . --ext .ts --fix","prewatch":"npm run precompile","precompile":"tsc --version && lerna run version:update --scope @opentelemetry/instrumentation-bunyan --include-dependencies","version:update":"node ../../../scripts/version-update.js","test-all-versions":"tav"},"_npmUser":{"name":"dyladan","email":"dyladan@gmail.com"},"repository":{"url":"git+https://github.com/open-telemetry/opentelemetry-js-contrib.git","type":"git"},"_npmVersion":"lerna/5.5.2/node@v14.20.1+x64 (linux)","description":"OpenTelemetry instrumentation for bunyan","directories":{},"_nodeVersion":"14.20.1","dependencies":{"@types/bunyan":"1.8.7","@opentelemetry/instrumentation":"^0.32.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"gts":"3.1.0","nyc":"15.1.0","mocha":"7.2.0","sinon":"14.0.0","bunyan":"1.8.15","rimraf":"3.0.2","ts-mocha":"10.0.0","typescript":"4.3.5","@types/node":"18.11.7","@types/mocha":"7.0.2","@types/sinon":"10.0.2","test-all-versions":"5.0.1","@opentelemetry/api":"^1.0.0","@opentelemetry/sdk-trace-base":"^1.3.1","@opentelemetry/sdk-trace-node":"^1.3.1","@opentelemetry/context-async-hooks":"^1.3.1"},"peerDependencies":{"@opentelemetry/api":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/instrumentation-bunyan_0.30.1_1667396698655_0.3851434582687663","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":1667396698776,"_cnpm_publish_time":1667396698776,"dist-tags":{"latest":"0.70.0"}}