Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/telemetry-tracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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');
}
}

Expand Down