Skip to content

Commit 026023c

Browse files
Jordi Bertran de Balandatlhunter
authored andcommitted
don't compute service name unless necessary
1 parent b835b1f commit 026023c

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

packages/dd-trace/src/plugins/consumer.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,12 @@ class ConsumerPlugin extends InboundPlugin {
88
static get type () { return 'messaging' }
99

1010
startSpan (options) {
11-
const spanDefaults = {
12-
service: this.config.service || this.serviceName(),
13-
kind: this.constructor.kind
11+
if (!options.service) {
12+
options.service = this.config.service || this.serviceName()
13+
}
14+
if (!options.kind) {
15+
options.kind = this.constructor.kind
1416
}
15-
Object.keys(spanDefaults).forEach(
16-
key => {
17-
if (!options[key]) options[key] = spanDefaults[key]
18-
}
19-
)
2017
return super.startSpan(this.operationName(), options)
2118
}
2219
}

packages/dd-trace/src/plugins/producer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ class ProducerPlugin extends OutboundPlugin {
99

1010
startSpan (options) {
1111
const spanDefaults = {
12-
service: this.config.service || this.serviceName(),
1312
kind: this.constructor.kind
1413
}
14+
if (!options.service) {
15+
options.service = this.config.service || this.serviceName()
16+
}
1517
Object.keys(spanDefaults).forEach(
1618
key => {
1719
if (!options[key]) options[key] = spanDefaults[key]

0 commit comments

Comments
 (0)