-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Exclude uri from otel tracing #43885
Conversation
Thanks for your pull request! Your pull request does not follow our editorial rules. Could you have a look?
This message is automatically generated by a bot. |
/cc @brunobat (opentelemetry), @radcortez (opentelemetry) |
First draft pull request. Feel free to add any suggestions! cc: @brunobat |
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.
I think this is moving in the right direction @mcruzdev.
I think you should add a property where you could add a list of strings with paths that can be ignored.
it you could add a test in quarkus-integration-test-opentelemetry
it would be great.
...rc/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetryTracelessWithRootPathTest.java
Show resolved
Hide resolved
...test/java/io/quarkus/opentelemetry/deployment/common/traces/TracelessClassLevelResource.java
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
🙈 The PR is closed and the preview is expired. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
@mcruzdev can you please update src/main/asciidoc/opentelemetry-tracing.adoc
in the section related with sampling and add 2 sections, one for the annotation and another for the configuration?
Can you also swash and rebase the PR?
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
Thanks @mcruzdev
It's a great PR.
I added just some minor comments.
...n/java/io/quarkus/opentelemetry/runtime/AutoConfiguredOpenTelemetrySdkBuilderCustomizer.java
Outdated
Show resolved
Hide resolved
/** | ||
* Identifies that the current path should not be select for tracing. | ||
* <p> | ||
* Used together with {@code jakarta.ws.rs.Path} annotation. |
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.
Can you please add a test where a @Traceless
is used outside of a rest endpoint?
I imagine you get an exception, would it be possible to have a nice message in that case?
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.
We do not have an exception, should we add an exception?
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.
If this only makes sense for rest endpoints, yes.
integration-tests/opentelemetry/src/main/resources/application.properties
Outdated
Show resolved
Hide resolved
Sorry, for delay @brunobat. I have been very busy lately. I answered your comments! |
e31a5b7
to
f202f18
Compare
import io.quarkus.opentelemetry.runtime.tracing.Traceless; | ||
|
||
@Traceless | ||
public class NoResource { |
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.
@brunobat This one do not throw an exception, because we have the following rule:
if (Objects.isNull(possibleClassAnnotatedWithPath)) {
continue;
}
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, better throw a precise exception because their code will not behave as expected.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
f202f18
to
88f628d
Compare
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.
Excellent PR. Thanks very much @mcruzdev!
Status for workflow
|
Status for workflow
|
@@ -170,6 +192,77 @@ void dropNames( | |||
dropStaticResources.produce(new DropStaticResourcesBuildItem(resources)); | |||
} | |||
|
|||
private Set<String> generateTracelessUris(final List<AnnotationInstance> annotations, final String rootPath) { | |||
final Set<String> applicationUris = new HashSet<>(); | |||
for (AnnotationInstance annotation : annotations) { |
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.
Documentation says:
There are two ways to disable tracing for a specific REST endpoint.
I do not believe you can disable tracing for specific REST endpoints based on paths, because you cannot identify REST resource methods with path. Path to resource method is one-to-many
relation, but docs ATM says absolutely nothing about that.
I am worried about this annotation approach:
- What will happen if I annotate
@GET
method with certain path? Won't this will also exclude@PUT
and any other HTTP method? Same must be true for different consumed/produced types etc. if I have 10 different endpoints with same path and I put this one one endpoint, is it expected that all the endpoints are not traced? - If I placed this one
@Path("/hello/{id}") String method()
and I have another method@Path("/hello/more-specific") completelyDifferentMethod()
then both endpoints will be excluded even though I only placed this on one method with less specific path? - I can have endpoints only annotated with HTTP method like
@GET
etc. but this feature depends on@Path
annotation, so here I cannot disable endpointget()
:
@Path("something")
public class SomethingResource {
@GET
public String get() {
return "something";
}
@GET
@Path("another")
public String another() {
return "another";
}
}
- I think this won't work for subresources either, you will get illegal state for valid scenario like:
@Path("/simple")
public class SimpleQuarkusRestResource {
@Traceless
@Path("sub")
public SubResource subResource() {
return new SubResource();
}
}
public class SubResource {
@Path("123")
@GET
public String sub() {
return "sub";
}
@GET
@Path("otherSub")
public String otherPath() {
return "otherSub";
}
}
- it does not consider inheritance, https://jakarta.ee/specifications/restful-ws/4.0/jakarta-restful-ws-spec-4.0#annotationinheritance, if I have
@Path
on parent class endpoint or interface method without@Path
, I'll get exception message containingPlease ensure that the class is properly annotated with @Path annotation.
. - documentation speaks about endpoints, not paths. REST clients has also
@Path
, what happens if I put this on the REST client? Or better, if I put this on REST endpoints, this will not exclude traces for the client as well?
I suggest that someone who makes living working on Jakarta REST impl. like @geoand reviews this PR. Maybe it's alright, I wouldn't know.
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.
Path to resource method is one-to-many relation, but docs ATM says absolutely nothing about that
This is absolutely true for JAX-RS / Jakarta REST. When I look at @Traceless
, I expect it's matching to behave the same way as @PermissionsAllowed
for example - this PR does not seem to do that at all
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.
I believe that @Traceless
should be removed completely as it's behavior is wrong. Allowing users to configure the path to not be traced makes sense, but with the way things are now, @Traceless
is very misleading and get users into a lot of trouble.
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.
I want to make sure to properly acknowledge @mcruzdev for the work done here and @michalvavrik for raising this issue!
It's amazing to have such a great community that works so effectively on continuously improving Quarkus in so many ways!
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.
I want to make sure to properly acknowledge @mcruzdev for the work done here and @michalvavrik for raising this issue!
It's amazing to have such a great community that works so effectively on continuously improving Quarkus in so many ways!
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.
Thank you for catching this @michalvavrik. I really appreciate your reviews; I’ve been learning a lot.
We can remove the @Traceless
annotation and rely solely on the configuration for now until we have a better implementation through annotations.
@geoand can I send a pull request for removing it? From what I’ve seen, this hasn’t been released yet, 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.
cc: @brunobat
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.
Yes please do, this indeed has not been released yet.
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.
Was on a conference yesterday. I've replied in the new issue.
What
This pull request creates a new
BuildItem
that is used for drop uri from tracing when usingquarkus-opentelemetry
extension. TheDropApplicationUrisBuildItem
is generated from the scanning of the@Traceless
annotation.The
@Traceless
annotation is used with thejakarta.ws.rs.Path
annotation. If annotated at class level all uri below will be ignored for tracing.If your
@Path
annotation contains expression like@Path("/cars/{carId}")
the extension will ignore all thing aftercars
using, e.g.cars*
.Why
You can see the issue below, or directly this Stackoverflow discussion.
Fixes #42659