diff --git a/instrumentation/build.gradle.kts b/instrumentation/build.gradle.kts index dda7e4527..47c0fe647 100644 --- a/instrumentation/build.gradle.kts +++ b/instrumentation/build.gradle.kts @@ -34,6 +34,7 @@ dependencies{ implementation(project(":instrumentation:servlet:servlet-3.0")) implementation(project(":instrumentation:spark-2.3")) implementation(project(":instrumentation:grpc-1.6")) + implementation(project(":instrumentation:grpc-shaded-netty-1.9")) implementation(project(":instrumentation:okhttp:okhttp-3.0")) implementation(project(":instrumentation:apache-httpclient-4.0")) implementation(project(":instrumentation:jaxrs-client-2.0")) diff --git a/instrumentation/grpc-1.6/build.gradle.kts b/instrumentation/grpc-1.6/build.gradle.kts index 87d1dfeb7..53af2f784 100644 --- a/instrumentation/grpc-1.6/build.gradle.kts +++ b/instrumentation/grpc-1.6/build.gradle.kts @@ -14,8 +14,8 @@ muzzle { group = "io.grpc" module = "grpc-core" versions = "[1.6.0,)" - // for body capture via com.google.protobuf.util.JsonFormat - extraDependency("io.grpc:grpc-protobuf:1.6.0") + // for body capture via com.google.protobuf.Message to exist always + extraDependency("com.google.protobuf:protobuf-java:3.3.1") extraDependency("io.grpc:grpc-netty:1.6.0") } } @@ -34,6 +34,8 @@ idea { } } +val testGrpcVersion = "1.30.0" + protobuf { protoc { // The artifact spec for the Protobuf Compiler @@ -60,15 +62,21 @@ val grpcVersion = "1.6.0" dependencies { api("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-grpc-1.6:${versions["opentelemetry_java_agent"]}") api("io.opentelemetry.instrumentation:opentelemetry-grpc-1.6:${versions["opentelemetry_java_agent"]}") + implementation(project(":instrumentation:grpc-common")) + implementation(project(":shaded-protobuf-java-util", "shadow")) compileOnly("io.grpc:grpc-core:${grpcVersion}") - compileOnly("io.grpc:grpc-protobuf:${grpcVersion}") + compileOnly("io.grpc:grpc-protobuf:${grpcVersion}") { + exclude("com.google.protobuf", "protobuf-java-util") + } compileOnly("io.grpc:grpc-stub:${grpcVersion}") compileOnly("io.grpc:grpc-netty:${grpcVersion}") implementation("javax.annotation:javax.annotation-api:1.3.2") - testImplementation(testFixtures(project(":testing-common"))) + testImplementation(testFixtures(project(":testing-common"))) + testImplementation(project(":instrumentation:grpc-shaded-netty-1.9")) + testImplementation("io.grpc:grpc-core:${grpcVersion}") { version { strictly(grpcVersion) @@ -90,3 +98,46 @@ dependencies { } } } + +val grpcVersions = listOf(grpcVersion, "1.30.0") + +sourceSets { + for (version in grpcVersions) { + create("test_$version") { + dependencies { + implementationConfigurationName("io.grpc:grpc-core:$version") + } + } + } +} + +tasks.compileTestJava { + this.classpath += sourceSets.named("test_$grpcVersion").get().output +} +tasks.test { + classpath += sourceSets.named("test_$grpcVersion").get().output +} + +for (version in listOf("1.30.0")) { + val versionedConfiguration = configurations.create("test_${version}") { + extendsFrom(configurations.runtimeClasspath.get()) + } + dependencies { + versionedConfiguration(testFixtures(project(":testing-common"))) + versionedConfiguration("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-grpc-1.6:${versions["opentelemetry_java_agent"]}") + versionedConfiguration("io.opentelemetry.instrumentation:opentelemetry-grpc-1.6:${versions["opentelemetry_java_agent"]}") + versionedConfiguration(project(":instrumentation:grpc-shaded-netty-1.9")) + versionedConfiguration(platform("io.grpc:grpc-bom:$version")) + versionedConfiguration("io.grpc:grpc-core") + versionedConfiguration("io.grpc:grpc-protobuf") + versionedConfiguration("io.grpc:grpc-stub") + versionedConfiguration("io.grpc:grpc-netty") + + } + val versionedTest = task("test_${version}") { + group = "verification" + classpath = versionedConfiguration + sourceSets.main.get().output + sourceSets.test.get().output + sourceSets.named("test_$version").get().output + useJUnitPlatform() + } + tasks.check { dependsOn(versionedTest) } +} diff --git a/instrumentation/grpc-1.6/src/main/java/io/opentelemetry/javaagent/instrumentation/hypertrace/grpc/v1_6/GrpcSpanDecorator.java b/instrumentation/grpc-1.6/src/main/java/io/opentelemetry/javaagent/instrumentation/hypertrace/grpc/v1_6/GrpcSpanDecorator.java index b91cd314e..a44289735 100644 --- a/instrumentation/grpc-1.6/src/main/java/io/opentelemetry/javaagent/instrumentation/hypertrace/grpc/v1_6/GrpcSpanDecorator.java +++ b/instrumentation/grpc-1.6/src/main/java/io/opentelemetry/javaagent/instrumentation/hypertrace/grpc/v1_6/GrpcSpanDecorator.java @@ -17,11 +17,12 @@ package io.opentelemetry.javaagent.instrumentation.hypertrace.grpc.v1_6; import com.google.protobuf.Message; -import com.google.protobuf.util.JsonFormat; import io.grpc.Metadata; import io.grpc.Metadata.Key; import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.trace.Span; +import io.opentelemetry.javaagent.instrumentation.hypertrace.com.google.protobuf.util.JsonFormat; +import io.opentelemetry.javaagent.instrumentation.hypertrace.grpc.GrpcSemanticAttributes; import java.io.IOException; import java.util.LinkedHashMap; import java.util.Map; diff --git a/instrumentation/grpc-1.6/src/main/java/io/opentelemetry/javaagent/instrumentation/hypertrace/grpc/v1_6/NettyHttp2HeadersInstrumentationModule.java b/instrumentation/grpc-1.6/src/main/java/io/opentelemetry/javaagent/instrumentation/hypertrace/grpc/v1_6/NettyHttp2HeadersInstrumentationModule.java index 56aabae15..4c4d7ab2f 100644 --- a/instrumentation/grpc-1.6/src/main/java/io/opentelemetry/javaagent/instrumentation/hypertrace/grpc/v1_6/NettyHttp2HeadersInstrumentationModule.java +++ b/instrumentation/grpc-1.6/src/main/java/io/opentelemetry/javaagent/instrumentation/hypertrace/grpc/v1_6/NettyHttp2HeadersInstrumentationModule.java @@ -28,6 +28,7 @@ import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; import io.opentelemetry.javaagent.instrumentation.api.Java8BytecodeBridge; +import io.opentelemetry.javaagent.instrumentation.hypertrace.grpc.GrpcSemanticAttributes; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; diff --git a/instrumentation/grpc-1.6/src/test/java/io/opentelemetry/javaagent/instrumentation/hypertrace/grpc/v1_6/GrpcInstrumentationTest.java b/instrumentation/grpc-1.6/src/test/java/io/opentelemetry/javaagent/instrumentation/hypertrace/grpc/v1_6/GrpcInstrumentationTest.java index 924f95399..6ad6cf081 100644 --- a/instrumentation/grpc-1.6/src/test/java/io/opentelemetry/javaagent/instrumentation/hypertrace/grpc/v1_6/GrpcInstrumentationTest.java +++ b/instrumentation/grpc-1.6/src/test/java/io/opentelemetry/javaagent/instrumentation/hypertrace/grpc/v1_6/GrpcInstrumentationTest.java @@ -19,7 +19,6 @@ import com.google.protobuf.util.JsonFormat; import io.grpc.ForwardingServerCall; import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; import io.grpc.Metadata; import io.grpc.Server; import io.grpc.ServerBuilder; @@ -30,6 +29,7 @@ import io.grpc.Status; import io.grpc.StatusRuntimeException; import io.grpc.stub.MetadataUtils; +import io.opentelemetry.javaagent.instrumentation.hypertrace.grpc.GrpcSemanticAttributes; import io.opentelemetry.sdk.trace.data.SpanData; import java.io.IOException; import java.net.URL; @@ -104,10 +104,7 @@ public void sendHeaders(Metadata headers) { .build(); SERVER.start(); - CHANNEL = - ManagedChannelBuilder.forTarget(String.format("localhost:%d", SERVER.getPort())) - .usePlaintext(true) - .build(); + CHANNEL = new GrpcChannelProvider(SERVER.getPort()).get(); } @AfterAll diff --git a/instrumentation/grpc-1.6/src/test_1.30.0/java/io/opentelemetry/javaagent/instrumentation/hypertrace/grpc/v1_6/GrpcChannelProvider.java b/instrumentation/grpc-1.6/src/test_1.30.0/java/io/opentelemetry/javaagent/instrumentation/hypertrace/grpc/v1_6/GrpcChannelProvider.java new file mode 100644 index 000000000..c3e7b8ed6 --- /dev/null +++ b/instrumentation/grpc-1.6/src/test_1.30.0/java/io/opentelemetry/javaagent/instrumentation/hypertrace/grpc/v1_6/GrpcChannelProvider.java @@ -0,0 +1,37 @@ +/* + * Copyright The Hypertrace Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.opentelemetry.javaagent.instrumentation.hypertrace.grpc.v1_6; + +import io.grpc.ManagedChannel; +import io.grpc.ManagedChannelBuilder; +import java.util.function.Supplier; + +final class GrpcChannelProvider implements Supplier { + + private final int port; + + GrpcChannelProvider(final int port) { + this.port = port; + } + + @Override + public ManagedChannel get() { + return ManagedChannelBuilder.forTarget(String.format("localhost:%d", port)) + .usePlaintext() + .build(); + } +} diff --git a/instrumentation/grpc-1.6/src/test_1.6.0/java/io/opentelemetry/javaagent/instrumentation/hypertrace/grpc/v1_6/GrpcChannelProvider.java b/instrumentation/grpc-1.6/src/test_1.6.0/java/io/opentelemetry/javaagent/instrumentation/hypertrace/grpc/v1_6/GrpcChannelProvider.java new file mode 100644 index 000000000..50e655c7e --- /dev/null +++ b/instrumentation/grpc-1.6/src/test_1.6.0/java/io/opentelemetry/javaagent/instrumentation/hypertrace/grpc/v1_6/GrpcChannelProvider.java @@ -0,0 +1,37 @@ +/* + * Copyright The Hypertrace Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.opentelemetry.javaagent.instrumentation.hypertrace.grpc.v1_6; + +import io.grpc.ManagedChannel; +import io.grpc.ManagedChannelBuilder; +import java.util.function.Supplier; + +final class GrpcChannelProvider implements Supplier { + + private final int port; + + GrpcChannelProvider(final int port) { + this.port = port; + } + + @Override + public ManagedChannel get() { + return ManagedChannelBuilder.forTarget(String.format("localhost:%d", port)) + .usePlaintext(true) + .build(); + } +} diff --git a/instrumentation/grpc-common/build.gradle.kts b/instrumentation/grpc-common/build.gradle.kts new file mode 100644 index 000000000..9887ae99c --- /dev/null +++ b/instrumentation/grpc-common/build.gradle.kts @@ -0,0 +1,7 @@ +plugins { + `java-library` +} + +dependencies { + compileOnly("io.grpc:grpc-core:1.6.0") +} \ No newline at end of file diff --git a/instrumentation/grpc-1.6/src/main/java/io/opentelemetry/javaagent/instrumentation/hypertrace/grpc/v1_6/GrpcSemanticAttributes.java b/instrumentation/grpc-common/src/main/java/io/opentelemetry/javaagent/instrumentation/hypertrace/grpc/GrpcSemanticAttributes.java similarity index 99% rename from instrumentation/grpc-1.6/src/main/java/io/opentelemetry/javaagent/instrumentation/hypertrace/grpc/v1_6/GrpcSemanticAttributes.java rename to instrumentation/grpc-common/src/main/java/io/opentelemetry/javaagent/instrumentation/hypertrace/grpc/GrpcSemanticAttributes.java index e5caa1fcb..7ac554964 100644 --- a/instrumentation/grpc-1.6/src/main/java/io/opentelemetry/javaagent/instrumentation/hypertrace/grpc/v1_6/GrpcSemanticAttributes.java +++ b/instrumentation/grpc-common/src/main/java/io/opentelemetry/javaagent/instrumentation/hypertrace/grpc/GrpcSemanticAttributes.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.opentelemetry.javaagent.instrumentation.hypertrace.grpc.v1_6; +package io.opentelemetry.javaagent.instrumentation.hypertrace.grpc; import io.grpc.Metadata; diff --git a/instrumentation/grpc-shaded-netty-1.9/build.gradle.kts b/instrumentation/grpc-shaded-netty-1.9/build.gradle.kts new file mode 100644 index 000000000..363a96a6b --- /dev/null +++ b/instrumentation/grpc-shaded-netty-1.9/build.gradle.kts @@ -0,0 +1,29 @@ +plugins { + `java-library` + id("net.bytebuddy.byte-buddy") + id("io.opentelemetry.instrumentation.auto-instrumentation") + muzzle +} + +muzzle { + pass { + group = "io.grpc" + module = "grpc-netty-shaded" + versions = "[1.9.0,)" + assertInverse = true + } +} + +afterEvaluate{ + io.opentelemetry.instrumentation.gradle.bytebuddy.ByteBuddyPluginConfigurator(project, + sourceSets.main.get(), + "io.opentelemetry.javaagent.tooling.muzzle.collector.MuzzleCodeGenerationPlugin", + project(":javaagent-tooling").configurations["instrumentationMuzzle"] + configurations.runtimeClasspath + ).configure() +} + +dependencies { + compileOnly("io.grpc:grpc-core:1.9.0") + compileOnly("io.grpc:grpc-netty-shaded:1.9.0") + implementation(project(":instrumentation:grpc-common")) +} \ No newline at end of file diff --git a/instrumentation/grpc-shaded-netty-1.9/src/main/java/io/opentelemetry/javaagent/instrumentation/shaded/netty/ShadedNettyHttp2HeadersInstrumentationModule.java b/instrumentation/grpc-shaded-netty-1.9/src/main/java/io/opentelemetry/javaagent/instrumentation/shaded/netty/ShadedNettyHttp2HeadersInstrumentationModule.java new file mode 100644 index 000000000..b81c69079 --- /dev/null +++ b/instrumentation/grpc-shaded-netty-1.9/src/main/java/io/opentelemetry/javaagent/instrumentation/shaded/netty/ShadedNettyHttp2HeadersInstrumentationModule.java @@ -0,0 +1,36 @@ +/* + * Copyright The Hypertrace Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.opentelemetry.javaagent.instrumentation.shaded.netty; + +import com.google.auto.service.AutoService; +import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; +import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; +import java.util.Collections; +import java.util.List; + +@AutoService(InstrumentationModule.class) +public final class ShadedNettyHttp2HeadersInstrumentationModule extends InstrumentationModule { + + public ShadedNettyHttp2HeadersInstrumentationModule() { + super("grpc-netty", "ht", "grpc-netty-ht"); + } + + @Override + public List typeInstrumentations() { + return Collections.singletonList(new ShadedNettyUtilsInstrumentation()); + } +} diff --git a/instrumentation/grpc-shaded-netty-1.9/src/main/java/io/opentelemetry/javaagent/instrumentation/shaded/netty/ShadedNettyUtilsInstrumentation.java b/instrumentation/grpc-shaded-netty-1.9/src/main/java/io/opentelemetry/javaagent/instrumentation/shaded/netty/ShadedNettyUtilsInstrumentation.java new file mode 100644 index 000000000..dff744467 --- /dev/null +++ b/instrumentation/grpc-shaded-netty-1.9/src/main/java/io/opentelemetry/javaagent/instrumentation/shaded/netty/ShadedNettyUtilsInstrumentation.java @@ -0,0 +1,85 @@ +/* + * Copyright The Hypertrace Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.opentelemetry.javaagent.instrumentation.shaded.netty; + +import static net.bytebuddy.matcher.ElementMatchers.failSafe; +import static net.bytebuddy.matcher.ElementMatchers.isMethod; +import static net.bytebuddy.matcher.ElementMatchers.named; +import static net.bytebuddy.matcher.ElementMatchers.takesArguments; + +import io.grpc.Metadata; +import io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2Headers; +import io.opentelemetry.api.trace.Span; +import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; +import io.opentelemetry.javaagent.instrumentation.api.Java8BytecodeBridge; +import io.opentelemetry.javaagent.instrumentation.shaded.netty.utils.NettyUtils; +import java.util.HashMap; +import java.util.Map; +import net.bytebuddy.asm.Advice; +import net.bytebuddy.description.method.MethodDescription; +import net.bytebuddy.description.type.TypeDescription; +import net.bytebuddy.matcher.ElementMatcher; + +final class ShadedNettyUtilsInstrumentation implements TypeInstrumentation { + + @Override + public ElementMatcher typeMatcher() { + return failSafe(named("io.grpc.netty.shaded.io.grpc.netty.Utils")); + } + + @Override + public Map, String> transformers() { + Map, String> transformers = new HashMap<>(); + transformers.put( + isMethod().and(named("convertClientHeaders")).and(takesArguments(6)), + ShadedNettyUtilsInstrumentation.class.getName() + "$Utils_convertClientHeaders_Advice"); + transformers.put( + isMethod().and(named("convertHeaders")).and(takesArguments(1)), + ShadedNettyUtilsInstrumentation.class.getName() + "$GrpcUtils_convertHeaders_Advice"); + return transformers; + } + + static final class Utils_convertClientHeaders_Advice { + @Advice.OnMethodExit(suppress = Throwable.class) + public static void exit( + @Advice.Argument(1) Object scheme, + @Advice.Argument(2) Object defaultPath, + @Advice.Argument(3) Object authority, + @Advice.Argument(4) Object method) { + + Span currentSpan = Java8BytecodeBridge.currentSpan(); + NettyUtils.handleConvertClientHeaders(scheme, defaultPath, authority, method, currentSpan); + } + } + + /** + * There are multiple implementations of {@link Http2Headers}. Only some of them support getting + * authority, path etc. For instance {@code GrpcHttp2ResponseHeaders} throws unsupported exception + * when accessing authority etc. This header is used client response. + * + * @see {@link io.grpc.netty.GrpcHttp2HeadersUtils} + */ + static final class GrpcUtils_convertHeaders_Advice { + + @Advice.OnMethodExit(suppress = Throwable.class) + public static void exit( + @Advice.Argument(0) Http2Headers http2Headers, @Advice.Return Metadata metadata) { + + NettyUtils.handleConvertHeaders(http2Headers, metadata); + } + } +} diff --git a/instrumentation/grpc-shaded-netty-1.9/src/main/java/io/opentelemetry/javaagent/instrumentation/shaded/netty/utils/NettyUtils.java b/instrumentation/grpc-shaded-netty-1.9/src/main/java/io/opentelemetry/javaagent/instrumentation/shaded/netty/utils/NettyUtils.java new file mode 100644 index 000000000..e70afabf0 --- /dev/null +++ b/instrumentation/grpc-shaded-netty-1.9/src/main/java/io/opentelemetry/javaagent/instrumentation/shaded/netty/utils/NettyUtils.java @@ -0,0 +1,70 @@ +/* + * Copyright The Hypertrace Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.opentelemetry.javaagent.instrumentation.shaded.netty.utils; + +import io.grpc.Metadata; +import io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2Headers; +import io.opentelemetry.api.trace.Span; +import io.opentelemetry.javaagent.instrumentation.hypertrace.grpc.GrpcSemanticAttributes; +import org.hypertrace.agent.core.instrumentation.HypertraceSemanticAttributes; + +public class NettyUtils { + + public static void handleConvertHeaders(Http2Headers http2Headers, Metadata metadata) { + if (http2Headers.authority() != null) { + metadata.put( + GrpcSemanticAttributes.AUTHORITY_METADATA_KEY, http2Headers.authority().toString()); + } + if (http2Headers.path() != null) { + metadata.put(GrpcSemanticAttributes.PATH_METADATA_KEY, http2Headers.path().toString()); + } + if (http2Headers.method() != null) { + metadata.put(GrpcSemanticAttributes.METHOD_METADATA_KEY, http2Headers.method().toString()); + } + if (http2Headers.scheme() != null) { + metadata.put(GrpcSemanticAttributes.SCHEME_METADATA_KEY, http2Headers.scheme().toString()); + } + } + + public static void handleConvertClientHeaders( + Object scheme, Object defaultPath, Object authority, Object method, Span currentSpan) { + if (scheme != null) { + currentSpan.setAttribute( + HypertraceSemanticAttributes.rpcRequestMetadata( + GrpcSemanticAttributes.addColon(GrpcSemanticAttributes.SCHEME)), + scheme.toString()); + } + if (defaultPath != null) { + currentSpan.setAttribute( + HypertraceSemanticAttributes.rpcRequestMetadata( + GrpcSemanticAttributes.addColon(GrpcSemanticAttributes.PATH)), + defaultPath.toString()); + } + if (authority != null) { + currentSpan.setAttribute( + HypertraceSemanticAttributes.rpcRequestMetadata( + GrpcSemanticAttributes.addColon(GrpcSemanticAttributes.AUTHORITY)), + authority.toString()); + } + if (method != null) { + currentSpan.setAttribute( + HypertraceSemanticAttributes.rpcRequestMetadata( + GrpcSemanticAttributes.addColon(GrpcSemanticAttributes.METHOD)), + method.toString()); + } + } +} diff --git a/settings.gradle.kts b/settings.gradle.kts index 02955dcea..b26f5eb9f 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -26,6 +26,12 @@ include("javaagent-core") include("testing-common") include("instrumentation:grpc-1.6") findProject(":instrumentation:grpc-1.6")?.name = "grpc-1.6" +include("instrumentation:grpc-common") +findProject(":instrumentation:grpc-common")?.name = "grpc-common" +include("instrumentation:grpc-shaded-netty-1.9") +findProject(":instrumentation:grpc-shaded-netty-1.9")?.name = "grpc-shaded-netty-1.9" +include("shaded-protobuf-java-util") +findProject(":shaded-protobuf-java-util")?.name = "shaded-protobuf-java-util" include("instrumentation:okhttp:okhttp-3.0") findProject(":instrumentation:okhttp:okhttp-3.0")?.name = "okhttp-3.0" include("otel-extensions") diff --git a/shaded-protobuf-java-util/build.gradle.kts b/shaded-protobuf-java-util/build.gradle.kts new file mode 100644 index 000000000..312b8b8ba --- /dev/null +++ b/shaded-protobuf-java-util/build.gradle.kts @@ -0,0 +1,16 @@ +plugins { + `java-library` + id("com.github.johnrengelman.shadow") version "6.0.0" +} + +dependencies { + implementation("com.google.protobuf:protobuf-java-util:3.4.0") { + exclude("com.google.protobuf", "protobuf-java") + exclude("com.google.guava", "guava") + } +} + +tasks.shadowJar { + relocate("com.google.protobuf.util", "io.opentelemetry.javaagent.instrumentation.hypertrace.com.google.protobuf.util") + relocate("com.google.gson", "io.opentelemetry.javaagent.instrumentation.hypertrace.com.google.gson") +}