-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Restclient @WithSpan throws in java.lang.ClassCastException #36118
Comments
/cc @cescoffier (rest-client), @geoand (rest-client) |
The problem here is that rest client uses its own interceptor chain impl including custom invocation context ( FTR, some aspects of rest client having its own interceptor impl were recently discussed in #35558. We could change |
Also of note is that the next interceptors specification version (used in CDI 4.1) will add the ability to retrieve interceptor bindings effectively removing the need for |
@manovotn thanks for the analysis. What is the best way to deal with this? |
I am not sure... |
Right. My vote is to address this specific use case now as it could quite prevalent and think about a general fix later. @manovotn mind opening a PR with what you have in mind? |
@geoand so, I originally thought you could alter it like this but that's not helping here and you will get:
The custom |
Another approach I could think of is here - #36123 I am not a fan of this copy-pasta but we already had to do the same other parts of rest-client so in this particular case it doesn't seem as harmful. However, even with this solution I am still seeing the same |
Thanks @manovotn for the code. I'll debug what's going on. |
This is to retrieve the
On another note, what is the goal here? REST invocations (both server and client) are automatically traced and follow specific tracing rules for HTTP, so |
This is a really good point... Why do you need this @ennishol ? Only because of the |
@manovotn your PR works... Those warnings are just because the OTel exporter is trying to send traces to the OTel Collector and there's none. As soon as you have one, you can see the expected spans: |
@ennishol
|
@brunobat
|
@ennishol you can search by // ...
Span current = Span.current();
Response response;
try(Scope scope = current.makeCurrent()){
current.setAttribute("remote-id", 666L);
response = client.getResponse(666L);
}
// ... This is because you probably shouldn't add a new span just to extract the that id. |
@brunobat Thanks for suggestions. The thing is, our code sets the tag in all applications, so we want to have consistent tags everywhere. It is not just about searching this one trace, but possibly multiple ones across all applications without knowing URLs have been used in the requests so |
I was not saying that. It will work after the fix. @manovotn PR is enough to fix the exception and later enable this new annotation to work. |
Describe the bug
To be able to add a parameter to the trace, I added two annotations to rest client remote call
@WithSpan
and@SpanAttribute
as described in the open telemetry documentation:This does not work however and the error is:
Reproducer with test
code-with-quarkus.tar.gz
or start with
./mvnw quarkus:dev
andcurl http://localhost:8080/hello
When I remove
@WithSpan
then it works but the parameterid
is not propagated into the trace tags.Expected behavior
No response
Actual behavior
No response
How to Reproduce?
No response
Output of
uname -a
orver
No response
Output of
java -version
No response
GraalVM version (if different from Java)
No response
Quarkus version or git rev
No response
Build tool (ie. output of
mvnw --version
orgradlew --version
)No response
Additional information
No response
The text was updated successfully, but these errors were encountered: