[core] Propagate synthetics origin headers#699
Conversation
| def origin | ||
| hdr = @carrier[HTTP_HEADER_ORIGIN] | ||
| # Only return the value if it is not an empty string | ||
| hdr if hdr != '' |
There was a problem hiding this comment.
Is nil an acceptable output here?
There was a problem hiding this comment.
Yeah, I want nil instead of '' so I can tell whether we should set/propagate this header further.
| env[HTTP_HEADER_TRACE_ID] = context.trace_id.to_s | ||
| env[HTTP_HEADER_PARENT_ID] = context.span_id.to_s | ||
| env[HTTP_HEADER_SAMPLING_PRIORITY] = context.sampling_priority.to_s | ||
| env[HTTP_HEADER_ORIGIN] = context.origin.to_s if context.origin |
There was a problem hiding this comment.
Not a big deal, but it's fine if you call to_s on nil, it will just give you a '' string, as long as that's acceptable. Although when I look at this, the goal is to not set this header at all if the value is blank, so this is probably fine as is.
I might suggest we do the same for sampling priority line above, just as a minor bit of housekeeping and consistency.
There was a problem hiding this comment.
Yup, using nil as a means to say "do not propagate this header"
| 'HTTP_X_DATADOG_PARENT_ID' => '2', | ||
| 'HTTP_X_DATADOG_SAMPLING_PRIORITY' => Datadog::Ext::Priority::USER_KEEP.to_s | ||
| 'HTTP_X_DATADOG_SAMPLING_PRIORITY' => Datadog::Ext::Priority::USER_KEEP.to_s, | ||
| 'HTTP_X_DATADOG_ORIGIN' => 'synthetics' |
There was a problem hiding this comment.
Side note (not an action item for this PR), but we should move these distributed tracing examples, where possible, into some kind of shared examples, so we don't have to re-implement the tests for each integration.
delner
left a comment
There was a problem hiding this comment.
Overall looks good. Left a few minor suggestions, but they aren't blockers. Act at your discretion. Thanks @brettlangdon! 🎉
This PR adds support for extracting, injecting, and propagating
X-Datadog-Originheaders as a part of distributed tracing.X-Datadog-Originheader will be parsed and attached to the context ascontext.origin.X-Datadog-Originheader will be appended to any distributed tracing request from a context withcontext.originset._dd.origintag will be set on the root trace of the context set to the value fromcontext.origin.