{"name":"@opentelemetry/instrumentation-amqplib","version":"0.64.0","keywords":["amqplib","opentelemetry","rabbitmq","AMQP 0-9-1"],"author":{"name":"OpenTelemetry Authors"},"license":"Apache-2.0","_id":"@opentelemetry/instrumentation-amqplib@0.64.0","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"}],"homepage":"https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/instrumentation-amqplib#readme","bugs":{"url":"https://github.com/open-telemetry/opentelemetry-js-contrib/issues"},"dist":{"shasum":"cfd80a7174642d84ad96b6e0168b0a62df771365","tarball":"http://registry-npm.ywwl.com/@opentelemetry/instrumentation-amqplib/download/@opentelemetry/instrumentation-amqplib-0.64.0.tgz","fileCount":24,"integrity":"sha512-yiTkjF7bSGp25UmhIYqKkbxyxDDD8w3fFf0KHkpc0m+8DsEXqmuu5a5buERSoeoT7wGgUSCuFcsm+BwlKetK4w==","signatures":[{"sig":"MEUCIQDgbj8ExGq+pzJnleAcW/MBiOrpYFadbnGgKo3Ayx2+IgIgZ7lrUR6ib50xIYGBQjT2dyWDyVmp2GR0yW08Ald4kXU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@opentelemetry%2finstrumentation-amqplib@0.64.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":140348,"size":32142,"noattachment":false,"key":"/@opentelemetry/instrumentation-amqplib/-/@opentelemetry/instrumentation-amqplib-0.64.0.tgz"},"main":"build/src/index.js","types":"build/src/index.d.ts","engines":{"node":"^18.19.0 || >=20.6.0"},"gitHead":"b68fb6dcc0649631ebecab7bde81879486f74f0b","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/*","watch":"tsc -w","compile":"tsc -p .","lint:readme":"node ../../scripts/lint-readme.js","prepublishOnly":"npm run compile","version:update":"node ../../scripts/version-update.js","test-services:ls":"echo rabbitmq","test-all-versions":"tav","test-services:stop":"cd ../.. && npm run test-services:stop rabbitmq","test-services:start":"cd ../.. && npm run test-services:start rabbitmq","test:with-services-env":"cross-env NODE_OPTIONS='-r dotenv/config' DOTENV_CONFIG_PATH=../../test/test-services.env npm test","compile:with-dependencies":"nx run-many -t compile -p @opentelemetry/instrumentation-amqplib","test-all-versions:with-services-env":"cross-env NODE_OPTIONS='-r dotenv/config' DOTENV_CONFIG_PATH=../../test/test-services.env npm run test-all-versions"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:bab51ffb-555f-42a4-a506-affdc4641f00"}},"repository":{"url":"git+https://github.com/open-telemetry/opentelemetry-js-contrib.git","type":"git","directory":"packages/instrumentation-amqplib"},"_npmVersion":"lerna/9.0.5/node@v24.14.1+x64 (linux)","description":"OpenTelemetry instrumentation for the `amqplib` messaging client for RabbitMQ","directories":{},"_nodeVersion":"24.14.1","dependencies":{"@opentelemetry/core":"^2.0.0","@opentelemetry/instrumentation":"^0.217.0","@opentelemetry/semantic-conventions":"^1.33.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"lodash":"4.18.1","amqplib":"^1.0.3","@types/lodash":"4.17.24","@types/amqplib":"^0.10.7","@opentelemetry/api":"^1.3.0","@opentelemetry/contrib-test-utils":"^0.64.0"},"peerDependencies":{"@opentelemetry/api":"^1.3.0"},"_npmOperationalInternal":{"tmp":"tmp/instrumentation-amqplib_0.64.0_1778077853213_0.7869444781073398","host":"s3://npm-registry-packages-npm-production"},"readme":"# OpenTelemetry Amqplib (RabbitMQ) 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 [`amqplib`](https://www.npmjs.com/package/amqplib) (RabbitMQ) module.\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-amqplib\n```\n\n## Supported Versions\n\n- [`amqplib`](https://www.npmjs.com/package/amqplib) versions `>=0.5.5 <3`\n\n## Usage\n\nOpenTelemetry amqplib Instrumentation allows the user to automatically collect trace data and export them to the backend of choice, to give observability to distributed systems when working with [`amqplib`](https://github.com/amqp-node/amqplib) (RabbitMQ).\n\nTo load a specific plugin, specify it in the registerInstrumentations's configuration:\n\nTo enable a specific instrumentation, pass it to `registerInstrumentations()`.\nThis is commonly done via `NodeSDK` for fully setting up all OpenTelemetry SDK components:\n\n```js\nconst { NodeSDK } = require('@opentelemetry/sdk-node');\nconst { AmqplibInstrumentation } = require('@opentelemetry/instrumentation-amqplib');\n\nconst sdk = new NodeSDK({\n  instrumentations: [\n    new AmqplibInstrumentation({\n      // publishHook: (span: Span, publishInfo: PublishInfo) => { },\n      // publishConfirmHook: (span: Span, publishConfirmedInto: PublishConfirmedInfo) => { },\n      // consumeHook: (span: Span, consumeInfo: ConsumeInfo) => { },\n      // consumeEndHook: (span: Span, consumeEndInfo: ConsumeEndInfo) => { },\n      // useLinksForConsume: boolean,\n    }),\n  ],\n});\nsdk.start();\nprocess.once('beforeExit', async () => { await sdk.shutdown(); });\n```\n\n### amqplib Instrumentation Options\n\namqplib instrumentation has few options available to choose from. You can set the following:\n\n| Options              | Type                                           | Description                                                                         |\n| -------------------- | ---------------------------------------------- | ----------------------------------------------------------------------------------- |\n| `publishHook`        | `AmqplibPublishCustomAttributeFunction`        | hook for adding custom attributes before publish message is sent.                   |\n| `publishConfirmHook` | `AmqplibPublishConfirmCustomAttributeFunction` | hook for adding custom attributes after publish message is confirmed by the broker. |\n| `consumeHook`        | `AmqplibConsumeCustomAttributeFunction`        | hook for adding custom attributes before consumer message is processed.             |\n| `consumeEndHook`     | `AmqplibConsumeEndCustomAttributeFunction`     | hook for adding custom attributes after consumer message is acked to server.        |\n| `consumeTimeoutMs`   | `number`                                       | read [Consume Timeout](#consume-timeout) below                                      |\n| `useLinksForConsume` | `boolean`                                      | read [Links for Consume](#links-for-consume) below                                  |\n\n### Consume Timeout\n\nWhen user is setting up consume callback, it is user's responsibility to call ack/nack etc on the msg to resolve it in the server. If user is not calling the ack, the message will stay in the queue until channel is closed, or until server timeout expires (if configured).\n\nWhile we wait for the ack, a reference to the message is stored in plugin, which\nwill never be garbage collected.\nTo prevent memory leak, plugin has it's own configuration of timeout, which will close the span if user did not call ack after this timeout.\n\nIf timeout is not big enough, span might be closed with 'InstrumentationTimeout', and then received valid ack from the user later which will not be instrumented.\n\nDefault is 1 minute\n\n### Links for Consume\n\nBy default, consume spans continue the trace where a message was produced. However, per the [spec](https://opentelemetry.io/docs/specs/semconv/messaging/messaging-spans/#consumer-spans), consume spans should be linked to the message's creation context. Setting to true, this will enable the behavior to follow the spec.\n\nDefault is false\n\n## Running Tests Locally\n\nTo run the tests locally, you need to have a RabbitMQ server running.  You can use the following command to start a RabbitMQ server using Docker:\n\n```bash\nnpm run test:docker:run\n```\n\nBy default, the tests that connect to RabbitMQ are skipped. To make sure these tests are run, you can set the `RUN_RABBIT_TESTS` environment variable to `true`\n\n## Semantic Conventions\n\nThis instrumentation uses Semantic Conventions for messaging spans. The `instrumentation-amqplib` versions 0.67.0 and later emit the stable `server.*` semantic conventions for network attributes.\n\nAttributes collected:\n\n| Attribute                        | Short Description                                                      |\n| -------------------------------- | ---------------------------------------------------------------------- |\n| `messaging.destination`          | The message destination name.                                          |\n| `messaging.destination_kind`     | The kind of message destination.                                       |\n| `messaging.rabbitmq.routing_key` | RabbitMQ message routing key.                                          |\n| `messaging.operation`            | A string identifying the kind of message consumption.                  |\n| `messaging.message_id`           | A value used by the messaging system as an identifier for the message. |\n| `messaging.conversation_id`      | The ID identifying the conversation to which the message belongs.      |\n| `messaging.protocol`             | The name of the transport protocol.                                    |\n| `messaging.protocol_version`     | The version of the transport protocol.                                 |\n| `messaging.system`               | A string identifying the messaging system.                             |\n| `messaging.url`                  | The connection string.                                                 |\n| `server.address`                 | Remote hostname.                                                       |\n| `server.port`                    | Remote port number.                                                    |\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-amqplib\n[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Finstrumentation-amqplib.svg\n","publish_time":1778077853391,"_cnpm_publish_time":1778077853391,"dist-tags":{"latest":"0.72.0"}}