@@ -347,7 +347,7 @@ export class PubsubSpans {
347347
348348 const spanAttributes = {
349349 // 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
351351 [ 'messaging.system' ] : 'gcp_pubsub' ,
352352 [ 'messaging.destination.name' ] : destinationId ?? destinationName ,
353353 [ 'gcp.project_id' ] : projectId ,
@@ -396,6 +396,7 @@ export class PubsubSpans {
396396 } ) ;
397397 if ( topicInfo . topicId ) {
398398 span . updateName ( `${ topicInfo . topicId } create` ) ;
399+ span . setAttribute ( 'messaging.operation' , 'create' ) ;
399400 span . setAttribute ( 'messaging.destination.name' , topicInfo . topicId ) ;
400401 }
401402
@@ -430,6 +431,7 @@ export class PubsubSpans {
430431 const attributes = this . createAttributes ( subInfo , message , caller ) ;
431432 if ( subInfo . subId ) {
432433 attributes [ 'messaging.destination.name' ] = subInfo . subId ;
434+ attributes [ 'messaging.operation' ] = 'receive' ;
433435 }
434436
435437 if ( context ) {
@@ -553,6 +555,7 @@ export class PubsubSpans {
553555 ) ;
554556
555557 span ?. setAttribute ( 'messaging.batch.message_count' , messageSpans . length ) ;
558+ span ?. setAttribute ( 'messaging.operation' , 'receive' ) ;
556559
557560 if ( span ) {
558561 // Also attempt to link from the subscribe span(s) back to the publish RPC span.
@@ -600,6 +603,7 @@ export class PubsubSpans {
600603 ) ;
601604
602605 span ?. setAttribute ( 'messaging.batch.message_count' , messageSpans . length ) ;
606+ span ?. setAttribute ( 'messaging.operation' , 'receive' ) ;
603607
604608 if ( span ) {
605609 // Also attempt to link from the subscribe span(s) back to the publish RPC span.
@@ -651,7 +655,7 @@ export class PubsubSpans {
651655 }
652656
653657 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' ) ;
655659 }
656660}
657661
0 commit comments