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

Servlet instrumentation overwrites setStatus that was set manually earlier #2929

Closed
ryanrupp opened this issue May 7, 2021 · 2 comments · Fixed by #2956
Closed

Servlet instrumentation overwrites setStatus that was set manually earlier #2929

ryanrupp opened this issue May 7, 2021 · 2 comments · Fixed by #2956
Labels
bug Something isn't working

Comments

@ryanrupp
Copy link

ryanrupp commented May 7, 2021

Describe the bug
See Slack thread here. I have some custom instrumentation that is trying to call span.setStatus(error) on a span generated by servlet instrumentation - this works correctly. However, the servlet instrumentation ends up overwriting this status with UNSET here due to HttpStatusConverter returning unset for >= 100 && < 400 HTTP status codes. In the Slack thread it's mentioned the instrumentation should only ever set ERROR. Note my HTTP request actually does return a 200 (non-error) but this is the nature of the RPC protocol I'm instrumenting that it returns 200 with an error status in the response body instead of HTTP status code.

Steps to reproduce
Add an instrumentation that modifies the span that the servlet is going to operate on, calling setStatus(error).

What did you expect to see?
The span should be reported with status=error

What did you see instead?
The span was reported with status=unset

What version are you using?
1.1.0

Environment
OpenJDK 1.8

@ryanrupp ryanrupp added the bug Something isn't working label May 7, 2021
@ryanrupp
Copy link
Author

ryanrupp commented May 7, 2021

There's probably some other areas that are using this similar pattern of setting to UNSET explicitly instead of skipping the method span.setStatus method call, general pattern:

span.setStatus(mapFromException(something))

mapFromException(something) {
     return isError(something) ? ERROR : UNSET;
}

Other examples if you look for SpanStatus.UNSET usage e.g.:

https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/apache-dubbo/apache-dubbo-2.7/library/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboHelper.java#L27

Discussion around:

  1. Should span.setStatus ignore UNSET being passed?
  2. Otherwise maybe something in BaseTracer that handles the ignoring aspect:
setStatus(span, status) {
    if (status == UNSET) {
         return;
    }

    span.setStatus(status)
}

@iNikem
Copy link
Contributor

iNikem commented May 8, 2021

As I am going to submit a PR to spec soon to implement open-telemetry/opentelemetry-specification#1584 (comment), I can also submit a proposal that SDK should ignore Span.setStatus calls with UNSET. Let's see how the community will react to that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants