Skip to content

Commit

Permalink
Update OTel to 1.3.1 (#61)
Browse files Browse the repository at this point in the history
* Update OTel to 1.3.1

* Cleanup
  • Loading branch information
anuraaga authored Jun 28, 2021
1 parent 86e0e57 commit 497f57f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
4 changes: 2 additions & 2 deletions dependencyManagement/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ val DEPENDENCY_BOMS = listOf(
"com.google.protobuf:protobuf-bom:3.17.0",
"com.linecorp.armeria:armeria-bom:1.7.2",
"io.grpc:grpc-bom:1.37.1",
"io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:${if (!TEST_SNAPSHOTS) "1.2.0-alpha" else "1.3.0-alpha-SNAPSHOT"}",
"io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:${if (!TEST_SNAPSHOTS) "1.3.1-alpha" else "1.4.0-alpha-SNAPSHOT"}",
"org.apache.logging.log4j:log4j-bom:2.14.1",
"org.junit:junit-bom:5.7.2",
"org.springframework.boot:spring-boot-dependencies:2.4.5",
Expand Down Expand Up @@ -66,7 +66,7 @@ val DEPENDENCIES = listOf(
"commons-logging:commons-logging:1.2",
"com.sparkjava:spark-core:2.9.3",
"com.squareup.okhttp3:okhttp:4.9.1",
"io.opentelemetry.javaagent:opentelemetry-javaagent:${if (!TEST_SNAPSHOTS) "1.2.0" else "1.3.0-SNAPSHOT"}",
"io.opentelemetry.javaagent:opentelemetry-javaagent:${if (!TEST_SNAPSHOTS) "1.3.1" else "1.4.0-SNAPSHOT"}",
"net.bytebuddy:byte-buddy:1.11.0"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@

import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
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;

Expand All @@ -36,11 +35,10 @@ public AwsXrayLog4jInstrumentationModule() {
// The SPI will be merged with what's in the agent so we don't need to inject it, only our
// provider implementation.
@Override
public String[] helperResourceNames() {
return new String[] {
"software.amazon.opentelemetry.javaagent.instrumentation.log4j_2_13_2."
+ "AwsXrayContextDataProvider"
};
public List<String> helperResourceNames() {
return Collections.singletonList(
"software.amazon.opentelemetry.javaagent.instrumentation.log4j_2_13_2."
+ "AwsXrayContextDataProvider");
}

@Override
Expand All @@ -65,9 +63,8 @@ public ElementMatcher<TypeDescription> typeMatcher() {
}

@Override
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
public void transform(TypeTransformer transformer) {
// Nothing to instrument, no methods to match
return Collections.emptyMap();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.implementsInterface;
import static io.opentelemetry.javaagent.extension.matcher.ClassLoaderMatcher.hasClassesNamed;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.named;
Expand All @@ -28,11 +27,11 @@
import io.opentelemetry.api.trace.SpanContext;
import io.opentelemetry.instrumentation.logback.v1_0.internal.UnionMap;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
import io.opentelemetry.javaagent.instrumentation.api.InstrumentationContext;
import java.util.Collections;
import java.util.Map;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.implementation.bytecode.assign.Assigner.Typing;
import net.bytebuddy.matcher.ElementMatcher;
Expand All @@ -51,8 +50,8 @@ public ElementMatcher<TypeDescription> typeMatcher() {
}

@Override
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
public void transform(TypeTransformer transformer) {
transformer.applyAdviceToMethod(
isMethod()
.and(isPublic())
.and(named("getMDCPropertyMap").or(named("getMdc")))
Expand Down
15 changes: 14 additions & 1 deletion otelagent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,19 @@ base {
archivesBaseName = "aws-opentelemetry-agent"
}

val shadowClasspath by configurations.creating {
isCanBeConsumed = false
isCanBeResolved = true
attributes {
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling::class.java, Bundling.EXTERNAL))
}
}

dependencies {
implementation("io.opentelemetry.javaagent", "opentelemetry-javaagent", classifier = "all")
// Ensure dependency doesn't leak into POMs by using compileOnly and shadow-specific configuration.
val agentDep = create("io.opentelemetry.javaagent", "opentelemetry-javaagent", classifier = "all")
shadowClasspath(agentDep)
compileOnly(agentDep)
}

val bundledProjects = listOf(
Expand Down Expand Up @@ -60,6 +71,8 @@ tasks {
shadowJar {
archiveClassifier.set("")

configurations = listOf(shadowClasspath)

exclude("**/module-info.class")

mergeServiceFiles("inst/META-INF/services")
Expand Down

0 comments on commit 497f57f

Please sign in to comment.