diff --git a/src/telemetry-tracing.ts b/src/telemetry-tracing.ts index b921518ab..422b2d904 100644 --- a/src/telemetry-tracing.ts +++ b/src/telemetry-tracing.ts @@ -347,7 +347,7 @@ export class PubsubSpans { const spanAttributes = { // Add Opentelemetry semantic convention attributes to the span, based on: - // https://github.com/open-telemetry/opentelemetry-specification/blob/v1.1.0/specification/trace/semantic_conventions/messaging.md + // https://github.com/open-telemetry/semantic-conventions/blob/v1.24.0/docs/messaging/messaging-spans.md ['messaging.system']: 'gcp_pubsub', ['messaging.destination.name']: destinationId ?? destinationName, ['gcp.project_id']: projectId, @@ -396,6 +396,7 @@ export class PubsubSpans { }); if (topicInfo.topicId) { span.updateName(`${topicInfo.topicId} create`); + span.setAttribute('messaging.operation', 'create'); span.setAttribute('messaging.destination.name', topicInfo.topicId); } @@ -430,6 +431,7 @@ export class PubsubSpans { const attributes = this.createAttributes(subInfo, message, caller); if (subInfo.subId) { attributes['messaging.destination.name'] = subInfo.subId; + attributes['messaging.operation'] = 'receive'; } if (context) { @@ -553,6 +555,7 @@ export class PubsubSpans { ); span?.setAttribute('messaging.batch.message_count', messageSpans.length); + span?.setAttribute('messaging.operation', 'receive'); if (span) { // Also attempt to link from the subscribe span(s) back to the publish RPC span. @@ -600,6 +603,7 @@ export class PubsubSpans { ); span?.setAttribute('messaging.batch.message_count', messageSpans.length); + span?.setAttribute('messaging.operation', 'receive'); if (span) { // Also attempt to link from the subscribe span(s) back to the publish RPC span. @@ -651,7 +655,7 @@ export class PubsubSpans { } static setReceiveProcessResult(span: Span, isAck: boolean) { - span.setAttribute('messaging.gcp_pubsub.result', isAck ? 'ack' : 'nack'); + span?.setAttribute('messaging.gcp_pubsub.result', isAck ? 'ack' : 'nack'); } }