-
Notifications
You must be signed in to change notification settings - Fork 848
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
HttpTraceContext::extract() fails on traceparent == null #767
Comments
Also, catching the exception and trying to manually set the parent to null through EDIT: My bad. There's |
I agree on this, and I think we should try to not throw exceptions for non-fatal cases. |
I will try fix it, please assign me |
@pavolloffay how do u think should we return null here ( opentelemetry-java/api/src/main/java/io/opentelemetry/trace/propagation/HttpTraceContext.java Line 113 in 7b601b1
SpanContext.INVALID ?Also i think that it's kinda heavy method, should i also refactor it? |
I'd love to see some refactoring in there, @DotSpy ! |
My advise is to keep different PRs for any refactoring (given it's not only about code style, but actual improved readability) and for the null-handling cases. |
@jkwatson @carlosalberto how do u think what should i return instead of throwing: Line 98 in bd4f373
or SpanContext.INVALID
|
I'm not a Tracing expert, but I think |
|
…l cases (#782) * fix: HttpTraceContext::extract() fails on traceparent == null (#767) * fix: HttpTraceContext::extract() fails on traceparent == null (#767) * fix: HttpTraceContext::extract() fails on traceparent == null (#767) * docs: add an * refactor: use invalid span context from HttpTraceContext * style: apply google code style Co-authored-by: Uladzislau Kiva <[email protected]>
I think we can close this one because it's merged |
Resolved by #782 |
Turns out the `fields` method returns the names of fields, but it's not mandatory that those fields are present. To cope with this, we blindly assume that extracting the span's parent will work, and catch the exception in the case where the parent is missing. See: open-telemetry/opentelemetry-java#767
io.opentelemetry.trace.propagation.HttpTraceContext::extract()
can be used to construct aSpanContext
from HTTP headers/request attributes. This is very useful when instrumenting servlets, for example.However, this method fails on an
IllegalArgumentException
when thetraceparent
attribute can't be located. I don't think this exception should be called, since root spans should not have this attribute set. I believe the correct behavior should just be to copy the null to the constructedSpanContext
.The text was updated successfully, but these errors were encountered: