-
Notifications
You must be signed in to change notification settings - Fork 324
R&D week: blackhole span #6326
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
Merged
Merged
R&D week: blackhole span #6326
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
37ae5c2
R&D week: blackhole span
amarziali af0cddb
blackhole manual tracing API
amarziali 25b195a
Decouple httpclient and aws sdk instrumentations with blackhole
amarziali 5508303
exclude blackhole from coverage
amarziali f5f7da5
Merge branch 'master' into andrea.marziali/blackhole
amarziali 1105e7f
Merge branch 'master' into andrea.marziali/blackhole
amarziali 47f4209
exlcude no-op from coverage
amarziali 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
26 changes: 26 additions & 0 deletions
26
...tation/src/main/java/datadog/trace/instrumentation/trace_annotation/DoNotTraceAdvice.java
This file contains hidden or 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,26 @@ | ||
| package datadog.trace.instrumentation.trace_annotation; | ||
|
|
||
| import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan; | ||
| import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.blackholeSpan; | ||
| import static datadog.trace.instrumentation.trace_annotation.TraceDecorator.DECORATE; | ||
|
|
||
| import datadog.trace.bootstrap.instrumentation.api.AgentScope; | ||
| import net.bytebuddy.asm.Advice; | ||
| import net.bytebuddy.implementation.bytecode.assign.Assigner; | ||
|
|
||
| public class DoNotTraceAdvice { | ||
| @Advice.OnMethodEnter(suppress = Throwable.class) | ||
| public static AgentScope before() { | ||
| return activateSpan(blackholeSpan()); | ||
| } | ||
|
|
||
| @Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class) | ||
| public static void after( | ||
| @Advice.Enter final AgentScope scope, | ||
| @Advice.Return(typing = Assigner.Typing.DYNAMIC, readOnly = false) Object result) { | ||
| if (scope != null) { | ||
| scope.close(); | ||
| result = DECORATE.wrapAsyncResultOrFinishSpan(result, scope.span()); | ||
| } | ||
| } | ||
| } |
44 changes: 44 additions & 0 deletions
44
...a/datadog/trace/instrumentation/trace_annotation/DoNotTraceAnnotationInstrumentation.java
This file contains hidden or 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,44 @@ | ||
| package datadog.trace.instrumentation.trace_annotation; | ||
|
|
||
| import static datadog.trace.agent.tooling.bytebuddy.matcher.HierarchyMatchers.declaresMethod; | ||
| import static datadog.trace.agent.tooling.bytebuddy.matcher.HierarchyMatchers.isAnnotatedWith; | ||
| import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named; | ||
|
|
||
| import com.google.auto.service.AutoService; | ||
| import datadog.trace.agent.tooling.Instrumenter; | ||
| import de.thetaphi.forbiddenapis.SuppressForbidden; | ||
| import net.bytebuddy.description.type.TypeDescription; | ||
| import net.bytebuddy.matcher.ElementMatcher; | ||
|
|
||
| @AutoService(Instrumenter.class) | ||
| public final class DoNotTraceAnnotationInstrumentation extends Instrumenter.Tracing | ||
| implements Instrumenter.ForTypeHierarchy { | ||
|
|
||
| @SuppressForbidden | ||
| public DoNotTraceAnnotationInstrumentation() { | ||
| super("not-not-trace", "do-not-trace-annotation"); | ||
| } | ||
|
|
||
| @Override | ||
| public String hierarchyMarkerType() { | ||
| return "datadog.trace.api.DoNotTrace"; | ||
| } | ||
|
|
||
| @Override | ||
| public ElementMatcher<TypeDescription> hierarchyMatcher() { | ||
| return declaresMethod(isAnnotatedWith(named(hierarchyMarkerType()))); | ||
| } | ||
|
|
||
| @Override | ||
| public String[] helperClassNames() { | ||
| return new String[] { | ||
| packageName + ".TraceDecorator", | ||
| }; | ||
| } | ||
|
|
||
| @Override | ||
| public void adviceTransformations(AdviceTransformation transformation) { | ||
| transformation.applyAdvice( | ||
| isAnnotatedWith(named(hierarchyMarkerType())), packageName + ".DoNotTraceAdvice"); | ||
| } | ||
| } |
This file contains hidden or 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
14 changes: 14 additions & 0 deletions
14
...strumentation/trace-annotation/src/test/java/dd/test/trace/annotation/DontTraceClass.java
This file contains hidden or 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,14 @@ | ||
| package dd.test.trace.annotation; | ||
|
|
||
| import datadog.trace.api.DoNotTrace; | ||
| import datadog.trace.api.Trace; | ||
|
|
||
| public class DontTraceClass { | ||
| @DoNotTrace | ||
| public void muted() { | ||
| normallyTraced(); | ||
| } | ||
|
|
||
| @Trace | ||
| public void normallyTraced() {} | ||
| } |
This file contains hidden or 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 hidden or 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
12 changes: 12 additions & 0 deletions
12
dd-trace-api/src/main/java/datadog/trace/api/DoNotTrace.java
This file contains hidden or 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,12 @@ | ||
| package datadog.trace.api; | ||
|
|
||
| import static java.lang.annotation.ElementType.METHOD; | ||
| import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
|
||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.Target; | ||
|
|
||
| /** Set this annotation to a method to mute tracing until its scope is closed */ | ||
| @Retention(RUNTIME) | ||
| @Target(METHOD) | ||
| public @interface DoNotTrace {} |
This file contains hidden or 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 hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.