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

Exclude uri from otel tracing #43885

Merged
merged 1 commit into from
Nov 14, 2024
Merged

Exclude uri from otel tracing #43885

merged 1 commit into from
Nov 14, 2024

Conversation

mcruzdev
Copy link
Contributor

@mcruzdev mcruzdev commented Oct 15, 2024

What

This pull request creates a new BuildItem that is used for drop uri from tracing when using quarkus-opentelemetry extension. The DropApplicationUrisBuildItem is generated from the scanning of the @Traceless annotation.

The @Traceless annotation is used with the jakarta.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 after cars using, e.g. cars*.

Why

You can see the issue below, or directly this Stackoverflow discussion.

Fixes #42659

Copy link

quarkus-bot bot commented Oct 15, 2024

Thanks for your pull request!

Your pull request does not follow our editorial rules. Could you have a look?

  • description should not be empty, describe your intent or provide links to the issues this PR is fixing (using Fixes #NNNNN) or changelogs

This message is automatically generated by a bot.

Copy link

quarkus-bot bot commented Oct 15, 2024

/cc @brunobat (opentelemetry), @radcortez (opentelemetry)

@mcruzdev
Copy link
Contributor Author

mcruzdev commented Oct 15, 2024

First draft pull request. Feel free to add any suggestions!

cc: @brunobat

@mcruzdev mcruzdev marked this pull request as ready for review October 20, 2024 02:21
Copy link
Contributor

@brunobat brunobat left a 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.

This comment has been minimized.

Copy link

github-actions bot commented Oct 21, 2024

🙈 The PR is closed and the preview is expired.

This comment has been minimized.

This comment has been minimized.

@mcruzdev mcruzdev requested a review from brunobat October 23, 2024 00:25
Copy link
Contributor

@brunobat brunobat left a 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.

Copy link
Contributor

@brunobat brunobat left a 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.

/**
* Identifies that the current path should not be select for tracing.
* <p>
* Used together with {@code jakarta.ws.rs.Path} annotation.
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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.

@mcruzdev
Copy link
Contributor Author

mcruzdev commented Nov 13, 2024

Sorry, for delay @brunobat. I have been very busy lately.

I answered your comments!

import io.quarkus.opentelemetry.runtime.tracing.Traceless;

@Traceless
public class NoResource {
Copy link
Contributor Author

@mcruzdev mcruzdev Nov 13, 2024

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;
                    }

Copy link
Contributor

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.

Copy link
Contributor

@brunobat brunobat left a 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!

Copy link

quarkus-bot bot commented Nov 13, 2024

Status for workflow Quarkus Documentation CI

This is the status report for running Quarkus Documentation CI on commit 88f628d.

✅ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

Warning

There are other workflow runs running, you probably need to wait for their status before merging.

Copy link

quarkus-bot bot commented Nov 13, 2024

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit 88f628d.

✅ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

You can consult the Develocity build scans.


Flaky tests - Develocity

⚙️ JVM Tests - JDK 17

📦 integration-tests/opentelemetry-vertx-exporter

io.quarkus.it.opentelemetry.vertx.exporter.grpc.SimpleGrpcNoTLSNoCompressionTest.test - History

  • Assertion condition defined as a Lambda expression in io.quarkus.it.opentelemetry.vertx.exporter.AbstractExporterTest Expecting size of: [resource_metrics { resource { attributes { - org.awaitility.core.ConditionTimeoutException
org.awaitility.core.ConditionTimeoutException: 
Assertion condition defined as a Lambda expression in io.quarkus.it.opentelemetry.vertx.exporter.AbstractExporterTest 
Expecting size of:
  [resource_metrics {
  resource {
    attributes {
      key: "host.name"
      value {

@brunobat brunobat merged commit 309646d into quarkusio:main Nov 14, 2024
32 checks passed
@quarkus-bot quarkus-bot bot added this to the 3.18 - main milestone Nov 14, 2024
@quarkus-bot quarkus-bot bot added the kind/enhancement New feature or request label Nov 14, 2024
@@ -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) {
Copy link
Member

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 endpoint get():
@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 containing Please 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.

Copy link
Contributor

@geoand geoand Nov 26, 2024

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

Copy link
Contributor

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.

Copy link
Contributor

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!

Copy link
Contributor

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!

Copy link
Contributor Author

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc: @brunobat

Copy link
Contributor

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.

Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add exclude paths to OpenTelemetry Tracing
4 participants