Skip to content

Commit ad19337

Browse files
rochdevwatson
authored andcommitted
only load the naming schema version that is used (#5318)
1 parent a970345 commit ad19337

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

packages/dd-trace/src/service-naming/index.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
const { schemaDefinitions } = require('./schemas')
2-
31
class SchemaManager {
42
constructor () {
5-
this.schemas = schemaDefinitions
6-
this.config = { spanAttributeSchema: 'v0', spanRemoveIntegrationFromService: false }
3+
this.schemas = {}
4+
this.configure({ spanAttributeSchema: 'v0', spanRemoveIntegrationFromService: false })
75
}
86

97
get schema () {
@@ -31,6 +29,16 @@ class SchemaManager {
3129
}
3230

3331
configure (config = {}) {
32+
const { spanAttributeSchema, spanRemoveIntegrationFromService } = config
33+
34+
if (!this.schemas.v0 && spanAttributeSchema === 'v0') {
35+
this.schemas.v0 = require('./schemas/v0')
36+
}
37+
38+
if (!this.schemas.v1 && (spanAttributeSchema === 'v1' || spanRemoveIntegrationFromService)) {
39+
this.schemas.v1 = require('./schemas/v1')
40+
}
41+
3442
this.config = config
3543
}
3644
}

packages/dd-trace/src/service-naming/schemas/index.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

packages/dd-trace/test/setup/mocha.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const runtimeMetrics = require('../../src/runtime_metrics')
1010
const agent = require('../plugins/agent')
1111
const Nomenclature = require('../../src/service-naming')
1212
const { storage } = require('../../../datadog-core')
13-
const { schemaDefinitions } = require('../../src/service-naming/schemas')
1413
const { getInstrumentation } = require('./helpers/load-inst')
1514

1615
global.withVersions = withVersions
@@ -35,7 +34,7 @@ function withNamingSchema (
3534
const testTitle = 'service and operation naming' + (desc !== '' ? ` (${desc})` : '')
3635

3736
describe(testTitle, () => {
38-
Object.keys(schemaDefinitions).forEach(versionName => {
37+
['v0', 'v1'].forEach(versionName => {
3938
describe(`in version ${versionName}`, () => {
4039
before(() => {
4140
fullConfig = Nomenclature.config

0 commit comments

Comments
 (0)