Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove version tag in telemetry metrics #5382

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions packages/dd-trace/src/telemetry/metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,11 @@ function hasPoints (metric) {
return metric.points.length > 0
}

let versionTag

class Metric {
constructor (namespace, metric, common, tags) {
this.namespace = namespace.toString()
this.metric = common ? metric : `nodejs.${metric}`
this.tags = tagArray(tags)
if (common) {
if (versionTag === undefined) {
versionTag = `version:${process.version}`
}
this.tags.push(versionTag)
}
this.common = common

this.points = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ describe('IastNamespace', () => {
expect(metric.metric).to.be.equal('metric.name')
expect(metric.namespace).to.be.equal('iast')
expect(metric.type).to.be.equal('count')
expect(metric.tags).to.be.deep.equal(['key:tag1', `version:${process.version}`])
expect(metric.tags).to.be.deep.equal(['key:tag1'])
})

it('should register a new count type metric and store it in the map supporting non array tags', () => {
Expand All @@ -161,7 +161,7 @@ describe('IastNamespace', () => {
expect(metric.metric).to.be.equal('metric.name')
expect(metric.namespace).to.be.equal('iast')
expect(metric.type).to.be.equal('count')
expect(metric.tags).to.be.deep.equal(['key:tag1', `version:${process.version}`])
expect(metric.tags).to.be.deep.equal(['key:tag1'])
})

it('should register a new distribution type metric and store it in the map', () => {
Expand All @@ -173,7 +173,7 @@ describe('IastNamespace', () => {
expect(metric.metric).to.be.equal('metric.name')
expect(metric.namespace).to.be.equal('iast')
expect(metric.type).to.be.equal('distribution')
expect(metric.tags).to.be.deep.equal(['key:tag1', `version:${process.version}`])
expect(metric.tags).to.be.deep.equal(['key:tag1'])
})

it('should not add the version tags to the tags array', () => {
Expand All @@ -183,7 +183,7 @@ describe('IastNamespace', () => {
const metric = namespace.getMetric('metric.name', tags)

expect(tags).to.be.deep.equal(['key:tag1'])
expect(metric.tags).to.be.deep.equal(['key:tag1', `version:${process.version}`])
expect(metric.tags).to.be.deep.equal(['key:tag1'])
})

it('should not create a previously created metric', () => {
Expand Down
42 changes: 14 additions & 28 deletions packages/dd-trace/test/telemetry/metrics.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ describe('metrics', () => {
interval: undefined,
type: 'count',
tags: [
'bar:baz',
`version:${process.version}`
'bar:baz'
],
common: true
}
Expand All @@ -83,8 +82,7 @@ describe('metrics', () => {
interval: undefined,
type: 'count',
tags: [
'bux:bax',
`version:${process.version}`
'bux:bax'
],
common: true
}
Expand Down Expand Up @@ -128,8 +126,7 @@ describe('metrics', () => {
interval: undefined,
type: 'count',
tags: [
'bar:baz',
`version:${process.version}`
'bar:baz'
],
common: true
}
Expand All @@ -145,8 +142,7 @@ describe('metrics', () => {
interval: undefined,
type: 'count',
tags: [
'bux:bax',
`version:${process.version}`
'bux:bax'
],
common: true
}
Expand Down Expand Up @@ -250,8 +246,7 @@ describe('metrics', () => {
interval: undefined,
type: 'count',
tags: [
'bar:baz',
`version:${process.version}`
'bar:baz'
],
common: true
},
Expand All @@ -261,8 +256,7 @@ describe('metrics', () => {
interval: undefined,
type: 'count',
tags: [
'bux:bax',
`version:${process.version}`
'bux:bax'
],
common: true
}
Expand Down Expand Up @@ -298,8 +292,7 @@ describe('metrics', () => {
metric: 'name',
tags: [
'foo:bar',
'baz:buz',
`version:${process.version}`
'baz:buz'
],
common: true,
points: []
Expand Down Expand Up @@ -405,8 +398,7 @@ describe('metrics', () => {
type: 'count',
tags: [
'foo:bar',
'baz:buz',
`version:${process.version}`
'baz:buz'
],
common: true
})
Expand All @@ -427,8 +419,7 @@ describe('metrics', () => {
metric: 'name',
tags: [
'foo:bar',
'baz:buz',
`version:${process.version}`
'baz:buz'
],
common: true,
points: []
Expand Down Expand Up @@ -477,8 +468,7 @@ describe('metrics', () => {
common: true,
tags: [
'foo:bar',
'baz:buz',
`version:${process.version}`
'baz:buz'
]
})
})
Expand All @@ -498,8 +488,7 @@ describe('metrics', () => {
metric: 'name',
tags: [
'foo:bar',
'baz:buz',
`version:${process.version}`
'baz:buz'
],
common: true,
points: []
Expand Down Expand Up @@ -567,8 +556,7 @@ describe('metrics', () => {
type: 'gauge',
tags: [
'foo:bar',
'baz:buz',
`version:${process.version}`
'baz:buz'
],
common: true
})
Expand All @@ -589,8 +577,7 @@ describe('metrics', () => {
metric: 'name',
tags: [
'foo:bar',
'baz:buz',
`version:${process.version}`
'baz:buz'
],
common: true,
points: [],
Expand Down Expand Up @@ -638,8 +625,7 @@ describe('metrics', () => {
type: 'rate',
tags: [
'foo:bar',
'baz:buz',
`version:${process.version}`
'baz:buz'
],
common: true
})
Expand Down
Loading