forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce @traceless annotation for selectively disabling tracing
This currently only works for Quarkus REST Resolves: quarkusio#44733
- Loading branch information
Showing
8 changed files
with
178 additions
and
3 deletions.
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
17 changes: 17 additions & 0 deletions
17
extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/Traceless.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,17 @@ | ||
package io.quarkus.opentelemetry; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import io.smallrye.common.annotation.Experimental; | ||
|
||
/** | ||
* Identifies that the current path should not be select for tracing. | ||
*/ | ||
@Target({ ElementType.TYPE, ElementType.METHOD }) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Experimental("This annotation is only supported by Quarkus REST currently") | ||
public @interface Traceless { | ||
} |
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
...ry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/InternalAttributes.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.runtime.tracing; | ||
|
||
import io.opentelemetry.api.common.AttributeKey; | ||
import io.opentelemetry.api.common.Attributes; | ||
|
||
/** | ||
* Contains utilities for working with internal Quarkus attributes | ||
*/ | ||
public final class InternalAttributes { | ||
|
||
public static final AttributeKey<String> TRACELESS = AttributeKey.stringKey("TRACELESS"); | ||
|
||
public static boolean containsTraceless(Attributes attributes) { | ||
return Boolean.parseBoolean(attributes.get(TRACELESS)); | ||
} | ||
|
||
private InternalAttributes() { | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...quarkus/opentelemetry/runtime/tracing/intrumentation/resteasy/TracelessServerHandler.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,16 @@ | ||
package io.quarkus.opentelemetry.runtime.tracing.intrumentation.resteasy; | ||
|
||
import org.jboss.resteasy.reactive.server.core.ResteasyReactiveRequestContext; | ||
import org.jboss.resteasy.reactive.server.spi.ServerRestHandler; | ||
|
||
import io.opentelemetry.api.trace.Span; | ||
import io.opentelemetry.instrumentation.api.instrumenter.LocalRootSpan; | ||
import io.quarkus.opentelemetry.runtime.tracing.InternalAttributes; | ||
|
||
public class TracelessServerHandler implements ServerRestHandler { | ||
@Override | ||
public void handle(ResteasyReactiveRequestContext requestContext) throws Exception { | ||
Span localRootSpan = LocalRootSpan.current(); | ||
localRootSpan.setAttribute(InternalAttributes.TRACELESS, "true"); | ||
} | ||
} |
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
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
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