-
Notifications
You must be signed in to change notification settings - Fork 133
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
RUMM-3374 fix: Manual trace injection APIs are not available in DatadogTrace
#1415
RUMM-3374 fix: Manual trace injection APIs are not available in DatadogTrace
#1415
Conversation
…` APIs to unify wording in public APIs
DatadogTrace
DatadogTrace
9cd8347
to
3afe2ea
Compare
/// The `OTelHTTPHeadersWriter` should be used to inject trace propagation headers to | ||
/// the network requests send to the backend instrumented with Open Telemetry. | ||
/// The injected headers conform to [Open Telemetry](https://github.com/openzipkin/b3-propagation) standard. | ||
/// The `OTelHTTPHeadersWriter` class facilitates the injection of trace propagation headers into network requests | ||
/// targeted at a backend expecting [B3 propagation format](https://github.com/openzipkin/b3-propagation). | ||
/// | ||
/// Usage: | ||
/// | ||
/// var request = URLRequest(...) | ||
/// | ||
/// let writer = OTelHTTPHeadersWriter(injectEncoding: .single) | ||
/// let span = DatadogTracer.shared().startSpan("network request") | ||
/// writer.inject(spanContext: span.context) | ||
/// let span = Tracer.shared().startRootSpan(operationName: "network request") | ||
/// Tracer.shared().inject(spanContext: span.context, writer: writer) | ||
/// | ||
/// writer.traceHeaderFields.forEach { (field, value) in | ||
/// request.setValue(value, forHTTPHeaderField: field) | ||
/// } | ||
/// | ||
/// // call span.finish() when the request completes | ||
/// | ||
/// | ||
public class OTelHTTPHeadersWriter: TracePropagationHeadersWriter { |
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.
💡 Even with these changes, I'm concerned about the OTelHTTPHeadersWriter
name. OTel doesn't dictate this or that headers format and using "OTel" definitely does not imply B3-*
headers. It should be B3HTTPHeadersWriter
IMO (consistent with W3CHTTPHeadersWriter
and bare HTTPHeadersWriter
which uses x-datadog-*
headers).
I'd be up for deprecating this symbol and renaming it accordingly. WDYT @ganeshnj @maciejburda @maxep ?
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.
Yeah, I likeB3HTTPHeadersWriter
.
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.
Agreed :) B3*
is technically more correct 👍
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.
Renamed OTelHTTPHeaders*
to B3HTTPHeaders*
with deprecating the prior. See: 4a3819c
Datadog ReportBranch report: ✅ |
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.
Great stuff! I like renaming proposal
/// The `OTelHTTPHeadersWriter` should be used to inject trace propagation headers to | ||
/// the network requests send to the backend instrumented with Open Telemetry. | ||
/// The injected headers conform to [Open Telemetry](https://github.com/openzipkin/b3-propagation) standard. | ||
/// The `OTelHTTPHeadersWriter` class facilitates the injection of trace propagation headers into network requests | ||
/// targeted at a backend expecting [B3 propagation format](https://github.com/openzipkin/b3-propagation). | ||
/// | ||
/// Usage: | ||
/// | ||
/// var request = URLRequest(...) | ||
/// | ||
/// let writer = OTelHTTPHeadersWriter(injectEncoding: .single) | ||
/// let span = DatadogTracer.shared().startSpan("network request") | ||
/// writer.inject(spanContext: span.context) | ||
/// let span = Tracer.shared().startRootSpan(operationName: "network request") | ||
/// Tracer.shared().inject(spanContext: span.context, writer: writer) | ||
/// | ||
/// writer.traceHeaderFields.forEach { (field, value) in | ||
/// request.setValue(value, forHTTPHeaderField: field) | ||
/// } | ||
/// | ||
/// // call span.finish() when the request completes | ||
/// | ||
/// | ||
public class OTelHTTPHeadersWriter: TracePropagationHeadersWriter { |
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.
Yeah, I likeB3HTTPHeadersWriter
.
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.
Nice! Just for clarification: why only in DatadogTrace
and not in DatadogRUM
?
It's because the current use of Tracer.shared().inject(spanContext: span.context) so it won't make sense for RUM. Also, even if trace context is injected manually into request, there is currently no way to pass it to manually created RUM Resource for RUM <> APM correlation. |
…tion-impossible * develop: REPLAY-1936 fix access levels Update CHANGELOG.md REPLAY-1936 add objective-c interface
What and why?
🐞 This PR fixes the problem of
*HTTPHeaderWriter
APIs being not available after importingDatadogTrace
in2.0.0
.It was a miss during
1.x
→2.x
APIs migration. As a workaround, users had to importDatadogInternal
directly into their code. These APIs should be available with onlyimport DatadogTrace
.How?
The actual fix are following exports in
DatadogTrace
module:Extra work done:
samplingRate
→sampleRate
.OTelHTTPHeaders*
APIs are now deprecated and renamed toB3HTTPHeaders*
, see RUMM-3374 fix: Manual trace injection APIs are not available inDatadogTrace
#1415 (comment)Example
project to manually test ifimport DatadogTrace
will make writers work (unit tests are already in place):Review checklist
Custom CI job configuration (optional)