{"name":"@opentelemetry/instrumentation-bunyan","version":"0.21.0","keywords":["opentelemetry","logging","nodejs","tracing","profiling","instrumentation","bunyan"],"author":{"name":"OpenTelemetry Authors"},"license":"Apache-2.0","_id":"@opentelemetry/instrumentation-bunyan@0.21.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":"d3a4b04e0868723bf5dfb8dfed75c98e0be0364b","tarball":"http://registry-npm.ywwl.com/@opentelemetry/instrumentation-bunyan/download/@opentelemetry/instrumentation-bunyan-0.21.0.tgz","fileCount":11,"integrity":"sha512-nC0lX/q6a/MLtmR15ZuDH9vwcvgg0oLkqROtg+EkIhcc7iip5HGaIOgJxmrlGUQVZdrwMUbaMPiM8hgVPtBTFQ==","signatures":[{"sig":"MEUCICnHrVBG680dH93Y6ge+hem2vlWCIS0BmiBeLTKIIbJLAiEAwtX0CxReUwYleRmAYQUFmoJi8gtvRJs5syP2lgn1aXA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23658,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgyg1lCRA9TVsSAnZWagAAOgcQAIHxfUdDdnt7mWudl1Yy\n8//5RgHJaEg4p6kkIU26g/8YVcG5P/6lpfTE2Fya4cKngCcOpJH7FRLZ7Jd8\nIzXR41C2zEuK8tMcD4izS2ixBJjscPXOdo0uHIzyW8ei8OZwYNnj+DlXy8ho\nlhH9ModEntKdd3FRLLxGEaAKAnAjKSd/AVIvAEN8NorG9VbWSFJbeH1vBE66\nCbxe5LIsi9Jfd/0PU+cB1iXBqcSIGwu4q/1K6RgYGenk4n9J6Ant8n/aoM4g\nu4Aom58YWepRFQcG9arEwuFsPa27Ojb7ofDp3N6wgYyIZhuTlHmPY6D2ucn/\nG6nWu/FY3XRRqESzrVNFIENYDaienSXfsEk622FG6KFvCF92RPoRAyYhnN+z\nCn/EI2jLvArqA1JXjGcZIsmpePDlOWr/c4KLIbIuSIJBpfs/jhMB+0cDmwP5\nv7tuLqQ0uA9ntS0xWjrQKaQ/VDiBov2F4Y7KHMKBT9ejJRfK7MGLyS/DfUij\nJEoIJs1YCllI5lGMu0DZzu4fHLsYZjKbdXTu0ADm3q9Ti+cIH4NwSpftO3gA\naHiwX2v5znVP8fki/wWLNJ8+E0iUyQk2n1b4uZLG2wT2sADYjnUuC2OnhKw3\nf+yfOJTJlj5dXzRkEV/MtL1SD/LhrKU7m+/+fNiMqZvdOKQAfyZ8ZZZfI5ir\nVASC\r\n=QJ9d\r\n-----END PGP SIGNATURE-----\r\n","size":7412,"noattachment":false,"key":"/@opentelemetry/instrumentation-bunyan/-/@opentelemetry/instrumentation-bunyan-0.21.0.tgz"},"main":"build/src/index.js","types":"build/src/index.d.ts","engines":{"node":">=8.5.0"},"gitHead":"621f0141e406b75ef11a77fb85ce8caab9c8a272","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.17.0+x64 (linux)","description":"OpenTelemetry instrumentation for bunyan","directories":{},"_nodeVersion":"14.17.0","dependencies":{"@types/bunyan":"1.8.6","@opentelemetry/instrumentation":"^0.21.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"gts":"3.1.0","nyc":"15.1.0","mocha":"7.2.0","sinon":"9.2.4","bunyan":"1.8.15","rimraf":"3.0.2","codecov":"3.8.2","ts-mocha":"8.0.0","typescript":"4.3.2","@types/node":"14.17.3","@types/mocha":"7.0.2","@types/sinon":"10.0.2","@opentelemetry/api":"0.21.0","@opentelemetry/node":"0.21.0","@opentelemetry/tracing":"0.21.0","@opentelemetry/context-async-hooks":"0.21.0"},"peerDependencies":{"@opentelemetry/api":"^0.21.0"},"_npmOperationalInternal":{"tmp":"tmp/instrumentation-bunyan_0.21.0_1623854437036_0.4429529607328555","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":1623854437224,"_cnpm_publish_time":1623854437224,"dist-tags":{"latest":"0.70.0"}}