@@ -347,7 +347,7 @@ export class PubsubSpans {
347
347
348
348
const spanAttributes = {
349
349
// Add Opentelemetry semantic convention attributes to the span, based on:
350
- // https://github.com/open-telemetry/opentelemetry-specification /blob/v1.1 .0/specification/trace/semantic_conventions/ messaging.md
350
+ // https://github.com/open-telemetry/semantic-conventions /blob/v1.24 .0/docs/messaging/ messaging-spans .md
351
351
[ 'messaging.system' ] : 'gcp_pubsub' ,
352
352
[ 'messaging.destination.name' ] : destinationId ?? destinationName ,
353
353
[ 'gcp.project_id' ] : projectId ,
@@ -396,6 +396,7 @@ export class PubsubSpans {
396
396
} ) ;
397
397
if ( topicInfo . topicId ) {
398
398
span . updateName ( `${ topicInfo . topicId } create` ) ;
399
+ span . setAttribute ( 'messaging.operation' , 'create' ) ;
399
400
span . setAttribute ( 'messaging.destination.name' , topicInfo . topicId ) ;
400
401
}
401
402
@@ -430,6 +431,7 @@ export class PubsubSpans {
430
431
const attributes = this . createAttributes ( subInfo , message , caller ) ;
431
432
if ( subInfo . subId ) {
432
433
attributes [ 'messaging.destination.name' ] = subInfo . subId ;
434
+ attributes [ 'messaging.operation' ] = 'receive' ;
433
435
}
434
436
435
437
if ( context ) {
@@ -553,6 +555,7 @@ export class PubsubSpans {
553
555
) ;
554
556
555
557
span ?. setAttribute ( 'messaging.batch.message_count' , messageSpans . length ) ;
558
+ span ?. setAttribute ( 'messaging.operation' , 'receive' ) ;
556
559
557
560
if ( span ) {
558
561
// Also attempt to link from the subscribe span(s) back to the publish RPC span.
@@ -600,6 +603,7 @@ export class PubsubSpans {
600
603
) ;
601
604
602
605
span ?. setAttribute ( 'messaging.batch.message_count' , messageSpans . length ) ;
606
+ span ?. setAttribute ( 'messaging.operation' , 'receive' ) ;
603
607
604
608
if ( span ) {
605
609
// Also attempt to link from the subscribe span(s) back to the publish RPC span.
@@ -651,7 +655,7 @@ export class PubsubSpans {
651
655
}
652
656
653
657
static setReceiveProcessResult ( span : Span , isAck : boolean ) {
654
- span . setAttribute ( 'messaging.gcp_pubsub.result' , isAck ? 'ack' : 'nack' ) ;
658
+ span ? .setAttribute ( 'messaging.gcp_pubsub.result' , isAck ? 'ack' : 'nack' ) ;
655
659
}
656
660
}
657
661
0 commit comments