@@ -65,7 +65,9 @@ import {
6565 CONNECTION_ATTRIBUTES ,
6666 getConnectionAttributesFromServer ,
6767 getConnectionAttributesFromUrl ,
68+ InstrumentationConnection ,
6869 InstrumentationConsumeChannel ,
70+ InstrumentationConsumeMessage ,
6971 InstrumentationMessage ,
7072 InstrumentationPublishChannel ,
7173 isConfirmChannelTracing ,
@@ -253,18 +255,11 @@ export class AmqplibInstrumentation extends InstrumentationBase<AmqplibInstrumen
253255 this ,
254256 url ,
255257 socketOptions ,
256- function ( this : unknown , err , conn : Connection ) {
258+ function ( this : unknown , err , conn : InstrumentationConnection ) {
257259 if ( err == null ) {
258260 const urlAttributes = getConnectionAttributesFromUrl ( url ) ;
259- // the type of conn in @types /amqplib is amqp.Connection, but in practice the library send the
260- // `serverProperties` on the `conn` and not in a property `connection`.
261- // I don't have capacity to debug it currently but it should probably be fixed in @types or
262- // in the package itself
263- // currently setting as any to calm typescript
264- const serverAttributes = getConnectionAttributesFromServer (
265- conn as any
266- ) ;
267- ( conn as any ) [ CONNECTION_ATTRIBUTES ] = {
261+ const serverAttributes = getConnectionAttributesFromServer ( conn ) ;
262+ conn [ CONNECTION_ATTRIBUTES ] = {
268263 ...urlAttributes ,
269264 ...serverAttributes ,
270265 } ;
@@ -402,7 +397,7 @@ export class AmqplibInstrumentation extends InstrumentationBase<AmqplibInstrumen
402397
403398 const patchedOnMessage = function (
404399 this : unknown ,
405- msg : InstrumentationMessage | null
400+ msg : InstrumentationConsumeMessage | null
406401 ) {
407402 // msg is expected to be null for signaling consumer cancel notification
408403 // https://www.rabbitmq.com/consumer-cancel.html
@@ -724,7 +719,7 @@ export class AmqplibInstrumentation extends InstrumentationBase<AmqplibInstrumen
724719
725720 private callConsumeEndHook (
726721 span : Span ,
727- msg : ConsumeMessage ,
722+ msg : InstrumentationMessage ,
728723 rejected : boolean | null ,
729724 endOperation : EndOperation
730725 ) {
0 commit comments