-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'otel-fork-updated' into correct-history
- Loading branch information
Showing
19 changed files
with
321 additions
and
76 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
instrumentation/azure-sdk/javaagent/azure-sdk-javaagent.gradle
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,13 @@ | ||
apply from: "$rootDir/gradle/instrumentation.gradle" | ||
|
||
configurations { | ||
testRuntime.exclude group: "com.azure", module: "azure-core-tracing-opentelemetry" | ||
} | ||
|
||
dependencies { | ||
implementation(group: "com.azure", name: "azure-core-tracing-opentelemetry", version: "1.0.0-beta.8") { | ||
exclude(group: "com.azure", module: "azure-core") | ||
} | ||
|
||
library group: "com.azure", name: "azure-core", version: "1.14.0" | ||
} |
69 changes: 69 additions & 0 deletions
69
...va/io/opentelemetry/javaagent/instrumentation/azuresdk/AzureSdkInstrumentationModule.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,69 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.azuresdk; | ||
|
||
import static io.opentelemetry.javaagent.tooling.bytebuddy.matcher.ClassLoaderMatcher.hasClassesNamed; | ||
import static java.util.Collections.emptyMap; | ||
import static net.bytebuddy.matcher.ElementMatchers.named; | ||
import static net.bytebuddy.matcher.ElementMatchers.not; | ||
|
||
import com.google.auto.service.AutoService; | ||
import io.opentelemetry.javaagent.tooling.InstrumentationModule; | ||
import io.opentelemetry.javaagent.tooling.TypeInstrumentation; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
import net.bytebuddy.description.method.MethodDescription; | ||
import net.bytebuddy.description.type.TypeDescription; | ||
import net.bytebuddy.matcher.ElementMatcher; | ||
|
||
@AutoService(InstrumentationModule.class) | ||
public class AzureSdkInstrumentationModule extends InstrumentationModule { | ||
public AzureSdkInstrumentationModule() { | ||
super("azure-sdk"); | ||
} | ||
|
||
@Override | ||
public boolean isHelperClass(String className) { | ||
return className.startsWith("com.azure.core.tracing.opentelemetry."); | ||
} | ||
|
||
@Override | ||
public String[] helperResourceNames() { | ||
return new String[] { | ||
"META-INF/services/com.azure.core.http.policy.AfterRetryPolicyProvider", | ||
"META-INF/services/com.azure.core.util.tracing.Tracer" | ||
}; | ||
} | ||
|
||
@Override | ||
public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() { | ||
return hasClassesNamed("com.azure.core.util.tracing.Tracer") | ||
.and(not(hasClassesNamed("com.azure.core.tracing.opentelemetry.OpenTelemetryTracer"))); | ||
} | ||
|
||
@Override | ||
public List<TypeInstrumentation> typeInstrumentations() { | ||
return Collections.singletonList(new EmptyTypeInstrumentation()); | ||
} | ||
|
||
public static class EmptyTypeInstrumentation implements TypeInstrumentation { | ||
@Override | ||
public ElementMatcher<? super TypeDescription> typeMatcher() { | ||
// we cannot use com.azure.core.util.tracing.Tracer here because one of the classes that we | ||
// inject implements this interface, causing the interface to be loaded while it's being | ||
// transformed, which leads to duplicate class definition error after the interface is | ||
// transformed and the triggering class loader tries to load it. | ||
return named("com.azure.core.util.tracing.TracerProxy"); | ||
} | ||
|
||
@Override | ||
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() { | ||
// Nothing to instrument, no methods to match | ||
return emptyMap(); | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
instrumentation/azure-sdk/javaagent/src/test/groovy/AzureSdkTest.groovy
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,15 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import com.azure.core.util.tracing.TracerProxy | ||
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification | ||
|
||
class AzureSdkTest extends AgentInstrumentationSpecification { | ||
|
||
def "test helper classes injected"() { | ||
expect: | ||
TracerProxy.isTracingEnabled() | ||
} | ||
} |
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
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
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.