Skip to content

Commit 9726641

Browse files
authored
feat: add pubsub.subscription to GCP pubsub pull subsciptions (#7446)
1 parent 5889aba commit 9726641

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

packages/datadog-plugin-google-cloud-pubsub/src/consumer.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,10 @@ class GoogleCloudPubsubConsumerPlugin extends ConsumerPlugin {
127127
const meta = {
128128
'gcloud.project_id': subscription.pubsub.projectId,
129129
'pubsub.topic': topic,
130+
'pubsub.message_id': message.messageId,
130131
'span.kind': 'consumer',
132+
'pubsub.subscription': subscription.name,
131133
'pubsub.subscription_type': 'pull',
132-
'pubsub.span_type': 'message_processing',
133134
'messaging.operation': 'receive',
134135
base_service: baseService,
135136
service_override_type: 'custom',
@@ -171,9 +172,6 @@ class GoogleCloudPubsubConsumerPlugin extends ConsumerPlugin {
171172
metrics,
172173
}, ctx)
173174

174-
if (message.id) {
175-
span.setTag('pubsub.message_id', message.id)
176-
}
177175
if (message.publishTime) {
178176
span.setTag('pubsub.publish_time', message.publishTime.toISOString())
179177
}

packages/datadog-plugin-google-cloud-pubsub/test/index.spec.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ describe('Plugin', () => {
186186

187187
describe('onmessage', () => {
188188
it('should be instrumented', async () => {
189+
const [topic] = await pubsub.createTopic(topicName)
190+
const [sub] = await topic.createSubscription('foo')
191+
const subscriptionName = sub.name
192+
189193
const expectedSpanPromise = expectSpanWithDefaults({
190194
name: expectedSchema.receive.opName,
191195
service: expectedSchema.receive.serviceName,
@@ -194,13 +198,14 @@ describe('Plugin', () => {
194198
component: 'google-cloud-pubsub',
195199
'span.kind': 'consumer',
196200
'pubsub.topic': resource,
201+
'pubsub.subscription': subscriptionName,
202+
'pubsub.subscription_type': 'pull',
197203
},
198204
metrics: {
199205
'pubsub.ack': 1,
200206
},
201207
})
202-
const [topic] = await pubsub.createTopic(topicName)
203-
const [sub] = await topic.createSubscription('foo')
208+
204209
sub.on('message', msg => msg.ack())
205210
await publish(topic, { data: Buffer.from('hello') })
206211
return expectedSpanPromise

0 commit comments

Comments
 (0)