Skip to content

Commit f24e2c7

Browse files
committed
push changes
1 parent 1aa4cd7 commit f24e2c7

File tree

5 files changed

+27
-4
lines changed

5 files changed

+27
-4
lines changed

.vscode/settings.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
{
2-
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"test:appsec:plugins:ci": "yarn services && nyc --no-clean --include \"packages/dd-trace/src/appsec/**/*.js\" -- npm run test:appsec:plugins",
2424
"test:debugger": "mocha -r 'packages/dd-trace/test/setup/mocha.js' 'packages/dd-trace/test/debugger/**/*.spec.js'",
2525
"test:debugger:ci": "nyc --no-clean --include 'packages/dd-trace/src/debugger/**/*.js' -- npm run test:debugger",
26-
"test:trace:core": "tap packages/dd-trace/test/encode/0.5.spec.js",
26+
"test:trace:core": "tap packages/dd-trace/test/tagger.spec.js",
2727
"test:trace:core:ci": "npm run test:trace:core -- --coverage --nyc-arg=--include=\"packages/dd-trace/src/**/*.js\"",
2828
"test:instrumentations": "mocha -r 'packages/dd-trace/test/setup/mocha.js' 'packages/datadog-instrumentations/test/**/*.spec.js'",
2929
"test:instrumentations:ci": "nyc --no-clean --include 'packages/datadog-instrumentations/src/**/*.js' -- npm run test:instrumentations",

packages/dd-trace/src/tagger.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function add (carrier, keyValuePairs, parseOtelTags = false) {
2121
try {
2222
if (typeof keyValuePairs === 'string') {
2323
// split on comma or whitespace
24-
const segments = keyValuePairs.split(/[ ,]+/)
24+
const segments = keyValuePairs.split(keyValuePairs.includes(',') ? ',' : ' ')
2525
for (const segment of segments) {
2626
const separatorIndex = parseOtelTags ? segment.indexOf('=') : segment.indexOf(':')
2727
if (separatorIndex === -1) continue

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,24 @@ describe('format', () => {
299299
})
300300
})
301301

302+
it('should extract empty tags', () => {
303+
spanContext._trace.tags = {
304+
foo: '',
305+
count: 1
306+
}
307+
308+
trace = format(span)
309+
310+
expect(trace.meta).to.include({
311+
foo: ''
312+
})
313+
314+
expect(trace.metrics).to.include({
315+
count: 1
316+
})
317+
})
318+
319+
302320
it('should discard user-defined tags with name HOSTNAME_KEY by default', () => {
303321
spanContext._tags[HOSTNAME_KEY] = 'some_hostname'
304322

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ describe('tagger', () => {
5454
expect(carrier).to.have.property('cKey', '')
5555
})
5656

57+
it('should add tags from space separated string3', () => {
58+
tagger.add(carrier, 'env:test,aKey:aVal bKey:bVal cKey:')
59+
60+
expect(carrier).to.have.property('env', 'test')
61+
expect(carrier).to.have.property('aKey', 'aVal bKey:bVal cKey:')
62+
})
63+
5764
it('should add tags as an array', () => {
5865
tagger.add(carrier, ['foo:bar', 'baz:qux'])
5966

0 commit comments

Comments
 (0)