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

Baggage support #4563

Merged
merged 45 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
1d46ff2
otel baggage support
ida613 Jul 31, 2024
951e4cb
modified otel baggage support
ida613 Jul 31, 2024
d14fe44
bug fix
ida613 Jul 31, 2024
55c9880
removed undefined function
ida613 Jul 31, 2024
0d626b2
unit test
ida613 Jul 31, 2024
87d8174
update implementation
ida613 Aug 1, 2024
f49cb62
added encoding
ida613 Aug 2, 2024
700f022
add span formatting
ida613 Aug 5, 2024
c0f74d8
revert format changes
ida613 Aug 6, 2024
d6672cc
update config options
ida613 Aug 7, 2024
d98648b
updated http encoding
ida613 Aug 13, 2024
7ffc64a
remove comments
ida613 Aug 13, 2024
4880dea
add noop and otel baggage support
ida613 Aug 13, 2024
a4b90c7
Merge branch 'master' into ida613/baggage
ida613 Aug 13, 2024
b2ff71c
updated according to rfc
ida613 Sep 19, 2024
d1a2be3
Merge branch 'master' into ida613/baggage
ida613 Sep 19, 2024
49aaa7a
fix unit test
ida613 Sep 19, 2024
d514bed
Merge branch 'ida613/baggage' of github.com:DataDog/dd-trace-js into …
ida613 Sep 19, 2024
32e91a7
Merge branch 'master' into ida613/baggage
ida613 Sep 19, 2024
8b9b917
update span api
ida613 Sep 20, 2024
de79a4e
logging debugging message
ida613 Sep 20, 2024
dae0866
Merge branch 'master' into ida613/baggage
ida613 Sep 20, 2024
089353f
bug fix
ida613 Sep 23, 2024
ac0f133
remove limits from baggage extraction
ida613 Sep 26, 2024
1ed2206
fix unit test
ida613 Sep 26, 2024
0b753fd
remove unused tests
ida613 Sep 26, 2024
489a81e
Merge branch 'master' into ida613/baggage
ida613 Sep 26, 2024
052e693
add baggage propagation style
ida613 Oct 20, 2024
6359a79
Merge branch 'master' into ida613/baggage
ida613 Oct 20, 2024
78c87d5
fix lint error
ida613 Oct 20, 2024
3719d66
account for when spanId and traceId are missing
ida613 Oct 20, 2024
54d926d
test for undefined traceId and spanId
ida613 Oct 20, 2024
098ac33
remove break statement
ida613 Oct 20, 2024
2809fe4
removed handling of undefined traceId and spandId
ida613 Oct 20, 2024
511fe14
handle baggage propagator
ida613 Oct 21, 2024
7109626
test theory
ida613 Oct 21, 2024
1f3ebc0
Merge branch 'master' into ida613/baggage
ida613 Oct 21, 2024
9f1bfac
bug fix
ida613 Oct 22, 2024
2e6afab
reverse yarn.lock changes
ida613 Oct 22, 2024
cadc687
remove yarn.lock changes
ida613 Oct 22, 2024
97ccd23
Merge branch 'master' into ida613/baggage
ida613 Oct 22, 2024
1249935
revert otel changes
ida613 Oct 23, 2024
c27f768
removed dead code and updated baggage pair limits
ida613 Oct 30, 2024
58d1b7f
Merge branch 'master' into ida613/baggage
ida613 Oct 30, 2024
f898c98
fix linter errors
ida613 Oct 30, 2024
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
3 changes: 3 additions & 0 deletions packages/dd-trace/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,9 @@ class Config {
this._setValue(defaults, 'url', undefined)
this._setValue(defaults, 'version', pkg.version)
this._setValue(defaults, 'instrumentation_config_id', undefined)
this._setValue(defaults, 'baggagePropagation', true)
this._setValue(defaults, 'baggageInject', true)
this._setValue(defaults, 'baggageExtract', true)
ida613 marked this conversation as resolved.
Show resolved Hide resolved
}

_applyEnvironment () {
Expand Down
11 changes: 11 additions & 0 deletions packages/dd-trace/src/opentracing/propagation/text_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ class TextMapPropagator {
spanContext._baggageItems && Object.keys(spanContext._baggageItems).forEach(key => {
carrier[baggagePrefix + key] = String(spanContext._baggageItems[key])
})
if (this._config.baggageInject === false) return
if (this._config.baggageInject === true || this._config.baggagePropagation === true) {
carrier.baggage = JSON.stringify(spanContext._baggageItems)
}
}

_injectTags (spanContext, carrier) {
Expand Down Expand Up @@ -540,6 +544,13 @@ class TextMapPropagator {
spanContext._baggageItems[match[1]] = carrier[key]
}
})
if (this._config.baggageExtract === false) return
if (this._config.baggageExtract === true || this._config.baggagePropagation === true) {
const baggages = JSON.parse(carrier.baggage)
for (const [key, value] of Object.entries(baggages)) {
spanContext._baggageItems[key] = spanContext._baggageItems[key] || value
}
}
}

_extractSamplingPriority (carrier, spanContext) {
Expand Down
12 changes: 12 additions & 0 deletions packages/dd-trace/src/opentracing/span.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,18 @@ class DatadogSpan {
return this._spanContext._baggageItems[key]
}

getAllBaggageItems () {
return this._spanContext._baggageItems
ida613 marked this conversation as resolved.
Show resolved Hide resolved
}

removeBaggageItem (key) {
delete this._spanContext._baggageItems[key]
}

removeAllBaggageItems () {
this._spanContext._baggageItems = {}
}

setTag (key, value) {
this._addTags({ [key]: value })
return this
Expand Down
Loading