Misc minor cleanups (#178)
* Use singleton map for consistency * Use singletonMap static import for consistency * Remove unnecessary attribute
This commit is contained in:
parent
ab8fb882f8
commit
a652e39177
|
@ -96,7 +96,7 @@ public final class AkkaHttpClientInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
||||
public static void methodExit(
|
||||
@Advice.Argument(value = 0) final HttpRequest request,
|
||||
@Advice.Argument(0) final HttpRequest request,
|
||||
@Advice.This final HttpExt thiz,
|
||||
@Advice.Return final Future<HttpResponse> responseFuture,
|
||||
@Advice.Enter final SpanWithScope spanWithScope,
|
||||
|
|
|
@ -89,7 +89,7 @@ public final class AkkaHttpServerInstrumentation extends Instrumenter.Default {
|
|||
public static void wrapHandler(
|
||||
@Advice.Argument(value = 0, readOnly = false)
|
||||
Function1<HttpRequest, Future<HttpResponse>> handler,
|
||||
@Advice.Argument(value = 7) final Materializer materializer) {
|
||||
@Advice.Argument(7) final Materializer materializer) {
|
||||
handler = new AsyncWrapper(handler, materializer.executionContext());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public class ApacheHttpClientRedirectInstrumentation extends Instrumenter.Defaul
|
|||
public static class ClientRedirectAdvice {
|
||||
@Advice.OnMethodExit(suppress = Throwable.class)
|
||||
private static void onAfterExecute(
|
||||
@Advice.Argument(value = 0) final HttpRequest original,
|
||||
@Advice.Argument(0) final HttpRequest original,
|
||||
@Advice.Return(typing = Assigner.Typing.DYNAMIC) final HttpRequest redirect) {
|
||||
if (redirect == null) {
|
||||
return;
|
||||
|
|
|
@ -2,6 +2,7 @@ package io.opentelemetry.auto.instrumentation.aws.v2;
|
|||
|
||||
import static io.opentelemetry.auto.instrumentation.aws.v2.TracingExecutionInterceptor.ScopeHolder.CURRENT;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasSuperType;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
|
||||
|
@ -11,7 +12,6 @@ import static net.bytebuddy.matcher.ElementMatchers.not;
|
|||
import com.google.auto.service.AutoService;
|
||||
import io.opentelemetry.auto.tooling.Instrumenter;
|
||||
import io.opentelemetry.context.Scope;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import net.bytebuddy.asm.Advice;
|
||||
import net.bytebuddy.description.method.MethodDescription;
|
||||
|
@ -38,7 +38,7 @@ public final class AwsHttpClientInstrumentation extends AbstractAwsClientInstrum
|
|||
|
||||
@Override
|
||||
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
|
||||
return Collections.singletonMap(
|
||||
return singletonMap(
|
||||
isMethod().and(isPublic()).and(named("execute")),
|
||||
AwsHttpClientInstrumentation.class.getName() + "$AwsHttpClientAdvice");
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ import io.opentelemetry.auto.bootstrap.InstrumentationContext;
|
|||
import io.opentelemetry.auto.tooling.Instrumenter;
|
||||
import io.opentelemetry.trace.Span;
|
||||
import io.opentelemetry.trace.Tracer;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import net.bytebuddy.asm.Advice;
|
||||
import net.bytebuddy.description.method.MethodDescription;
|
||||
|
@ -35,8 +34,7 @@ public class CouchbaseCoreInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public Map<String, String> contextStore() {
|
||||
return Collections.singletonMap(
|
||||
"com.couchbase.client.core.message.CouchbaseRequest", Span.class.getName());
|
||||
return singletonMap("com.couchbase.client.core.message.CouchbaseRequest", Span.class.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,6 @@ import io.opentelemetry.auto.bootstrap.InstrumentationContext;
|
|||
import io.opentelemetry.auto.instrumentation.api.Tags;
|
||||
import io.opentelemetry.auto.tooling.Instrumenter;
|
||||
import io.opentelemetry.trace.Span;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import net.bytebuddy.asm.Advice;
|
||||
import net.bytebuddy.description.method.MethodDescription;
|
||||
|
@ -36,8 +35,7 @@ public class CouchbaseNetworkInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public Map<String, String> contextStore() {
|
||||
return Collections.singletonMap(
|
||||
"com.couchbase.client.core.message.CouchbaseRequest", Span.class.getName());
|
||||
return singletonMap("com.couchbase.client.core.message.CouchbaseRequest", Span.class.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -4,6 +4,7 @@ import static io.opentelemetry.auto.instrumentation.googlehttpclient.GoogleHttpC
|
|||
import static io.opentelemetry.auto.instrumentation.googlehttpclient.GoogleHttpClientDecorator.TRACER;
|
||||
import static io.opentelemetry.auto.instrumentation.googlehttpclient.HeadersInjectAdapter.SETTER;
|
||||
import static io.opentelemetry.trace.Span.Kind.CLIENT;
|
||||
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;
|
||||
|
@ -20,7 +21,6 @@ import io.opentelemetry.auto.tooling.Instrumenter;
|
|||
import io.opentelemetry.context.Scope;
|
||||
import io.opentelemetry.trace.Span;
|
||||
import io.opentelemetry.trace.Status;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import net.bytebuddy.asm.Advice;
|
||||
|
@ -42,8 +42,7 @@ public class GoogleHttpClientInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public Map<String, String> contextStore() {
|
||||
return Collections.singletonMap(
|
||||
"com.google.api.client.http.HttpRequest", RequestState.class.getName());
|
||||
return singletonMap("com.google.api.client.http.HttpRequest", RequestState.class.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package io.opentelemetry.auto.instrumentation.hibernate.core.v4_3;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasSuperType;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
@ -57,13 +58,9 @@ public class SessionInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
|
||||
final Map<ElementMatcher<? super MethodDescription>, String> transformers = new HashMap<>();
|
||||
|
||||
transformers.put(
|
||||
return singletonMap(
|
||||
isMethod().and(returns(safeHasSuperType(named("org.hibernate.procedure.ProcedureCall")))),
|
||||
SessionInstrumentation.class.getName() + "$GetProcedureCallAdvice");
|
||||
|
||||
return transformers;
|
||||
}
|
||||
|
||||
public static class GetProcedureCallAdvice {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package io.opentelemetry.auto.instrumentation.java.concurrent;
|
||||
|
||||
import static io.opentelemetry.auto.instrumentation.java.concurrent.AdviceUtils.TRACER;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.nameMatches;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
|
||||
|
@ -12,7 +13,6 @@ import io.opentelemetry.auto.bootstrap.InstrumentationContext;
|
|||
import io.opentelemetry.auto.bootstrap.instrumentation.java.concurrent.State;
|
||||
import io.opentelemetry.auto.tooling.Instrumenter;
|
||||
import io.opentelemetry.trace.Span;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executor;
|
||||
|
@ -38,8 +38,7 @@ public final class AkkaExecutorInstrumentation extends AbstractExecutorInstrumen
|
|||
|
||||
@Override
|
||||
public Map<String, String> contextStore() {
|
||||
return Collections.singletonMap(
|
||||
AkkaForkJoinTaskInstrumentation.TASK_CLASS_NAME, State.class.getName());
|
||||
return singletonMap(AkkaForkJoinTaskInstrumentation.TASK_CLASS_NAME, State.class.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package io.opentelemetry.auto.instrumentation.java.concurrent;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasSuperType;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isAbstract;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
@ -62,11 +63,9 @@ public final class JavaForkJoinTaskInstrumentation extends Instrumenter.Default
|
|||
|
||||
@Override
|
||||
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
|
||||
final Map<ElementMatcher<? super MethodDescription>, String> transformers = new HashMap<>();
|
||||
transformers.put(
|
||||
return singletonMap(
|
||||
named("exec").and(takesArguments(0)).and(not(isAbstract())),
|
||||
JavaForkJoinTaskInstrumentation.class.getName() + "$ForkJoinTaskAdvice");
|
||||
return transformers;
|
||||
}
|
||||
|
||||
public static class ForkJoinTaskAdvice {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package io.opentelemetry.auto.instrumentation.java.concurrent;
|
||||
|
||||
import static io.opentelemetry.auto.instrumentation.java.concurrent.AdviceUtils.TRACER;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.nameMatches;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
|
||||
|
@ -11,7 +12,6 @@ import io.opentelemetry.auto.bootstrap.InstrumentationContext;
|
|||
import io.opentelemetry.auto.bootstrap.instrumentation.java.concurrent.State;
|
||||
import io.opentelemetry.auto.tooling.Instrumenter;
|
||||
import io.opentelemetry.trace.Span;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executor;
|
||||
|
@ -38,8 +38,7 @@ public final class ScalaExecutorInstrumentation extends AbstractExecutorInstrume
|
|||
|
||||
@Override
|
||||
public Map<String, String> contextStore() {
|
||||
return Collections.singletonMap(
|
||||
ScalaForkJoinTaskInstrumentation.TASK_CLASS_NAME, State.class.getName());
|
||||
return singletonMap(ScalaForkJoinTaskInstrumentation.TASK_CLASS_NAME, State.class.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package io.opentelemetry.auto.instrumentation.java.concurrent;
|
||||
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasSuperType;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isAbstract;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
@ -64,11 +65,9 @@ public final class ScalaForkJoinTaskInstrumentation extends Instrumenter.Default
|
|||
|
||||
@Override
|
||||
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
|
||||
final Map<ElementMatcher<? super MethodDescription>, String> transformers = new HashMap<>();
|
||||
transformers.put(
|
||||
return singletonMap(
|
||||
named("exec").and(takesArguments(0)).and(not(isAbstract())),
|
||||
ScalaForkJoinTaskInstrumentation.class.getName() + "$ForkJoinTaskAdvice");
|
||||
return transformers;
|
||||
}
|
||||
|
||||
public static class ForkJoinTaskAdvice {
|
||||
|
|
|
@ -2,6 +2,7 @@ package io.opentelemetry.auto.instrumentation.jaxrs2;
|
|||
|
||||
import static io.opentelemetry.auto.instrumentation.jaxrs2.JaxRsAnnotationsDecorator.DECORATE;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasSuperType;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
|
||||
|
@ -11,7 +12,6 @@ import io.opentelemetry.auto.bootstrap.ContextStore;
|
|||
import io.opentelemetry.auto.bootstrap.InstrumentationContext;
|
||||
import io.opentelemetry.auto.tooling.Instrumenter;
|
||||
import io.opentelemetry.trace.Span;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.ws.rs.container.AsyncResponse;
|
||||
|
@ -29,7 +29,7 @@ public final class JaxRsAsyncResponseInstrumentation extends Instrumenter.Defaul
|
|||
|
||||
@Override
|
||||
public Map<String, String> contextStore() {
|
||||
return Collections.singletonMap("javax.ws.rs.container.AsyncResponse", Span.class.getName());
|
||||
return singletonMap("javax.ws.rs.container.AsyncResponse", Span.class.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -62,8 +62,7 @@ public final class JaxRsClientV1Instrumentation extends Instrumenter.Default {
|
|||
|
||||
@Advice.OnMethodEnter
|
||||
public static SpanWithScope onEnter(
|
||||
@Advice.Argument(value = 0) final ClientRequest request,
|
||||
@Advice.This final ClientHandler thisObj) {
|
||||
@Advice.Argument(0) final ClientRequest request, @Advice.This final ClientHandler thisObj) {
|
||||
|
||||
// WARNING: this might be a chain...so we only have to trace the first in the chain.
|
||||
final boolean isRootClientHandler = null == request.getProperties().get(SPAN_ATTRIBUTE);
|
||||
|
|
|
@ -84,8 +84,7 @@ public class RmiClientContextInstrumentation extends Instrumenter.Default {
|
|||
public static class StreamRemoteCallConstructorAdvice {
|
||||
@Advice.OnMethodEnter(suppress = Throwable.class)
|
||||
public static void onEnter(
|
||||
@Advice.Argument(value = 0) final Connection c,
|
||||
@Advice.Argument(value = 1) final ObjID id) {
|
||||
@Advice.Argument(0) final Connection c, @Advice.Argument(1) final ObjID id) {
|
||||
if (!c.isReusable()) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ package io.opentelemetry.auto.instrumentation.springdata;
|
|||
|
||||
import static io.opentelemetry.auto.instrumentation.springdata.SpringDataDecorator.DECORATOR;
|
||||
import static io.opentelemetry.auto.instrumentation.springdata.SpringDataDecorator.TRACER;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isConstructor;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
@ -14,7 +15,6 @@ import io.opentelemetry.auto.tooling.Instrumenter;
|
|||
import io.opentelemetry.context.Scope;
|
||||
import io.opentelemetry.trace.Span;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import net.bytebuddy.asm.Advice;
|
||||
import net.bytebuddy.description.method.MethodDescription;
|
||||
|
@ -54,7 +54,7 @@ public final class SpringRepositoryInstrumentation extends Instrumenter.Default
|
|||
|
||||
@Override
|
||||
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
|
||||
return Collections.singletonMap(
|
||||
return singletonMap(
|
||||
isConstructor(),
|
||||
SpringRepositoryInstrumentation.class.getName() + "$RepositoryFactorySupportAdvice");
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package io.opentelemetry.auto.instrumentation.trace_annotation;
|
|||
|
||||
import static io.opentelemetry.auto.instrumentation.trace_annotation.TraceConfigInstrumentation.PACKAGE_CLASS_NAME_REGEX;
|
||||
import static io.opentelemetry.auto.tooling.ByteBuddyElementMatchers.safeHasSuperType;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.declaresMethod;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
@ -97,7 +98,6 @@ public final class TraceAnnotationsInstrumentation extends Instrumenter.Default
|
|||
|
||||
@Override
|
||||
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
|
||||
return Collections.singletonMap(
|
||||
isAnnotatedWith(methodTraceMatcher), packageName + ".TraceAdvice");
|
||||
return singletonMap(isAnnotatedWith(methodTraceMatcher), packageName + ".TraceAdvice");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue