ref(node): Vendor amqplib instrumentation#21003
Conversation
Closes #20144 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 8573651. Configure here.
v2 is not within the supported version range (>=0.5.5 <2). The existing test covers v0.10.x, this one covers v1.x. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
size-limit report 📦
|
Avoids conflict with the existing amqplib test's rabbitmq container. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
| export interface Connection { | ||
| connection: { serverProperties: { product?: string; [key: string]: any } }; | ||
| [key: string]: any; |
There was a problem hiding this comment.
Bug: The code accesses conn.serverProperties directly, but the actual amqplib connection object nests this property under conn.connection.serverProperties, causing a TypeError.
Severity: CRITICAL
Suggested Fix
In utils.ts, change the access from conn.serverProperties.product?.toLowerCase?.() to conn.connection.serverProperties.product?.toLowerCase?.() to match the actual structure of the amqplib Connection object.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location:
packages/node/src/integrations/tracing/amqplib/vendored/amqplib-types.ts#L8-L10
Potential issue: The `getConnectionAttributesFromServer` function in `utils.ts` attempts
to access `conn.serverProperties.product`. However, the `Connection` object from
`amqplib` has a nested structure where server properties are located at
`conn.connection.serverProperties`. Accessing `conn.serverProperties` directly results
in `undefined`, which will cause a `TypeError: Cannot read property 'product' of
undefined` when the code attempts to access the `product` property. This error will
occur every time a RabbitMQ connection is established, crashing the amqplib
instrumentation.
Also affects:
packages/node/src/integrations/tracing/amqplib/vendored/utils.ts:105~107
Did we get this right? 👍 / 👎 to inform future reviews.

Vendors
@opentelemetry/instrumentation-amqplibinto the SDK with no logic changes. Uses latest upstream v0.65.0 which extends supported versions to include amqplib v1.x. Types from@types/amqplibare inlined as simplified interfaces to avoid requiring the package as a dependency. Adds integration test for amqplib v1.x.Closes #20144