{"_id":"@opentelemetry/instrumentation-kafkajs@0.32.0","bugs":{"url":"https://github.com/open-telemetry/opentelemetry-js-contrib/issues"},"dist":{"shasum":"585f496f9c44b9ac9875e84137b29315d41ec048","tarball":"http://registry-npm.ywwl.com/@opentelemetry/instrumentation-kafkajs/download/@opentelemetry/instrumentation-kafkajs-0.32.0.tgz","fileCount":24,"integrity":"sha512-O4Ow5ARmpdx+61T6564Y1wEgdZBDicEFPEvwBM7L8EmMhAMnaQUuZue+ReUiB8TZhlQaUGlLvnZFnhE5UPWwxg==","signatures":[{"sig":"MEYCIQDSSEVLtcjMEte5mx5zwza0DQ8yacG2E4zHaSljIn8HkgIhAOhYxBedKCeW/KgbNnKy7zNoee8b73OZkrztQQLVNXXr","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQC41/K7FG/0VvJT7l+P8Q6zHB8NwMAjgKqlJuvjR5Rp6QIgT778r11scN+2HH4D/1bEwj+zNhXzpjY2YUCkH6gYhhQ="}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@opentelemetry%2finstrumentation-kafkajs@0.32.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":132471,"size":27089,"noattachment":false,"key":"/@opentelemetry/instrumentation-kafkajs/-/@opentelemetry/instrumentation-kafkajs-0.32.0.tgz"},"main":"build/src/index.js","name":"@opentelemetry/instrumentation-kafkajs","types":"build/src/index.d.ts","author":{"name":"OpenTelemetry Authors"},"engines":{"node":"^18.19.0 || >=20.6.0"},"gitHead":"cc263ac4e94320402ac3afe50d50eb00905e1bb8","license":"Apache-2.0","scripts":{"tdd":"npm run test -- --watch-extensions ts --watch","test":"nyc --no-clean mocha --require @opentelemetry/contrib-test-utils 'test/**/*.test.ts'","clean":"rimraf build/*","compile":"tsc -p .","lint:readme":"node ../../scripts/lint-readme","prepublishOnly":"npm run compile","version:update":"node ../../scripts/version-update.js","test-all-versions":"tav","compile:with-dependencies":"nx run-many -t compile -p @opentelemetry/instrumentation-kafkajs"},"version":"0.32.0","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"6d71b18c-e3d7-4bdb-825f-7768635ba523"}},"homepage":"https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/instrumentation-kafkajs#readme","keywords":["kafkajs","instrumentation","nodejs","opentelemetry","profiling","tracing"],"repository":{"url":"git+https://github.com/open-telemetry/opentelemetry-js-contrib.git","type":"git","directory":"packages/instrumentation-kafkajs"},"_npmVersion":"lerna/9.0.7/node@v24.21.0+x64 (linux)","description":"OpenTelemetry instrumentation for `kafkajs` messaging client for Apache Kafka","directories":{},"maintainers":[{"name":"dyladan","email":"dyladan@gmail.com"},{"name":"pichlermarc","email":"marc.pichler@dynatrace.com"},{"name":"overbalance","email":"overbalancedev@proton.me"},{"name":"npmjs-account","email":"npmjs-account@opentelemetry.io"},{"name":"trentm","email":"trentm@gmail.com"},{"name":"martinkuba","email":"martin@martinkuba.com"}],"_nodeVersion":"24.21.0","dependencies":{"@opentelemetry/instrumentation":"^0.223.0","@opentelemetry/semantic-conventions":"^1.30.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"kafkajs":"^2.2.4","@opentelemetry/api":"^1.3.0","@opentelemetry/sdk-trace":"^2.9.0","@opentelemetry/contrib-test-utils":"^0.70.0"},"peerDependencies":{"@opentelemetry/api":"^1.3.0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/instrumentation-kafkajs_0.32.0_1791300184474_0.5385236470107109"},"readme":"# OpenTelemetry `kafkajs` Instrumentation for Node.js\n\n[![NPM Published Version][npm-img]][npm-url]\n[![Apache License][license-image]][license-image]\n\nThis module provides automatic instrumentation for the [`kafkajs`](https://www.npmjs.com/package/kafkajs) package.\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-kafkajs\n```\n\n### Supported versions\n\n- [`kafkajs`](https://www.npmjs.com/package/kafkajs) versions `>=0.3.0 <3`\n\n## Usage\n\n```js\nconst { NodeSDK } = require('@opentelemetry/sdk-node');\nconst { KafkaJsInstrumentation } = require('@opentelemetry/instrumentation-kafkajs');\n\nconst sdk = new NodeSDK({\n  instrumentations: [\n    new KafkaJsInstrumentation({\n      // see below for available configuration\n    }),\n  ],\n});\nsdk.start();\nprocess.once('beforeExit', async () => { await sdk.shutdown(); });\n```\n\n### Instrumentation Options\n\nYou can set the following:\n\n| Options        | Type                                   | Description                                                                                              |\n| -------------- | -------------------------------------- | -------------------------------------------------------------------------------------------------------- |\n| `producerHook` | `KafkaProducerCustomAttributeFunction` | Function called before a producer message is sent. Allows for adding custom attributes to the span.      |\n| `consumerHook` | `KafkaConsumerCustomAttributeFunction` | Function called before a consumer message is processed. Allows for adding custom attributes to the span. |\n\n## Semantic Conventions\n\nThis package uses `@opentelemetry/semantic-conventions` version `1.30+`, which implements Semantic Convention [Version 1.30.0](https://github.com/open-telemetry/semantic-conventions/blob/v1.30.0/docs/README.md)\n\n### Spans Emitted\n\n| KafkaJS Object | Action                     | Span Kind | Span Name                  | Operation Type / Name |\n| -------------- | -------------------------- | --------- | -------------------------- | --------------------- |\n| Consumer       | `eachBatch`                | Client    | `poll <topic-name>`        | `receive` / `poll`    |\n| Consumer       | `eachBatch`, `eachMessage` | Consumer  | `process <topic-name>` [1] | `process` / `process` |\n| Producer       | `send`                     | Producer  | `send <topic-name>`        | `send` / `send`       |\n\n**[1] `process <topic-name>`:** In the context of `eachBatch`, this span will be emitted for each message in the batch but the timing (start, end, duration) will reflect the timing of the batch.\n\n### Metrics Emitted\n\n| KafkaJS Object        | Metric Name                           | Short Description                                                                                      |\n| --------------------- | ------------------------------------- | ------------------------------------------------------------------------------------------------------ |\n| Consumer              | `messaging.process.duration`          | Duration of processing operation. [1]                                                                  |\n| Consumer              | `messaging.client.consumed.messages`  | Number of messages that were delivered to the application.                                             |\n| Consumer and Producer | `messaging.client.operation.duration` | Number of messages that were delivered to the application. (Only emitted for kafkajs@1.5.0 and later.) |\n| Producer              | `messaging.client.sent.messages`      | Number of messages producer attempted to send to the broker.                                           |\n\n**[1] `messaging.process.duration`:** In the context of `eachBatch`, this metric will be emitted once for each message but the value reflects the duration of the entire batch.\n\n### Attributes Collected\n\nThese attributes are added to both spans and metrics, where possible.\n\n| Attribute                            | Short Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |\n| ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| `messaging.system`                   | An identifier for the messaging system being used (i.e. `\"kafka\"`).                                                                                                                                                                                                                                                                                                                                                                                                                                                |\n| `messaging.destination.name`         | The message destination name.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |\n| `messaging.operation.type`           | A string identifying the type of messaging operation.                                                                                                                                                                                                                                                                                                                                                                                                                                                              |\n| `messaging.operation.name`           | The system-specific name of the messaging operation.                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| `messaging.operation.name`           | The system-specific name of the messaging operation.                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| `messaging.kafka.message.key`        | A stringified value representing the key of the Kafka message (if present).                                                                                                                                                                                                                                                                                                                                                                                                                                        |\n| `messaging.kafka.message.tombstone`  | A boolean that is true if the message is a tombstone.                                                                                                                                                                                                                                                                                                                                                                                                                                                              |\n| `messaging.kafka.offset`             | The offset of a record in the corresponding Kafka partition.                                                                                                                                                                                                                                                                                                                                                                                                                                                       |\n| `messaging.kafka.cluster.id`         | The Kafka cluster id, read from the broker metadata kafkajs's own producer/consumer already fetch — no separate connection is opened. On consumer spans this is always present once messages are flowing, since kafkajs refreshes metadata before it can fetch any record. On producer spans it's best-effort: omitted on a freshly created producer's first `send`/`sendBatch` (metadata isn't fetched until then), present on every send after. Also omitted if the broker predates KIP-78 (cluster id support). |\n| `messaging.destination.partition.id` | The identifier of the partition messages are sent to or received from, unique within the `messaging.destination.name`. **Note:** only available on producer spans.                                                                                                                                                                                                                                                                                                                                                 |\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-kafkajs\n[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Finstrumentation-kafkajs.svg\n","publish_time":1791300184562,"_cnpm_publish_time":1791300184562,"dist-tags":{"latest":"0.34.0"}}