-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update OpenTelemetry Bridge to latest version
Remove some of the interfaces from the wrapped objects to stop encouraging casting to our interfaces as a way to integrate. Add instrumentation to sync our context with the new otel context. Due to implementation differences, there are still some edge cases where they can get out of sync.
- Loading branch information
1 parent
2535430
commit fa5d213
Showing
17 changed files
with
406 additions
and
496 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
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
53 changes: 53 additions & 0 deletions
53
...adog/trace/instrumentation/opentelemetry/context/OpenTelemetryContextInstrumentation.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,53 @@ | ||
package datadog.trace.instrumentation.opentelemetry.context; | ||
|
||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.implementsInterface; | ||
import static java.util.Collections.singletonMap; | ||
import static net.bytebuddy.matcher.ElementMatchers.named; | ||
import static net.bytebuddy.matcher.ElementMatchers.returns; | ||
import static net.bytebuddy.matcher.ElementMatchers.takesArgument; | ||
|
||
import com.google.auto.service.AutoService; | ||
import datadog.trace.agent.tooling.Instrumenter; | ||
import java.util.Map; | ||
import net.bytebuddy.description.method.MethodDescription; | ||
import net.bytebuddy.description.type.TypeDescription; | ||
import net.bytebuddy.matcher.ElementMatcher; | ||
|
||
/** | ||
* This is experimental instrumentation and should only be enabled for evaluation/testing purposes. | ||
*/ | ||
@AutoService(Instrumenter.class) | ||
public class OpenTelemetryContextInstrumentation extends Instrumenter.Default { | ||
public OpenTelemetryContextInstrumentation() { | ||
super("opentelemetry-beta"); | ||
} | ||
|
||
@Override | ||
protected boolean defaultEnabled() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public ElementMatcher<TypeDescription> typeMatcher() { | ||
return implementsInterface(named("io.opentelemetry.context.ContextStorage")); | ||
} | ||
|
||
@Override | ||
public String[] helperClassNames() { | ||
return new String[] { | ||
"datadog.trace.instrumentation.opentelemetry.OtelSpan", | ||
"datadog.trace.instrumentation.opentelemetry.TypeConverter", | ||
"datadog.trace.instrumentation.opentelemetry.TypeConverter$1", | ||
packageName + ".WrappedScope", | ||
}; | ||
} | ||
|
||
@Override | ||
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() { | ||
return singletonMap( | ||
named("attach") | ||
.and(takesArgument(0, named("io.opentelemetry.context.Context"))) | ||
.and(returns(named("io.opentelemetry.context.Scope"))), | ||
packageName + ".ContextStorageAdvice"); | ||
} | ||
} |
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
23 changes: 1 addition & 22 deletions
23
...n/opentelemetry/src/main/java8/datadog/trace/instrumentation/opentelemetry/OtelScope.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
Oops, something went wrong.