Skip to content

Commit ae39159

Browse files
authored
feat(process tags): add tags to runtime metrics (#7717)
1 parent f31802d commit ae39159

File tree

14 files changed

+154
-26
lines changed

14 files changed

+154
-26
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
/packages/dd-trace/test/payload_tagging.spec.js @DataDog/apm-idm-js
4949
/packages/dd-trace/test/payload-tagging/ @DataDog/apm-idm-js
5050
/packages/dd-trace/test/propagation-hash.spec.js @DataDog/apm-idm-js
51+
/packages/dd-trace/test/tracer_metadata.spec.js @DataDog/apm-idm-js
5152

5253
# Test Optimization
5354
/ci @DataDog/ci-app-libraries

packages/datadog-plugin-amqplib/test/dsm.spec.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const sinon = require('sinon')
88

99
const { computePathwayHash } = require('../../dd-trace/src/datastreams/pathway')
1010
const { ENTRY_PARENT_HASH, DataStreamsProcessor } = require('../../dd-trace/src/datastreams/processor')
11+
const propagationHash = require('../../dd-trace/src/propagation-hash')
1112
const id = require('../../dd-trace/src/id')
1213
const agent = require('../../dd-trace/test/plugins/agent')
1314
const { withVersions } = require('../../dd-trace/test/setup/mocha')
@@ -59,12 +60,13 @@ describe('Plugin', () => {
5960
})
6061

6162
beforeEach(() => {
63+
const phash = propagationHash.getHash()
6264
const producerHashWithTopic = computePathwayHash('test', 'tester', [
6365
'direction:out',
6466
'has_routing_key:true',
6567
`topic:${queue}`,
6668
'type:rabbitmq',
67-
], ENTRY_PARENT_HASH)
69+
], ENTRY_PARENT_HASH, phash)
6870

6971
expectedProducerHashWithTopic = producerHashWithTopic.readBigUInt64LE(0).toString()
7072

@@ -73,13 +75,13 @@ describe('Plugin', () => {
7375
'exchange:namedExchange',
7476
'has_routing_key:true',
7577
'type:rabbitmq',
76-
], ENTRY_PARENT_HASH).readBigUInt64LE(0).toString()
78+
], ENTRY_PARENT_HASH, phash).readBigUInt64LE(0).toString()
7779

7880
expectedConsumerHash = computePathwayHash('test', 'tester', [
7981
'direction:in',
8082
`topic:${queue}`,
8183
'type:rabbitmq',
82-
], producerHashWithTopic).readBigUInt64LE(0).toString()
84+
], producerHashWithTopic, phash).readBigUInt64LE(0).toString()
8385
})
8486

