Skip to content

Commit 4ca58fd

Browse files
jbertrantlhunter
authored andcommitted
Peer service computation (#3177)
* introduce peer service computation for outbound edges: * add DD_TRACE_SPAN_PEER_SERVICE environment variable * add peer service computation logic * TODO: add tests for config, outbound, tracer (?) * provide a helper for testing peer service computation * defer plugin `finish` to TracingPlugin in children
1 parent 76eb950 commit 4ca58fd

File tree

29 files changed

+287
-28
lines changed

29 files changed

+287
-28
lines changed

packages/.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"proxyquire": true,
1212
"withNamingSchema": true,
1313
"withVersions": true,
14-
"withExports": true
14+
"withExports": true,
15+
"withPeerService": true
1516
},
1617
"rules": {
1718
"no-unused-expressions": 0,

packages/datadog-plugin-amqp10/test/index.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ describe('Plugin', () => {
6060
})
6161

6262
describe('when sending messages', () => {
63+
withPeerService(
64+
() => tracer,
65+
() => sender.send({ key: 'value' }),
66+
'localhost',
67+
'out.host'
68+
)
69+
6370
it('should do automatic instrumentation', done => {
6471
agent
6572
.use(traces => {

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ describe('Plugin', () => {
5353
})
5454

5555
describe('when sending commands', () => {
56+
withPeerService(
57+
() => tracer,
58+
() => channel.assertQueue('test', {}, () => {}),
59+
'localhost',
60+
'out.host'
61+
)
62+
5663
it('should do automatic instrumentation for immediate commands', done => {
5764
agent
5865
.use(traces => {
@@ -124,6 +131,13 @@ describe('Plugin', () => {
124131
})
125132

126133
describe('when publishing messages', () => {
134+
withPeerService(
135+
() => tracer,
136+
() => channel.assertQueue('test', {}, () => {}),
137+
'localhost',
138+
'out.host'
139+
)
140+
127141
it('should do automatic instrumentation', done => {
128142
agent
129143
.use(traces => {

packages/datadog-plugin-dns/src/lookup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class DNSLookupPlugin extends ClientPlugin {
3333
span.setTag('dns.address', result)
3434
}
3535

36-
span.finish()
36+
super.finish()
3737
}
3838
}
3939

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class GoogleCloudPubsubConsumerPlugin extends ConsumerPlugin {
3232
span.setTag('pubsub.ack', 1)
3333
}
3434

35-
span.finish()
35+
super.finish()
3636
}
3737
}
3838

packages/datadog-plugin-graphql/src/execute.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class GraphQLExecutePlugin extends TracingPlugin {
3232
finish ({ res, args }) {
3333
const span = this.activeSpan
3434
this.config.hooks.execute(span, args, res)
35-
span.finish()
35+
super.finish()
3636
}
3737
}
3838

packages/datadog-plugin-graphql/src/parse.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class GraphQLParsePlugin extends TracingPlugin {
2525

2626
this.config.hooks.parse(span, source, document)
2727

28-
span.finish()
28+
super.finish()
2929
}
3030
}
3131

packages/datadog-plugin-graphql/src/resolve.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,6 @@ class GraphQLResolvePlugin extends TracingPlugin {
5656
}
5757
}
5858

59-
finish (finishTime) {
60-
const span = this.activeSpan
61-
span.finish(finishTime)
62-
}
63-
6459
constructor (...args) {
6560
super(...args)
6661

packages/datadog-plugin-graphql/src/validate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class GraphQLValidatePlugin extends TracingPlugin {
2121
finish ({ document, errors }) {
2222
const span = this.activeSpan
2323
this.config.hooks.validate(span, document, errors)
24-
span.finish()
24+
super.finish()
2525
}
2626
}
2727

packages/datadog-plugin-grpc/src/client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class GrpcClientPlugin extends ClientPlugin {
5757
addMetadataTags(span, metadata, metadataFilter, 'response')
5858
}
5959

60-
span.finish()
60+
super.finish()
6161
}
6262

6363
configure (config) {

0 commit comments

Comments
 (0)