Skip to content

Commit

Permalink
Rename grizzly-client instrumentation (open-telemetry#1709)
Browse files Browse the repository at this point in the history
* Rename grizzly-client instrumentation
  • Loading branch information
trask authored Nov 21, 2020
1 parent e9821e9 commit 081e142
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 73 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ Because the automatic instrumentation runs in a different classpath than the ins
| [Apache HttpAsyncClient](https://hc.apache.org/index.html) | 4.0+ |
| [Apache HttpClient](https://hc.apache.org/index.html) | 2.0+ |
| [Armeria](https://armeria.dev) | 0.99.8+ |
| [AsyncHttpClient](https://github.com/AsyncHttpClient/async-http-client) | 1.9+ (not including 2.x yet) |
| [AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/java-handler.html) | 1.0+ |
| [AWS SDK](https://aws.amazon.com/sdk-for-java/) | 1.11.x and 2.2.0+ |
| [Cassandra Driver](https://github.com/datastax/java-driver) | 3.0+ |
Expand All @@ -228,11 +229,10 @@ Because the automatic instrumentation runs in a different classpath than the ins
| [Geode Client](https://geode.apache.org/) | 1.4+ |
| [Google HTTP Client](https://github.com/googleapis/google-http-java-client) | 1.19+ |
| [Grizzly](https://javaee.github.io/grizzly/httpserverframework.html) | 2.0+ (disabled by default, see below) |
| [Grizzly Client](https://github.com/javaee/grizzly-ahc) | 1.9+ |
| [gRPC](https://github.com/grpc/grpc-java) | 1.5+ |
| [Hibernate](https://github.com/hibernate/hibernate-orm) | 3.3+ |
| [HttpURLConnection](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/net/HttpURLConnection.html) | Java 7+ |
| [http4k <sup>&dagger;</sup>](https://www.http4k.org/guide/modules/opentelemetry/) | 3.270.0+ |
| [http4k <sup>&dagger;</sup>](https://www.http4k.org/guide/modules/opentelemetry/) | 3.270.0+ |
| [Hystrix](https://github.com/Netflix/Hystrix) | 1.4+ |
| [JAX-RS](https://javaee.github.io/javaee-spec/javadocs/javax/ws/rs/package-summary.html) | 0.5+ |
| [JAX-RS Client](https://javaee.github.io/javaee-spec/javadocs/javax/ws/rs/client/package-summary.html) | 2.0+ |
Expand All @@ -256,7 +256,7 @@ Because the automatic instrumentation runs in a different classpath than the ins
| [RabbitMQ Client](https://github.com/rabbitmq/rabbitmq-java-client) | 2.7+ |
| [Ratpack](https://github.com/ratpack/ratpack) | 1.4+ |
| [Reactor](https://github.com/reactor/reactor-core) | 3.1+ |
| [Reactor Netty](https://github.com/reactor/reactor-netty) | 0.9+ (not including 1.0) |
| [Reactor Netty](https://github.com/reactor/reactor-netty) | 0.9+ (not including 1.0) |
| [Rediscala](https://github.com/etaty/rediscala) | 1.8+ |
| [Redisson](https://github.com/redisson/redisson) | 3.0+ |
| [RMI](https://docs.oracle.com/en/java/javase/11/docs/api/java.rmi/java/rmi/package-summary.html) | Java 7+ |
Expand Down
14 changes: 14 additions & 0 deletions instrumentation/async-http-client-1.9/async-http-client-1.9.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apply from: "$rootDir/gradle/instrumentation.gradle"

muzzle {
pass {
group = "com.ning"
module = "async-http-client"
versions = "[1.9.0,)"
assertInverse = true
}
}

dependencies {
library group: 'com.ning', name: 'async-http-client', version: '1.9.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.grizzly.client;
package io.opentelemetry.javaagent.instrumentation.asynchttpclient;

import com.ning.http.client.Request;
import io.opentelemetry.context.propagation.TextMapPropagator;

public class GrizzlyInjectAdapter implements TextMapPropagator.Setter<Request> {
public class AsyncHttpClientInjectAdapter implements TextMapPropagator.Setter<Request> {

public static final GrizzlyInjectAdapter SETTER = new GrizzlyInjectAdapter();
public static final AsyncHttpClientInjectAdapter SETTER = new AsyncHttpClientInjectAdapter();

@Override
public void set(Request carrier, String key, String value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,38 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.grizzly.client;
package io.opentelemetry.javaagent.instrumentation.asynchttpclient;

import static java.util.Arrays.asList;
import static java.util.Collections.singletonMap;

import com.google.auto.service.AutoService;
import io.opentelemetry.javaagent.instrumentation.api.Pair;
import io.opentelemetry.javaagent.tooling.InstrumentationModule;
import io.opentelemetry.javaagent.tooling.TypeInstrumentation;
import java.util.List;
import java.util.Map;

@AutoService(InstrumentationModule.class)
public class GrizzlyClientInstrumentationModule extends InstrumentationModule {
public GrizzlyClientInstrumentationModule() {
super("grizzly-client", "grizzly-client-1.9", "ning");
@AutoService(io.opentelemetry.javaagent.tooling.InstrumentationModule.class)
public class AsyncHttpClientInstrumentationModule
extends io.opentelemetry.javaagent.tooling.InstrumentationModule {
public AsyncHttpClientInstrumentationModule() {
super("async-http-client", "async-http-client-1.9");
}

@Override
public String[] helperClassNames() {
return new String[] {
packageName + ".GrizzlyClientTracer", packageName + ".GrizzlyInjectAdapter"
packageName + ".AsyncHttpClientTracer", packageName + ".AsyncHttpClientInjectAdapter"
};
}

@Override
public List<TypeInstrumentation> typeInstrumentations() {
return asList(
new GrizzlyClientRequestInstrumentation(), new GrizzlyClientResponseInstrumentation());
return asList(new RequestInstrumentation(), new ResponseInstrumentation());
}

@Override
public Map<String, String> contextStore() {
return singletonMap("com.ning.http.client.AsyncHandler", Pair.class.getName());
}

@Override
protected boolean defaultEnabled() {
return false;
}
}
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.grizzly.client;
package io.opentelemetry.javaagent.instrumentation.asynchttpclient;

import com.ning.http.client.Request;
import com.ning.http.client.Response;
Expand All @@ -12,11 +12,11 @@
import java.net.URI;
import java.net.URISyntaxException;

public class GrizzlyClientTracer extends HttpClientTracer<Request, Request, Response> {
public class AsyncHttpClientTracer extends HttpClientTracer<Request, Request, Response> {

private static final GrizzlyClientTracer TRACER = new GrizzlyClientTracer();
private static final AsyncHttpClientTracer TRACER = new AsyncHttpClientTracer();

public static GrizzlyClientTracer tracer() {
public static AsyncHttpClientTracer tracer() {
return TRACER;
}

Expand Down Expand Up @@ -47,11 +47,11 @@ protected String responseHeader(Response response, String name) {

@Override
protected Setter<Request> getSetter() {
return GrizzlyInjectAdapter.SETTER;
return AsyncHttpClientInjectAdapter.SETTER;
}

@Override
protected String getInstrumentationName() {
return "io.opentelemetry.javaagent.grizzly-client";
return "io.opentelemetry.javaagent.async-http-client";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.grizzly.client;

import static io.opentelemetry.javaagent.instrumentation.grizzly.client.GrizzlyClientTracer.tracer;
package io.opentelemetry.javaagent.instrumentation.asynchttpclient;

import com.ning.http.client.AsyncHandler;
import com.ning.http.client.Request;
Expand All @@ -17,17 +15,17 @@
import io.opentelemetry.javaagent.instrumentation.api.Pair;
import net.bytebuddy.asm.Advice;

public class GrizzlyClientRequestAdvice {
public class RequestAdvice {

@Advice.OnMethodEnter(suppress = Throwable.class)
public static Scope onEnter(
@Advice.Argument(0) Request request, @Advice.Argument(1) AsyncHandler<?> handler) {
Context parentContext = Java8BytecodeBridge.currentContext();

Span span = tracer().startSpan(request);
Span span = AsyncHttpClientTracer.tracer().startSpan(request);
InstrumentationContext.get(AsyncHandler.class, Pair.class)
.put(handler, Pair.of(parentContext, span));
return tracer().startScope(span, request);
return AsyncHttpClientTracer.tracer().startScope(span, request);
}

@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
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.grizzly.client;
package io.opentelemetry.javaagent.instrumentation.asynchttpclient;

import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
Expand All @@ -16,7 +16,7 @@
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;

final class GrizzlyClientRequestInstrumentation implements TypeInstrumentation {
final class RequestInstrumentation implements TypeInstrumentation {

@Override
public ElementMatcher<? super TypeDescription> typeMatcher() {
Expand All @@ -30,6 +30,6 @@ public Map<? extends ElementMatcher<? super MethodDescription>, String> transfor
.and(takesArgument(0, named("com.ning.http.client.Request")))
.and(takesArgument(1, named("com.ning.http.client.AsyncHandler")))
.and(isPublic()),
GrizzlyClientRequestAdvice.class.getName());
RequestAdvice.class.getName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.grizzly.client;

import static io.opentelemetry.javaagent.instrumentation.grizzly.client.GrizzlyClientTracer.tracer;
package io.opentelemetry.javaagent.instrumentation.asynchttpclient;

import com.ning.http.client.AsyncCompletionHandler;
import com.ning.http.client.AsyncHandler;
Expand All @@ -18,7 +16,7 @@
import io.opentelemetry.javaagent.instrumentation.api.Pair;
import net.bytebuddy.asm.Advice;

public class GrizzlyClientResponseAdvice {
public class ResponseAdvice {

@Advice.OnMethodEnter(suppress = Throwable.class)
public static Scope onEnter(
Expand All @@ -33,7 +31,7 @@ public static Scope onEnter(
contextStore.put(handler, null);
}
if (spanWithParent.hasRight()) {
tracer().end(spanWithParent.getRight(), response);
AsyncHttpClientTracer.tracer().end(spanWithParent.getRight(), response);
}
return spanWithParent.hasLeft() ? spanWithParent.getLeft().makeCurrent() : null;
}
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.grizzly.client;
package io.opentelemetry.javaagent.instrumentation.asynchttpclient;

import static io.opentelemetry.javaagent.tooling.ClassLoaderMatcher.hasClassesNamed;
import static java.util.Collections.singletonMap;
Expand All @@ -18,7 +18,7 @@
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;

final class GrizzlyClientResponseInstrumentation implements TypeInstrumentation {
final class ResponseInstrumentation implements TypeInstrumentation {

@Override
public ElementMatcher<ClassLoader> classLoaderMatcher() {
Expand All @@ -36,6 +36,6 @@ public Map<? extends ElementMatcher<? super MethodDescription>, String> transfor
named("onCompleted")
.and(takesArgument(0, named("com.ning.http.client.Response")))
.and(isPublic()),
GrizzlyClientResponseAdvice.class.getName());
ResponseAdvice.class.getName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ import io.opentelemetry.instrumentation.test.base.HttpClientTest
import spock.lang.AutoCleanup
import spock.lang.Shared

class GrizzlyAsyncHttpClientTest extends HttpClientTest {

static {
System.setProperty("otel.instrumentation.grizzly-client.enabled", "true")
}
class AsyncHttpClientTest extends HttpClientTest {

@AutoCleanup
@Shared
Expand Down
24 changes: 0 additions & 24 deletions instrumentation/grizzly-client-1.9/grizzly-client-1.9.gradle

This file was deleted.

2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ include ':instrumentation:apache-httpclient:apache-httpclient-4.0'
include ':instrumentation:armeria-1.0:javaagent'
include ':instrumentation:armeria-1.0:library'
include ':instrumentation:armeria-1.0:testing'
include ':instrumentation:async-http-client-1.9'
include ':instrumentation:aws-lambda-1.0:javaagent'
include ':instrumentation:aws-lambda-1.0:library'
include ':instrumentation:aws-lambda-1.0:testing'
Expand Down Expand Up @@ -89,7 +90,6 @@ include ':instrumentation:finatra-2.9'
include ':instrumentation:geode-1.4'
include ':instrumentation:google-http-client-1.19'
include ':instrumentation:grizzly-2.0'
include ':instrumentation:grizzly-client-1.9'
include ':instrumentation:grpc-1.5:javaagent'
include ':instrumentation:grpc-1.5:library'
include ':instrumentation:grpc-1.5:testing'
Expand Down

0 comments on commit 081e142

Please sign in to comment.