Skip to content

Commit c9e1082

Browse files
authored
fix nomenclature file being loaded multiple times (#4168)
1 parent 2d874ad commit c9e1082

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

packages/dd-trace/src/plugin_manager.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const { channel } = require('dc-polyfill')
44
const { isFalse } = require('./util')
55
const plugins = require('./plugins')
66
const log = require('./log')
7-
const Nomenclature = require('./service-naming')
87

98
const loadChannel = channel('dd-trace:instrumentation:load')
109

@@ -102,7 +101,7 @@ module.exports = class PluginManager {
102101
// like instrumenter.enable()
103102
configure (config = {}) {
104103
this._tracerConfig = config
105-
Nomenclature.configure(config)
104+
this._tracer._nomenclature.configure(config)
106105

107106
for (const name in pluginClasses) {
108107
this.loadPlugin(name)

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const Plugin = require('./plugin')
44
const { storage } = require('../../../datadog-core')
55
const analyticsSampler = require('../analytics_sampler')
66
const { COMPONENT } = require('../constants')
7-
const Nomenclature = require('../service-naming')
87

98
class TracingPlugin extends Plugin {
109
constructor (...args) {
@@ -29,7 +28,7 @@ class TracingPlugin extends Plugin {
2928
kind = this.constructor.kind
3029
} = opts
3130

32-
return Nomenclature.serviceName(type, kind, id, opts)
31+
return this._tracer._nomenclature.serviceName(type, kind, id, opts)
3332
}
3433

3534
operationName (opts = {}) {
@@ -39,7 +38,7 @@ class TracingPlugin extends Plugin {
3938
kind = this.constructor.kind
4039
} = opts
4140

42-
return Nomenclature.opName(type, kind, id, opts)
41+
return this._tracer._nomenclature.opName(type, kind, id, opts)
4342
}
4443

4544
configure (config) {

packages/dd-trace/src/proxy.js

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const runtimeMetrics = require('./runtime_metrics')
66
const log = require('./log')
77
const { setStartupLogPluginManager } = require('./startup-log')
88
const telemetry = require('./telemetry')
9+
const nomenclature = require('./service-naming')
910
const PluginManager = require('./plugin_manager')
1011
const remoteConfig = require('./appsec/remote_config')
1112
const AppsecSdk = require('./appsec/sdk')
@@ -17,6 +18,7 @@ class Tracer extends NoopProxy {
1718
super()
1819

1920
this._initialized = false
21+
this._nomenclature = nomenclature
2022
this._pluginManager = new PluginManager(this)
2123
this.dogstatsd = new dogstatsd.NoopDogStatsDClient()
2224
this._tracingInitialized = false

packages/dd-trace/test/plugin_manager.spec.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const { channel } = require('dc-polyfill')
66
const proxyquire = require('proxyquire')
77

88
const loadChannel = channel('dd-trace:instrumentation:load')
9-
const Nomenclature = require('../../dd-trace/src/service-naming')
9+
const nomenclature = require('../../dd-trace/src/service-naming')
1010

1111
describe('Plugin Manager', () => {
1212
let tracer
@@ -19,7 +19,9 @@ describe('Plugin Manager', () => {
1919
let pm
2020

2121
beforeEach(() => {
22-
tracer = {}
22+
tracer = {
23+
_nomenclature: nomenclature
24+
}
2325
instantiated = []
2426
class FakePlugin {
2527
constructor (aTracer) {
@@ -249,7 +251,7 @@ describe('Plugin Manager', () => {
249251
let configureSpy
250252

251253
beforeEach(() => {
252-
configureSpy = sinon.spy(Nomenclature, 'configure')
254+
configureSpy = sinon.spy(tracer._nomenclature, 'configure')
253255
})
254256

255257
afterEach(() => {

0 commit comments

Comments
 (0)