diff --git a/agent/build.gradle b/agent/build.gradle index b470e6ba..9db1d84d 100644 --- a/agent/build.gradle +++ b/agent/build.gradle @@ -15,7 +15,7 @@ dependencies { //implementation project(path: ":custom", configuration: "shadow") customShadow project(path: ":instrumentation", configuration: "shadow") implementation project(path: ":core-bootstrap") - implementation "io.opentelemetry.javaagent:opentelemetry-javaagent:${versions.opentelemetryJavaagent}:all" + implementation "io.opentelemetry.javaagent:opentelemetry-javaagent:${versions.opentelemetryJavaagent}" implementation "com.appoptics.agent.java:core:${versions.appopticsCore}" implementation "com.appoptics.agent.java:metrics:${versions.appopticsMetrics}" } diff --git a/build.gradle b/build.gradle index 9f9b0444..d5b7ae24 100644 --- a/build.gradle +++ b/build.gradle @@ -9,8 +9,8 @@ subprojects { ext { versions = [ - opentelemetry : "1.3.0", - opentelemetryJavaagent: "1.3.0", + opentelemetry : "1.7.1", + opentelemetryJavaagent: "1.7.2", // opentelemetry : "1.1.0", // opentelemetryJavaagent: "1.1.0", bytebuddy : "1.10.18", diff --git a/buildSrc/src/main/java/io/opentelemetry/instrumentation/gradle/bytebuddy/ClasspathByteBuddyPlugin.java b/buildSrc/src/main/java/io/opentelemetry/instrumentation/gradle/bytebuddy/ClasspathByteBuddyPlugin.java index e211a59e..ffda174e 100644 --- a/buildSrc/src/main/java/io/opentelemetry/instrumentation/gradle/bytebuddy/ClasspathByteBuddyPlugin.java +++ b/buildSrc/src/main/java/io/opentelemetry/instrumentation/gradle/bytebuddy/ClasspathByteBuddyPlugin.java @@ -60,15 +60,15 @@ public boolean matches(TypeDescription typeDefinitions) { private static Plugin pluginFromClassPath( Iterable classPath, File sourceDirectory, String className) { try { - ClassLoader classLoader = classLoaderFromClassPath(classPath, sourceDirectory); + URLClassLoader classLoader = classLoaderFromClassPath(classPath, sourceDirectory); Class clazz = Class.forName(className, false, classLoader); - return (Plugin) clazz.getDeclaredConstructor().newInstance(); + return (Plugin) clazz.getDeclaredConstructor(URLClassLoader.class).newInstance(classLoader); } catch (Exception e) { throw new IllegalStateException("Failed to create ByteBuddy plugin instance", e); } } - private static ClassLoader classLoaderFromClassPath( + private static URLClassLoader classLoaderFromClassPath( Iterable classPath, File sourceDirectory) { List urls = new ArrayList<>(); urls.add(fileAsUrl(sourceDirectory)); diff --git a/custom/src/main/java/com/appoptics/opentelemetry/extensions/AppOpticsBootstrapPackagesProvider.java b/custom/src/main/java/com/appoptics/opentelemetry/extensions/AppOpticsBootstrapPackagesProvider.java index 3dddfa5e..3d2661f5 100644 --- a/custom/src/main/java/com/appoptics/opentelemetry/extensions/AppOpticsBootstrapPackagesProvider.java +++ b/custom/src/main/java/com/appoptics/opentelemetry/extensions/AppOpticsBootstrapPackagesProvider.java @@ -1,16 +1,20 @@ package com.appoptics.opentelemetry.extensions; import com.google.auto.service.AutoService; -import io.opentelemetry.javaagent.spi.BootstrapPackagesProvider; - -import java.util.Arrays; -import java.util.List; - -@AutoService(BootstrapPackagesProvider.class) -public class AppOpticsBootstrapPackagesProvider implements BootstrapPackagesProvider { +import io.opentelemetry.instrumentation.api.config.Config; +import io.opentelemetry.javaagent.extension.bootstrap.BootstrapPackagesBuilder; +import io.opentelemetry.javaagent.extension.bootstrap.BootstrapPackagesConfigurer; +/** + * This adds the Joboe core classes to the list which would always be loaded by the bootstrap classloader, + * no matter what classloader is used initially. + * The Otel agent instruments all classloaders and checks the class named to be loaded. It will load the class + * with the bootstrap classloader if the class mateches any of the prefix in the list above. + */ +@AutoService(BootstrapPackagesConfigurer.class) +public class AppOpticsBootstrapPackagesProvider implements BootstrapPackagesConfigurer { @Override - public List getPackagePrefixes() { - return Arrays.asList("com.tracelytics"); + public void configure(Config config, BootstrapPackagesBuilder builder) { + builder.add("com.tracelytics"); } } diff --git a/custom/src/main/java/com/appoptics/opentelemetry/extensions/AppOpticsContextPropagatorProvider.java b/custom/src/main/java/com/appoptics/opentelemetry/extensions/AppOpticsContextPropagatorProvider.java index d22cc303..7a7e3f93 100644 --- a/custom/src/main/java/com/appoptics/opentelemetry/extensions/AppOpticsContextPropagatorProvider.java +++ b/custom/src/main/java/com/appoptics/opentelemetry/extensions/AppOpticsContextPropagatorProvider.java @@ -2,13 +2,14 @@ import com.google.auto.service.AutoService; import io.opentelemetry.context.propagation.TextMapPropagator; +import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; import io.opentelemetry.sdk.autoconfigure.spi.ConfigurablePropagatorProvider; @AutoService(ConfigurablePropagatorProvider.class) public class AppOpticsContextPropagatorProvider implements ConfigurablePropagatorProvider { @Override - public TextMapPropagator getPropagator() { + public TextMapPropagator getPropagator(ConfigProperties config) { return new AppOpticsContextPropagator(); } diff --git a/custom/src/main/java/com/appoptics/opentelemetry/extensions/AppOpticsPropertySource.java b/custom/src/main/java/com/appoptics/opentelemetry/extensions/AppOpticsPropertySource.java index e8a4fea6..7217e9f6 100644 --- a/custom/src/main/java/com/appoptics/opentelemetry/extensions/AppOpticsPropertySource.java +++ b/custom/src/main/java/com/appoptics/opentelemetry/extensions/AppOpticsPropertySource.java @@ -1,7 +1,7 @@ package com.appoptics.opentelemetry.extensions; import com.google.auto.service.AutoService; -import io.opentelemetry.javaagent.spi.config.PropertySource; +import io.opentelemetry.javaagent.extension.config.ConfigPropertySource; import java.util.HashMap; import java.util.Map; @@ -9,8 +9,8 @@ /** * Provide various default properties when running OT agent with AO SPI implementations */ -@AutoService(PropertySource.class) -public class AppOpticsPropertySource implements PropertySource { +@AutoService(ConfigPropertySource.class) +public class AppOpticsPropertySource implements ConfigPropertySource { private static final Map PROPERTIES = new HashMap<>(); static { diff --git a/custom/src/main/java/com/appoptics/opentelemetry/extensions/AppOpticsSamplerProvider.java b/custom/src/main/java/com/appoptics/opentelemetry/extensions/AppOpticsSamplerProvider.java index d9a79220..f0e708ae 100644 --- a/custom/src/main/java/com/appoptics/opentelemetry/extensions/AppOpticsSamplerProvider.java +++ b/custom/src/main/java/com/appoptics/opentelemetry/extensions/AppOpticsSamplerProvider.java @@ -1,8 +1,8 @@ package com.appoptics.opentelemetry.extensions; import com.google.auto.service.AutoService; -import io.opentelemetry.sdk.autoconfigure.ConfigProperties; -import io.opentelemetry.sdk.autoconfigure.spi.ConfigurableSamplerProvider; +import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; +import io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSamplerProvider; import io.opentelemetry.sdk.trace.samplers.Sampler; @AutoService(ConfigurableSamplerProvider.class) diff --git a/custom/src/main/java/com/appoptics/opentelemetry/extensions/AppOpticsSpanExporterProvider.java b/custom/src/main/java/com/appoptics/opentelemetry/extensions/AppOpticsSpanExporterProvider.java index 97b7bce5..defbf0ac 100644 --- a/custom/src/main/java/com/appoptics/opentelemetry/extensions/AppOpticsSpanExporterProvider.java +++ b/custom/src/main/java/com/appoptics/opentelemetry/extensions/AppOpticsSpanExporterProvider.java @@ -2,8 +2,8 @@ import com.google.auto.service.AutoService; -import io.opentelemetry.sdk.autoconfigure.ConfigProperties; -import io.opentelemetry.sdk.autoconfigure.spi.ConfigurableSpanExporterProvider; +import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; +import io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider; import io.opentelemetry.sdk.trace.export.SpanExporter; @AutoService(ConfigurableSpanExporterProvider.class) diff --git a/custom/src/main/java/com/appoptics/opentelemetry/extensions/AppOpticsTracerProviderConfigurer.java b/custom/src/main/java/com/appoptics/opentelemetry/extensions/AppOpticsTracerProviderConfigurer.java index c59444ac..d80f6147 100644 --- a/custom/src/main/java/com/appoptics/opentelemetry/extensions/AppOpticsTracerProviderConfigurer.java +++ b/custom/src/main/java/com/appoptics/opentelemetry/extensions/AppOpticsTracerProviderConfigurer.java @@ -4,7 +4,8 @@ import com.google.auto.service.AutoService; import com.tracelytics.joboe.config.InvalidConfigException; import com.tracelytics.util.ServiceKeyUtils; -import io.opentelemetry.sdk.autoconfigure.spi.SdkTracerProviderConfigurer; +import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; +import io.opentelemetry.sdk.autoconfigure.spi.traces.SdkTracerProviderConfigurer; import io.opentelemetry.sdk.trace.SdkTracerProviderBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -12,7 +13,7 @@ @AutoService(SdkTracerProviderConfigurer.class) public class AppOpticsTracerProviderConfigurer implements SdkTracerProviderConfigurer { - private Logger logger = LoggerFactory.getLogger(getClass()); + private final Logger logger = LoggerFactory.getLogger(getClass()); public AppOpticsTracerProviderConfigurer() { try { Initializer.initialize(); @@ -22,7 +23,7 @@ public AppOpticsTracerProviderConfigurer() { } @Override - public void configure(SdkTracerProviderBuilder tracerProvider) { + public void configure(SdkTracerProviderBuilder tracerProvider, ConfigProperties config) { tracerProvider.addSpanProcessor(new AppOpticsRootSpanProcessor()); tracerProvider.addSpanProcessor(new AppOpticsProfilingSpanProcessor()); tracerProvider.addSpanProcessor(new AppOpticsInboundMetricsSpanProcessor()); diff --git a/gradle/instrumentation.gradle b/gradle/instrumentation.gradle index 6f8be9db..fce3a164 100644 --- a/gradle/instrumentation.gradle +++ b/gradle/instrumentation.gradle @@ -25,7 +25,7 @@ configurations { dependencies { compileOnly("io.opentelemetry:opentelemetry-sdk:${versions.opentelemetry}") - compileOnly("io.opentelemetry.javaagent:opentelemetry-javaagent-api:${versions.opentelemetryJavaagentAlpha}") + compileOnly("io.opentelemetry.javaagent:opentelemetry-javaagent-instrumentation-api:${versions.opentelemetryJavaagentAlpha}") compileOnly("io.opentelemetry.javaagent:opentelemetry-javaagent-extension-api:${versions.opentelemetryJavaagentAlpha}") //compileOnly("io.opentelemetry.javaagent:opentelemetry-javaagent-spi:${versions.opentelemetryJavaagentAlpha}") implementation "org.slf4j:slf4j-api:1.6.2" @@ -45,7 +45,7 @@ dependencies { afterEvaluate { dependencies { - compileOnly "io.opentelemetry.javaagent:opentelemetry-javaagent-api:${versions.opentelemetryJavaagentAlpha}" + compileOnly "io.opentelemetry.javaagent:opentelemetry-javaagent-instrumentation-api:${versions.opentelemetryJavaagentAlpha}" compileOnly "io.opentelemetry.javaagent:opentelemetry-javaagent-tooling:${versions.opentelemetryJavaagentAlpha}" compileOnly "net.bytebuddy:byte-buddy:${versions.bytebuddy}" compileOnly "io.opentelemetry:opentelemetry-api:${versions.opentelemetry}" @@ -55,7 +55,7 @@ afterEvaluate { } - def pluginName = 'io.opentelemetry.javaagent.tooling.muzzle.collector.MuzzleCodeGenerationPlugin' + def pluginName = 'io.opentelemetry.javaagent.tooling.muzzle.generation.MuzzleCodeGenerationPlugin' new ByteBuddyPluginConfigurator(project, sourceSets.main, pluginName, configurations.toolingRuntime + configurations.runtimeClasspath ).configure() diff --git a/instrumentation/appoptics-annotation/build.gradle b/instrumentation/appoptics-annotation/build.gradle index e44c0430..e6c15de4 100644 --- a/instrumentation/appoptics-annotation/build.gradle +++ b/instrumentation/appoptics-annotation/build.gradle @@ -6,7 +6,7 @@ apply from: "$rootDir/gradle/instrumentation.gradle" //} dependencies { - compileOnly "io.opentelemetry.instrumentation:opentelemetry-instrumentation-api:${versions.opentelemetryJavaagentAlpha}" + compileOnly "io.opentelemetry.javaagent:opentelemetry-javaagent-instrumentation-api:${versions.opentelemetryJavaagentAlpha}" compileOnly "com.appoptics.agent.java:core:${versions.appopticsCore}" compileOnly project(":appoptics-opentelemetry-sdk") compileOnly project(":custom") diff --git a/instrumentation/jdbc/src/main/java/com/appoptics/opentelemetry/instrumentation/AoStatementInstrumentation.java b/instrumentation/jdbc/src/main/java/com/appoptics/opentelemetry/instrumentation/AoStatementInstrumentation.java index e9ed6a6e..e8f93954 100644 --- a/instrumentation/jdbc/src/main/java/com/appoptics/opentelemetry/instrumentation/AoStatementInstrumentation.java +++ b/instrumentation/jdbc/src/main/java/com/appoptics/opentelemetry/instrumentation/AoStatementInstrumentation.java @@ -6,22 +6,17 @@ package com.appoptics.opentelemetry.instrumentation; import io.opentelemetry.context.Context; -import io.opentelemetry.context.Scope; import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; -import io.opentelemetry.javaagent.instrumentation.api.CallDepthThreadLocalMap; +import io.opentelemetry.javaagent.instrumentation.api.CallDepth; import net.bytebuddy.asm.Advice; -import net.bytebuddy.description.method.MethodDescription; import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.matcher.ElementMatcher; import java.sql.Statement; -import java.util.Map; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.implementsInterface; -import static io.opentelemetry.javaagent.extension.matcher.ClassLoaderMatcher.hasClassesNamed; -import static io.opentelemetry.javaagent.instrumentation.api.Java8BytecodeBridge.currentContext; -import static java.util.Collections.singletonMap; +import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; import static net.bytebuddy.matcher.ElementMatchers.*; /** @@ -52,7 +47,7 @@ public static class StatementAdvice { //@Advice.OnMethodEnter(suppress = Throwable.class) @Advice.OnMethodEnter public static void onEnter() { - if (CallDepthThreadLocalMap.getCallDepth(Statement.class).get() != 1) { //only report back when depth is one to avoid duplications + if (CallDepth.forClass(Statement.class).get() != 1) { //only report back when depth is one to avoid duplications return; } AoStatementTracer.writeStackTrace(Context.current()); diff --git a/instrumentation/spring/spring-webmvc-3.1/src/main/java/com/appoptics/opentelemetry/instrumentation/AoHandlerAdapterInstrumentation.java b/instrumentation/spring/spring-webmvc-3.1/src/main/java/com/appoptics/opentelemetry/instrumentation/AoHandlerAdapterInstrumentation.java index e1af58f4..2fe78184 100644 --- a/instrumentation/spring/spring-webmvc-3.1/src/main/java/com/appoptics/opentelemetry/instrumentation/AoHandlerAdapterInstrumentation.java +++ b/instrumentation/spring/spring-webmvc-3.1/src/main/java/com/appoptics/opentelemetry/instrumentation/AoHandlerAdapterInstrumentation.java @@ -18,7 +18,7 @@ import javax.servlet.http.HttpServletRequest; import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.implementsInterface; -import static io.opentelemetry.javaagent.extension.matcher.ClassLoaderMatcher.hasClassesNamed; +import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; import static net.bytebuddy.matcher.ElementMatchers.*; /**