{"name":"@opentelemetry/instrumentation-bunyan","version":"0.25.0","keywords":["opentelemetry","logging","nodejs","tracing","profiling","instrumentation","bunyan"],"author":{"name":"OpenTelemetry Authors"},"license":"Apache-2.0","_id":"@opentelemetry/instrumentation-bunyan@0.25.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":"e126a48310718fe61bb94951ee9ef9b4e0082e25","tarball":"http://registry-npm.ywwl.com/@opentelemetry/instrumentation-bunyan/download/@opentelemetry/instrumentation-bunyan-0.25.0.tgz","fileCount":15,"integrity":"sha512-7XEWbwZwoyx7a/LD5CQQnJeFXEeU1MW5jq1943WCD5tkh/k9KnK3Lc5qTYLzmH1I1eWJkI2vydVCImk5EvLQDg==","signatures":[{"sig":"MEQCIAHuhS5Vgms9REto/mst00KJ+jhqYUqOWK0gGnnDNPH9AiA+fm9ibruiVU+QM05yLlbh0+fGAryY0KiQ/wTWYVultg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":26317,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhP3csCRA9TVsSAnZWagAA1UwP/19/vFLTwXYqH86XvVmU\nqkoSfjAocK8eZowiJgP6DjeWuPpw9KKvBZAQdEWSY96Iy99ABiYDHnwHffeG\nSgA5IY6QhfMdYyx1LAHlF8vJAS/t35KLMSZNj51ipHMABPB5cRI6c+qU4BNY\ndPEc+orb1yByf2SYSsPKD8iQAGhpb0Nu2/+0eZujEi/awB7UwC0waQoMzZdQ\n1jl72o8BQNSERH6cNMVd+FJkz5a6NU34EqeAM1Abro8gji6sLevzajWqS1yg\nC3RaVingeJnn4HppGBiF3YCbLeibrsiKYOVVIcaFWz/UVR8kcjxsW6OlM/bN\n88o4Ws2AVzBFZeBlyFV03CigSGTK/ZabbGUsR10UVg0t01xkuwotEe6c5yp7\nDSPkbB3iZrDZkbYl6p3YkcHMXvdAzLPI3B2VOlFMctJEdCPyshqTJKoFf7Nl\nGWKQ5CDsmXCZCAk3WniuPM/QN2flPozhdPBsDwifEw08zS60nKDsdKRa79zH\nyYud1WqnspygLjU+bi5uEgUsUK2H9okc883ppu8W7FwRxR5tAgA2zBwhnQVJ\nR53BtCqxnnDQLPx51ixnDwhVDHM/8ky0LOOPjFgnAywMjdv8A3qC77LkeBN+\na+luVPoVzfqZUBSHMcIthQQfDKdxvFie6+ccBwwfeQZfPaKQC3eSMPeG5x22\nByb0\r\n=TSxs\r\n-----END PGP SIGNATURE-----\r\n","size":8331,"noattachment":false,"key":"/@opentelemetry/instrumentation-bunyan/-/@opentelemetry/instrumentation-bunyan-0.25.0.tgz"},"main":"build/src/index.js","types":"build/src/index.d.ts","engines":{"node":">=8.5.0"},"gitHead":"798fb2d5c585f6fdee10146bfe15e03409bdddfe","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.6+x64 (linux)","description":"OpenTelemetry instrumentation for bunyan","directories":{},"_nodeVersion":"14.17.6","dependencies":{"@types/bunyan":"1.8.7","@opentelemetry/instrumentation":"^0.25.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"gts":"3.1.0","nyc":"15.1.0","mocha":"7.2.0","sinon":"11.1.2","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","@opentelemetry/api":"1.0.2","@opentelemetry/sdk-trace-base":"0.25.0","@opentelemetry/sdk-trace-node":"0.25.0","@opentelemetry/context-async-hooks":"0.25.0"},"peerDependencies":{"@opentelemetry/api":"^1.0.2"},"_npmOperationalInternal":{"tmp":"tmp/instrumentation-bunyan_0.25.0_1631549228149_0.8857516588542733","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":1631549228278,"_cnpm_publish_time":1631549228278,"dist-tags":{"latest":"0.70.0"}}