{"name":"@opentelemetry/instrumentation-bunyan","version":"0.27.1","keywords":["bunyan","instrumentation","logging","nodejs","opentelemetry","profiling","tracing"],"author":{"name":"OpenTelemetry Authors"},"license":"Apache-2.0","_id":"@opentelemetry/instrumentation-bunyan@0.27.1","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":"e397be4bfabf1343c2a134b19177112b6be34856","tarball":"http://registry-npm.ywwl.com/@opentelemetry/instrumentation-bunyan/download/@opentelemetry/instrumentation-bunyan-0.27.1.tgz","fileCount":16,"integrity":"sha512-aiJOpEKUSWuh4z/Vr2GPW7ViqNxhxFBOmvQmsbinqGquFwy9NZ9rYKGULTUgakOV6X2SoCarG9g9Ufjw4lpTag==","signatures":[{"sig":"MEYCIQDe2SoMdvNcETI1sK9Vw4Vvoe9hNPuG61tqWc1cJ/d3AgIhANVwYNuWJlqoYatcC8b25Lefn3qgC5MjRV4I9egSmBg3","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":28130,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh7vekCRA9TVsSAnZWagAA47kP/2RVrIKCRaJwdXSjSVic\n8nsDmDXZ9PRajXtj9Ch2MKS10u3ov/QLeSzLPfX2sxY19jglBiIIzRtz01nX\n2cG7tRGwW0Y+HapL6g/XGx5vsXyswoxDIpQxVg3q0IeNUVKOYSiZveh53x7J\nxZR44fEZmGSYxWsDu142HZmdvundnEFslJ+kO33khRYpC/10ELz3SpY+cs93\nNtAFH5OIBG9Tm+JQ5c2pDgBvYzytDV3D5Fs3vZKLkZu6JwVe/srn4/atxOHF\nRkv3U4dgBw5wSzCoT2ETz+vg1Oq42zPuW17AafelgdgurOlrJlPKeoqKSREO\nL5A+ADOwYUHbMI18UvnyZ8kVMx4XlXxos60XNnfpj4U8u/kdvO+BS/Uds7Xg\nRM6mimWFrBOIOTU6XOK0xWmW0tBd0tYW1p41eIPxk24JXVfb81sYTLJVZv47\niH775Rt/39X2DR1c4PiXBLzSWXdkaYEMaicKrAt7ONnB6O8Ba/TPvXMRzl/v\n9Y+dJkZyX5gUPyXchEKF5710eKnTTv+ZqU9D4ZAsoWBONgasGc3ihK0eeTp9\np+tQfnEwRi6VDNUJRs/oD8lFFt3Dn+4uY+xaYdsgym+4lr6761fTxE6N/jJH\nzt50Rw0dClNHpZNMfN4HgkIdY+OghEgqLmYVBh5IRJCbkhoxGalP4YzO1RmM\nDyos\r\n=muk7\r\n-----END PGP SIGNATURE-----\r\n","size":8869,"noattachment":false,"key":"/@opentelemetry/instrumentation-bunyan/-/@opentelemetry/instrumentation-bunyan-0.27.1.tgz"},"main":"build/src/index.js","types":"build/src/index.d.ts","engines":{"node":">=8.5.0"},"gitHead":"edfc04cbe3e7faaa365724ddc26bf702b68cc008","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","prewatch":"npm run precompile","precompile":"tsc --version && lerna run version --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/3.22.1/node@v14.18.3+x64 (linux)","description":"OpenTelemetry instrumentation for bunyan","directories":{},"_nodeVersion":"14.18.3","dependencies":{"@types/bunyan":"1.8.7","@opentelemetry/instrumentation":"^0.27.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"gts":"3.1.0","nyc":"15.1.0","mocha":"7.2.0","sinon":"12.0.1","bunyan":"1.8.15","rimraf":"3.0.2","codecov":"3.8.3","ts-mocha":"8.0.0","typescript":"4.3.5","@types/node":"14.17.9","@types/mocha":"7.0.2","@types/sinon":"10.0.2","test-all-versions":"^5.0.1","@opentelemetry/api":"1.0.2","@opentelemetry/sdk-trace-base":"1.0.1","@opentelemetry/sdk-trace-node":"1.0.1","@opentelemetry/context-async-hooks":"1.0.1"},"peerDependencies":{"@opentelemetry/api":"^1.0.2"},"_npmOperationalInternal":{"tmp":"tmp/instrumentation-bunyan_0.27.1_1643050916708_0.8397026646095931","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":1643050916854,"_cnpm_publish_time":1643050916854,"dist-tags":{"latest":"0.70.0"}}