8587
it('Should emit DSM stats to the agent when sending a message on an unnamed exchange', done => {

packages/datadog-plugin-aws-sdk/test/kinesis.dsm.spec.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const agent = require('../../dd-trace/test/plugins/agent')
1111
const id = require('../../dd-trace/src/id')
1212
const { computePathwayHash } = require('../../dd-trace/src/datastreams/pathway')
1313
const { ENTRY_PARENT_HASH } = require('../../dd-trace/src/datastreams/processor')
14+
const propagationHash = require('../../dd-trace/src/propagation-hash')
1415
const helpers = require('./kinesis_helpers')
1516
const { setup } = require('./spec_helpers')
1617

@@ -67,19 +68,22 @@ describe('Kinesis', function () {
6768

6869
streamNameDSM = `MyStreamDSM-${id()}`
6970

71+
const phash = propagationHash.getHash()
7072
const producerHash = computePathwayHash(
7173
'test',
7274
'tester',
7375
['direction:out', 'topic:' + streamNameDSM, 'type:kinesis'],
74-
ENTRY_PARENT_HASH
76+
ENTRY_PARENT_HASH,
77+
phash
7578
)
7679

7780
expectedProducerHash = producerHash.readBigUInt64LE(0).toString()
7881
expectedConsumerHash = computePathwayHash(
7982
'test',
8083
'tester',
8184
['direction:in', 'topic:' + streamNameDSM, 'type:kinesis'],
82-
producerHash
85+
producerHash,
86+
phash
8387
).readBigUInt64LE(0).toString()
8488

8589
createResources(streamNameDSM, done)

packages/datadog-plugin-aws-sdk/test/sns.dsm.spec.js

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ const { after, afterEach, before, describe, it } = require('mocha')
66
const sinon = require('sinon')
77
const semver = require('semver')
88

9-
const { assertObjectContains } = require('../../../integration-tests/helpers')
10-
const { withVersions } = require('../../dd-trace/test/setup/mocha')
9+
const { computePathwayHash } = require('../../dd-trace/src/datastreams/pathway')
10+
const { ENTRY_PARENT_HASH } = require('../../dd-trace/src/datastreams/processor')
11+
const propagationHash = require('../../dd-trace/src/propagation-hash')
1112
const agent = require('../../dd-trace/test/plugins/agent')
13+
const { withVersions } = require('../../dd-trace/test/setup/mocha')
14+
const { assertObjectContains } = require('../../../integration-tests/helpers')
1215
const { setup } = require('./spec_helpers')
1316

1417
describe('Sns', function () {
@@ -71,8 +74,8 @@ describe('Sns', function () {
7174
}
7275

7376
describe('Data Streams Monitoring', () => {
74-
const expectedProducerHash = '15386798273908484982'
75-
const expectedConsumerHash = '15162998336469814920'
77+
let expectedProducerHash
78+
let expectedConsumerHash
7679
let nowStub
7780

7881
before(() => {
@@ -84,7 +87,28 @@ describe('Sns', function () {
8487
tracer = require('../../dd-trace')
8588
tracer.use('aws-sdk', { sns: { dsmEnabled: true }, sqs: { dsmEnabled: true } })
8689

87-
createResources('TestQueueDSM', 'TestTopicDSM', done)
90+
createResources('TestQueueDSM', 'TestTopicDSM', (err) => {
91+
if (err) return done(err)
92+
93+
const phash = propagationHash.getHash()
94+
const producerHash = computePathwayHash(
95+
'test', 'tester',
96+
['direction:out', `topic:${TopicArn}`, 'type:sns'],
97+
ENTRY_PARENT_HASH,
98+
phash
99+
)
100+
expectedProducerHash = producerHash.readBigUInt64LE(0).toString()
101+
102+
const queueName = QueueUrl.split('/').pop()
103+
expectedConsumerHash = computePathwayHash(
104+
'test', 'tester',
105+
['direction:in', `topic:${queueName}`, 'type:sqs'],
106+
producerHash,
107+
phash
108+
).readBigUInt64LE(0).toString()
109+
110+
done()
111+
})
88112
})
89113

90114
after(done => {

packages/datadog-plugin-aws-sdk/test/sqs.dsm.spec.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const sinon = require('sinon')
99

1010
const { computePathwayHash } = require('../../dd-trace/src/datastreams/pathway')
1111
const { ENTRY_PARENT_HASH } = require('../../dd-trace/src/datastreams/processor')
12+
const propagationHash = require('../../dd-trace/src/propagation-hash')
1213
const agent = require('../../dd-trace/test/plugins/agent')
1314
const { withVersions } = require('../../dd-trace/test/setup/mocha')
1415
const { assertObjectContains } = require('../../../integration-tests/helpers')
@@ -77,19 +78,22 @@ describe('Plugin', () => {
7778
})
7879

7980
beforeEach(() => {
81+
const phash = propagationHash.getHash()
8082
const producerHash = computePathwayHash(
8183
'test',
8284
'tester',
8385
['direction:out', 'topic:' + queueNameDSM, 'type:sqs'],
84-
ENTRY_PARENT_HASH
86+
ENTRY_PARENT_HASH,
87+
phash
8588
)
8689

8790
expectedProducerHash = producerHash.readBigUInt64LE(0).toString()
8891
expectedConsumerHash = computePathwayHash(
8992
'test',
9093
'tester',
9194
['direction:in', 'topic:' + queueNameDSM, 'type:sqs'],
92-
producerHash
95+
producerHash,
96+
phash
9397
).readBigUInt64LE(0).toString()
9498
})
9599

packages/datadog-plugin-bullmq/test/dsm.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ const { createIntegrationTestSuite } = require('../../dd-trace/test/setup/helper
99
const DataStreamsContext = require('../../dd-trace/src/datastreams/context')
1010
const { computePathwayHash } = require('../../dd-trace/src/datastreams/pathway')
1111
const { ENTRY_PARENT_HASH, DataStreamsProcessor } = require('../../dd-trace/src/datastreams/processor')
12+
const propagationHash = require('../../dd-trace/src/propagation-hash')
1213
const TestSetup = require('./test-setup')
1314

1415
const testSetup = new TestSetup()
1516

1617
const getDsmPathwayHash = (queueName, isProducer, parentHash) => {
1718
const edgeTags = [isProducer ? 'direction:out' : 'direction:in', `topic:${queueName}`, 'type:bullmq']
1819
edgeTags.sort()
19-
return computePathwayHash('test', 'tester', edgeTags, parentHash)
20+
return computePathwayHash('test', 'tester', edgeTags, parentHash, propagationHash.getHash())
2021
}
2122

2223
createIntegrationTestSuite('bullmq', 'bullmq', {

packages/datadog-plugin-confluentinc-kafka-javascript/test/dsm.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const { withVersions } = require('../../dd-trace/test/setup/mocha')
1111
const DataStreamsContext = require('../../dd-trace/src/datastreams/context')
1212
const { computePathwayHash } = require('../../dd-trace/src/datastreams/pathway')
1313
const { ENTRY_PARENT_HASH, DataStreamsProcessor } = require('../../dd-trace/src/datastreams/processor')
14+
const propagationHash = require('../../dd-trace/src/propagation-hash')
1415

1516
const getDsmPathwayHash = (testTopic, isProducer, parentHash) => {
1617
let edgeTags
@@ -21,7 +22,7 @@ const getDsmPathwayHash = (testTopic, isProducer, parentHash) => {
2122
}
2223

2324
edgeTags.sort()
24-
return computePathwayHash('test', 'tester', edgeTags, parentHash)
25+
return computePathwayHash('test', 'tester', edgeTags, parentHash, propagationHash.getHash())
2526
}
2627

2728
describe('Plugin', () => {

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const sinon = require('sinon')
77

88
const { computePathwayHash } = require('../../dd-trace/src/datastreams/pathway')
99
const { ENTRY_PARENT_HASH, DataStreamsProcessor } = require('../../dd-trace/src/datastreams/processor')
10+
const propagationHash = require('../../dd-trace/src/propagation-hash')
1011
const id = require('../../dd-trace/src/id')
1112
const agent = require('../../dd-trace/test/plugins/agent')
1213
const { withVersions } = require('../../dd-trace/test/setup/mocha')
@@ -65,17 +66,20 @@ describe('Plugin', () => {
6566

6667
const dsmFullTopic = `projects/${project}/topics/${dsmTopicName}`
6768

69+
const phash = propagationHash.getHash()
6870
expectedProducerHash = computePathwayHash(
6971
'test',
7072
'tester',
7173
['direction:out', 'topic:' + dsmFullTopic, 'type:google-pubsub'],
72-
ENTRY_PARENT_HASH
74+
ENTRY_PARENT_HASH,
75+
phash
7376
)
7477
expectedConsumerHash = computePathwayHash(
7578
'test',
7679
'tester',
7780
['direction:in', 'topic:' + dsmFullTopic, 'type:google-pubsub'],
78-
expectedProducerHash
81+
expectedProducerHash,
82+
phash
7983
)
8084
})
8185

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const { expectSomeSpan, withDefaults } = require('../../dd-trace/test/plugins/he
1313

1414
const { computePathwayHash } = require('../../dd-trace/src/datastreams/pathway')
1515
const { DataStreamsProcessor, ENTRY_PARENT_HASH } = require('../../dd-trace/src/datastreams/processor')
16+
const propagationHash = require('../../dd-trace/src/propagation-hash')
1617
const { expectedSchema, rawExpectedSchema } = require('./naming')
1718
const gc = global.gc ?? (() => {})
1819

@@ -395,17 +396,20 @@ describe('Plugin', () => {
395396

396397
const dsmFullTopic = `projects/${project}/topics/${dsmTopicName}`
397398

399+
const phash = propagationHash.getHash()
398400
expectedProducerHash = computePathwayHash(
399401
'test',
400402
'tester',
401403
['direction:out', 'topic:' + dsmFullTopic, 'type:google-pubsub'],
402-
ENTRY_PARENT_HASH
404+
ENTRY_PARENT_HASH,
405+
phash
403406
)
404407
expectedConsumerHash = computePathwayHash(
405408
'test',
406409
'tester',
407410
['direction:in', 'topic:' + dsmFullTopic, 'type:google-pubsub'],
408-
expectedProducerHash
411+
expectedProducerHash,
412+
phash
409413
)
410414
})
411415

packages/datadog-plugin-kafkajs/test/dsm.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const agent = require('../../dd-trace/test/plugins/agent')
1212
const DataStreamsContext = require('../../dd-trace/src/datastreams/context')
1313
const { computePathwayHash } = require('../../dd-trace/src/datastreams/pathway')
1414
const { ENTRY_PARENT_HASH, DataStreamsProcessor } = require('../../dd-trace/src/datastreams/processor')
15+
const propagationHash = require('../../dd-trace/src/propagation-hash')
1516
const { assertObjectContains } = require('../../../integration-tests/helpers')
1617

1718
const testKafkaClusterId = '5L6g3nShT-eMCtK--X86sw'
@@ -28,7 +29,7 @@ const getDsmPathwayHash = (testTopic, clusterIdAvailable, isProducer, parentHash
2829
edgeTags.push(`kafka_cluster_id:${testKafkaClusterId}`)
2930
}
3031
edgeTags.sort()
31-
return computePathwayHash('test', 'tester', edgeTags, parentHash)
32+
return computePathwayHash('test', 'tester', edgeTags, parentHash, propagationHash.getHash())
3233
}
3334

3435
describe('Plugin', () => {

0 commit comments

Comments
 (0)