Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Armeria gRPC clients #9662

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@ muzzle {
pass {
group.set("com.linecorp.armeria")
module.set("armeria")
versions.set("[1.3.0,)")
versions.set("[1.14.0,)")
assertInverse.set(true)
}
}

dependencies {
implementation(project(":instrumentation:armeria-1.3:library"))
implementation(project(":instrumentation:armeria-1.14:library"))
implementation(project(":instrumentation:grpc-1.6:javaagent"))
testInstrumentation(project(":instrumentation:netty:netty-4.1:javaagent"))

library("com.linecorp.armeria:armeria:1.3.0")
library("com.linecorp.armeria:armeria:1.14.0")

testImplementation(project(":instrumentation:armeria-1.3:testing"))
testImplementation(project(":instrumentation:armeria-1.14:testing"))
}

tasks {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.armeria.v1_3;
package io.opentelemetry.javaagent.instrumentation.armeria.v1_14;

import static net.bytebuddy.matcher.ElementMatchers.isConstructor;
import static net.bytebuddy.matcher.ElementMatchers.named;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.armeria.v1_3;
package io.opentelemetry.javaagent.instrumentation.armeria.v1_14;

import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed;
import static java.util.Arrays.asList;
Expand All @@ -17,7 +17,7 @@
@AutoService(InstrumentationModule.class)
public class ArmeriaInstrumentationModule extends InstrumentationModule {
public ArmeriaInstrumentationModule() {
super("armeria", "armeria-1.3");
super("armeria", "armeria-1.14");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.armeria.v1_14;

import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.named;

import com.linecorp.armeria.client.grpc.GrpcClientBuilder;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
import io.opentelemetry.javaagent.instrumentation.grpc.v1_6.GrpcSingletons
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;

public class ArmeriaRpcClientBuilderInstrumentation implements TypeInstrumentation {

@Override
public ElementMatcher<TypeDescription> typeMatcher() {
// we need to update class being targeted
return named("com.linecorp.armeria.client.grpc.GrpcClientBuilder");
}

@Override
public void transform(TypeTransformer transformer) {
transformer.applyAdviceToMethod(
isMethod().and(isPublic()).and(named("build")),
// reference this class' build advice
ArmeriaRpcClientBuilderInstrumentation.class.getName() + "$BuildAdvice");
}

@SuppressWarnings("unused")
public static class BuildAdvice {

@Advice.OnMethodEnter
// the the GrpcClientBuilder instead
public static void build(@Advice.This GrpcClientBuilder builder) {
builder.interceptor(GrpcSingletons.CLIENT_DECORATOR);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.armeria.v1_3;
package io.opentelemetry.javaagent.instrumentation.armeria.v1_14;

import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.armeria.v1_3;
package io.opentelemetry.javaagent.instrumentation.armeria.v1_14;

import com.linecorp.armeria.client.HttpClient;
import com.linecorp.armeria.server.HttpService;
import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientPeerServiceAttributesExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.net.PeerServiceAttributesExtractor;
import io.opentelemetry.instrumentation.armeria.v1_3.ArmeriaTelemetry;
import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaHttpClientAttributesGetter;
import io.opentelemetry.javaagent.bootstrap.internal.CommonConfig;
Expand All @@ -28,9 +28,9 @@ public final class ArmeriaSingletons {
.setCapturedClientResponseHeaders(CommonConfig.get().getClientResponseHeaders())
.setKnownMethods(CommonConfig.get().getKnownHttpRequestMethods())
.addClientAttributeExtractor(
HttpClientPeerServiceAttributesExtractor.create(
PeerServiceAttributesExtractor.create(
ArmeriaHttpClientAttributesGetter.INSTANCE,
CommonConfig.get().getPeerServiceResolver()))
CommonConfig.get().getPeerServiceMapping()))
.setEmitExperimentalHttpClientMetrics(
CommonConfig.get().shouldEmitExperimentalHttpClientMetrics())
.setEmitExperimentalHttpServerMetrics(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.armeria.v1_3;
package io.opentelemetry.javaagent.instrumentation.armeria.v1_14;

import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.armeria.v1_3;
package io.opentelemetry.javaagent.instrumentation.armeria.v1_14;

import io.opentelemetry.context.Context;
import io.opentelemetry.context.Scope;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.armeria.v1_3;
package io.opentelemetry.javaagent.instrumentation.armeria.v1_14;

import com.linecorp.armeria.common.HttpRequest;
import com.linecorp.armeria.common.HttpResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.armeria.v1_3;
package io.opentelemetry.javaagent.instrumentation.armeria.v1_14;

import io.opentelemetry.context.Context;
import io.opentelemetry.context.Scope;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.armeria.v1_3;
package io.opentelemetry.javaagent.instrumentation.armeria.v1_14;

import com.linecorp.armeria.client.WebClientBuilder;
import io.opentelemetry.instrumentation.armeria.v1_3.AbstractArmeriaHttpClientTest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.armeria.v1_3;
package io.opentelemetry.javaagent.instrumentation.armeria.v1_14;

import com.linecorp.armeria.server.ServerBuilder;
import io.opentelemetry.instrumentation.armeria.v1_3.AbstractArmeriaHttpServerTest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ plugins {
}

dependencies {
library("com.linecorp.armeria:armeria:1.3.0")
library("com.linecorp.armeria:armeria:1.14.0")

testImplementation(project(":instrumentation:armeria-1.3:testing"))
testImplementation(project(":instrumentation:armeria-1.14:testing"))
}

tasks {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.instrumentation.armeria.v1_3;
package io.opentelemetry.instrumentation.armeria.v1_14;

import com.linecorp.armeria.common.HttpRequest;
import com.linecorp.armeria.common.HttpStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.instrumentation.armeria.v1_3;
package io.opentelemetry.instrumentation.armeria.v1_14;

import com.linecorp.armeria.client.ClientRequestContext;
import com.linecorp.armeria.client.HttpClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.instrumentation.armeria.v1_3;
package io.opentelemetry.instrumentation.armeria.v1_14;

import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.linecorp.armeria.client.ClientRequestContext;
Expand Down Expand Up @@ -39,7 +39,7 @@

public final class ArmeriaTelemetryBuilder {

private static final String INSTRUMENTATION_NAME = "io.opentelemetry.armeria-1.3";
private static final String INSTRUMENTATION_NAME = "io.opentelemetry.armeria-1.14";

private final OpenTelemetry openTelemetry;
@Nullable private String peerService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.instrumentation.armeria.v1_3;
package io.opentelemetry.instrumentation.armeria.v1_14;

import com.linecorp.armeria.client.ClientRequestContext;
import io.opentelemetry.context.propagation.TextMapSetter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.instrumentation.armeria.v1_3;
package io.opentelemetry.instrumentation.armeria.v1_14;

import com.linecorp.armeria.client.ClientRequestContext;
import com.linecorp.armeria.client.HttpClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.instrumentation.armeria.v1_3;
package io.opentelemetry.instrumentation.armeria.v1_14;

import com.linecorp.armeria.common.HttpRequest;
import com.linecorp.armeria.common.HttpResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.instrumentation.armeria.v1_3;
package io.opentelemetry.instrumentation.armeria.v1_14;

import com.linecorp.armeria.server.ServiceRequestContext;
import io.netty.util.AsciiString;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.instrumentation.armeria.v1_3;
package io.opentelemetry.instrumentation.armeria.v1_14;

import com.linecorp.armeria.client.WebClientBuilder;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.instrumentation.armeria.v1_3;
package io.opentelemetry.instrumentation.armeria.v1_14;

import com.linecorp.armeria.server.ServerBuilder;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
Expand Down
10 changes: 10 additions & 0 deletions instrumentation/armeria-1.14/testing/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
plugins {
id("otel.java-conventions")
}

dependencies {
api(project(":testing-common"))

api("com.linecorp.armeria:armeria:1.14.0")
api("com.linecorp.armeria:armeria-junit4:1.14.0")
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.instrumentation.armeria.v1_3;
package io.opentelemetry.instrumentation.armeria.v1_14;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.instrumentation.armeria.v1_3;
package io.opentelemetry.instrumentation.armeria.v1_14;

import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.CAPTURE_HEADERS;
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.ERROR;
Expand Down
10 changes: 0 additions & 10 deletions instrumentation/armeria-1.3/testing/build.gradle.kts

This file was deleted.

Loading