-
Notifications
You must be signed in to change notification settings - Fork 9
feat: Implement baggage span tags feature #246
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
base: master
Are you sure you want to change the base?
Conversation
… the entire value. This tells us if the configuration is UNSET (so we apply default values) or if the configuration is disabled with an empty string value
- Change the individual baggage span tags into a list (I think I want to change it back) - Correctly add a default value at the main conf level
…ual `datadog_baggage_span_tag` directives, which feels more NGINX-y
doc/API.md
Outdated
of the current request. `<value>` is a string that may contain | ||
`$`-[variables][2] (including those provided by this module). | ||
|
||
### `datadog_baggage_span_tag` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Offline feedback: See if there is another name we can use for this directive that is more intuitive for users
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…ains all baggage items from the header and creates a corresponding span tag for each.
…e do not need to do a recursive lookup while handling each request.
…an_tags' directive which accepts one or more tags for the list of configured baggage keys to add as span tags, as opposed to multiple 'datadog_baggage_span_tag' directives that each add one baggage key to the list. The motivation for this approach is that it aligns with the DD_TRACE_BAGGAGE_TAG_KEYS environment variable adopted in other Datadog tracers that accepts one string of comma-separated keys (e.g. 'DD_TRACE_BAGGAGE_TAG_KEYS=user.id,account.id,session.id')
…tives: - 'datadog_baggage_span_tags' - 'baggage_span_tags_enabled'
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #246 +/- ##
==========================================
+ Coverage 68.61% 68.69% +0.07%
==========================================
Files 57 57
Lines 7322 7391 +69
Branches 1035 1051 +16
==========================================
+ Hits 5024 5077 +53
- Misses 1796 1804 +8
- Partials 502 510 +8
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ve added a few comments, in particular, I believe the wildcard case needs some rework. Additionally, I noticed a couple of scenarios that are not yet covered by tests:
datadog_baggage_span_tags user.id;
anddatadog_baggage_span off;
should not set span tags.datadog_baggage_span_tags user.id * fancy.tag;
, ensure that in this case all baggage is captured.
doc/API.md
Outdated
On the currently active span, if the current W3C baggage header has a baggage item | ||
whose key matches the specified `<key>`, automatically set a tag whose name is | ||
`baggage.<key>` and whose value is the value of the key-value pair. | ||
|
||
This overrides any `baggage_span_tags_enabled` directives at higher levels, | ||
and may be overriden by `baggage_span_tags_enabled` directives at lower levels. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current wording makes the directive harder to understand. I recommend simplifying it to convey the purpose as clearly and directly as possible.
On the currently active span, if the current W3C baggage header has a baggage item | |
whose key matches the specified `<key>`, automatically set a tag whose name is | |
`baggage.<key>` and whose value is the value of the key-value pair. | |
This overrides any `baggage_span_tags_enabled` directives at higher levels, | |
and may be overriden by `baggage_span_tags_enabled` directives at lower levels. | |
Set span tags for all baggage items matching `<key>` from the current W3C Baggage header. |
I also believe baggage_span_tags_enabled
should always take precedence over this directive. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes if the configuration is baggage_span_tags_enabled off
that should disable this. I believe I had a copy/paste issue here, sorry about that!
In commit 341fdb7 I've reworded this highlighted portion to say the following, which is essentially what you suggested. WDYT?
Set span tags for all items from the current W3C Baggage header with a matching `<key>`.
…ocumentation, and improved wildcard logic
…::variant<std::vector<std::string>, bool>'. This distinguishes between the first type containing baggage keys to set vs the second type indicating that the wildcard key '*' was specified so all baggage keys should be set.
…key>" and "datadog_baggage_span_tags_enabled off" are set, then no baggage span tags are set
In b9eee16 I've added a test case to cover this scenario.
For this scenario, I'm getting clarification in the RFC but my reading is that this does not invoke the wildcard behavior. This appears to only be activated when the configuration is exactly |
I confirmed with the RFC author that only the configuration |
That means, for the same directive,
That's error-prone, WDYT? |
…nt is 'all' or 'select'. 'all' invokes the wildcard behavior while 'select' accepts a list of keys
As discussed offline, to eliminate the |
Motivation
There are a set of W3C baggage items that the Datadog APM product, RUM product, etc. use to provide a comprehensive observability experience, which includes
user.id
,account.id
, andsession.id
. To deliver on the APM experience, we must make sure that the values are copied over to our web server spans as span tags.We also want to provide users the ability to customize this feature or disable if desired.
Changes
Adds new functionality to the Datadog NGINX module to automatically copy W3C baggage items as span tags to the
nginx
spans, following this RFC.This is implemented using two new NGINX directives, copied directly from the
doc/API.md
markdown file since the reference documentation should stand on its own:datadog_baggage_tags_enabled
datadog_baggage_tags_enabled on|off
http
,server
,location
If
on
, enable thedatadog_baggage_tags_keys
feature in the current configuration context.If
off
, disable thedatadog_baggage_tags_keys
feature in the current configuration context.datadog_baggage_tags_keys
datadog_baggage_tags_keys all | select <key> [<key> ...]
select user.id account.id session.id
http
,server
,location
Set span tags for items in the current W3C Baggage header.
To set span tags for baggage items with a matching
<key>
, usedatadog_baggage_tags_keys select <key> [<key> ...]
.To set span tags for all baggage items, use
datadog_baggage_tags_keys all
.