-
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...c/main/java/io/quarkus/opentelemetry/deployment/tracing/DropApplicationUrisBuildItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.quarkus.opentelemetry.deployment.tracing; | ||
|
||
import io.quarkus.builder.item.MultiBuildItem; | ||
|
||
/** | ||
* Represents an application uri that must be ignored for tracing. | ||
*/ | ||
public final class DropApplicationUrisBuildItem extends MultiBuildItem { | ||
|
||
private final String uri; | ||
|
||
public DropApplicationUrisBuildItem(String uri) { | ||
this.uri = uri; | ||
} | ||
|
||
public String uri() { | ||
return uri; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
...t/src/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetrySuppressAppUrisTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package io.quarkus.opentelemetry.deployment; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.hamcrest.Matchers.is; | ||
|
||
import java.util.List; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.opentelemetry.sdk.trace.data.SpanData; | ||
import io.quarkus.opentelemetry.deployment.common.TracerRouter; | ||
import io.quarkus.opentelemetry.deployment.common.exporter.InMemoryExporter; | ||
import io.quarkus.opentelemetry.deployment.common.exporter.InMemoryMetricExporterProvider; | ||
import io.quarkus.opentelemetry.deployment.common.traces.TraceMeResource; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.restassured.RestAssured; | ||
|
||
public class OpenTelemetrySuppressAppUrisTest { | ||
@RegisterExtension | ||
static final QuarkusUnitTest TEST = new QuarkusUnitTest().setArchiveProducer( | ||
() -> ShrinkWrap.create(JavaArchive.class) | ||
.addPackage(InMemoryExporter.class.getPackage()) | ||
.addAsResource("resource-config/application.properties", "application.properties") | ||
.addAsResource( | ||
"META-INF/services-config/io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider", | ||
"META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider") | ||
.addAsResource(new StringAsset(InMemoryMetricExporterProvider.class.getCanonicalName()), | ||
"META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.metrics.ConfigurableMetricExporterProvider") | ||
.addClasses(TracerRouter.class, TraceMeResource.class)) | ||
.overrideConfigKey("quarkus.otel.traces.suppress-application-uris", "tracer,/hello/Itachi"); | ||
|
||
@Inject | ||
InMemoryExporter exporter; | ||
|
||
@BeforeEach | ||
void setup() { | ||
exporter.reset(); | ||
} | ||
|
||
@Test | ||
@DisplayName("Should not trace when the using configuration quarkus.otel.traces.suppress-application-uris without slash") | ||
void testingSuppressAppUrisWithoutSlash() { | ||
RestAssured.when() | ||
.get("/tracer").then() | ||
.statusCode(200) | ||
.body(is("Hello Tracer!")); | ||
|
||
RestAssured.when() | ||
.get("/trace-me").then() | ||
.statusCode(200) | ||
.body(is("trace-me")); | ||
|
||
List<SpanData> spans = exporter.getSpanExporter().getFinishedSpanItems(1); | ||
|
||
assertThat(spans) | ||
.hasSize(1) | ||
.satisfiesOnlyOnce(span -> assertThat(span.getName()).containsOnlyOnce("trace-me")); | ||
} | ||
|
||
@Test | ||
@DisplayName("Should not trace when the using configuration quarkus.otel.traces.suppress-application-uris with slash") | ||
void testingSuppressAppUrisWithSlash() { | ||
RestAssured.when() | ||
.get("/hello/Itachi").then() | ||
.statusCode(200) | ||
.body(is("Amaterasu!")); | ||
|
||
RestAssured.when() | ||
.get("/trace-me").then() | ||
.statusCode(200) | ||
.body(is("trace-me")); | ||
|
||
List<SpanData> spans = exporter.getSpanExporter().getFinishedSpanItems(1); | ||
|
||
assertThat(spans) | ||
.hasSize(1) | ||
.satisfiesOnlyOnce(span -> assertThat(span.getName()).containsOnlyOnce("trace-me")); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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:
@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?@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?@GET
etc. but this feature depends on@Path
annotation, so here I cannot disable endpointget()
:@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.
.@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.
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 allThere 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.