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

Generate InstrumentationModule#contextStore() with muzzle #2775

Merged
Merged
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 @@ -8,14 +8,9 @@
import static java.util.Arrays.asList;

import com.google.auto.service.AutoService;
import io.opentelemetry.javaagent.instrumentation.api.concurrent.State;
import io.opentelemetry.javaagent.tooling.InstrumentationModule;
import io.opentelemetry.javaagent.tooling.TypeInstrumentation;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;

@AutoService(InstrumentationModule.class)
public class AkkaActorInstrumentationModule extends InstrumentationModule {
Expand All @@ -32,16 +27,6 @@ public List<TypeInstrumentation> typeInstrumentations() {
new AkkaActorCellInstrumentation());
}

@Override
public Map<String, String> contextStore() {
Map<String, String> map = new HashMap<>();
map.put(Runnable.class.getName(), State.class.getName());
map.put(Callable.class.getName(), State.class.getName());
map.put(AkkaForkJoinTaskInstrumentation.TASK_CLASS_NAME, State.class.getName());
map.put("akka.dispatch.Envelope", State.class.getName());
return Collections.unmodifiableMap(map);
}

@Override
protected boolean defaultEnabled() {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@
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.TypeInstrumentation;
import java.util.List;
import java.util.Map;

@AutoService(io.opentelemetry.javaagent.tooling.InstrumentationModule.class)
public class AsyncHttpClientInstrumentationModule
Expand All @@ -25,9 +22,4 @@ public AsyncHttpClientInstrumentationModule() {
public List<TypeInstrumentation> typeInstrumentations() {
return asList(new RequestInstrumentation(), new ResponseInstrumentation());
}

@Override
public Map<String, String> contextStore() {
return singletonMap("com.ning.http.client.AsyncHandler", Pair.class.getName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@
import static java.util.Arrays.asList;

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

@AutoService(io.opentelemetry.javaagent.tooling.InstrumentationModule.class)
public class AsyncHttpClientInstrumentationModule
Expand All @@ -28,12 +25,4 @@ public List<TypeInstrumentation> typeInstrumentations() {
new ResponseInstrumentation(),
new RequestSenderInstrumentation());
}

@Override
public Map<String, String> contextStore() {
Map<String, String> stores = new java.util.HashMap<>();
stores.put("org.asynchttpclient.AsyncHandler", Pair.class.getName());
stores.put("org.asynchttpclient.Request", Context.class.getName());
return stores;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@
package io.opentelemetry.javaagent.instrumentation.couchbase.v2_6;

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

import com.google.auto.service.AutoService;
import io.opentelemetry.api.trace.Span;
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 CouchbaseInstrumentationModule extends InstrumentationModule {
Expand All @@ -25,9 +22,4 @@ public CouchbaseInstrumentationModule() {
public List<TypeInstrumentation> typeInstrumentations() {
return asList(new CouchbaseCoreInstrumentation(), new CouchbaseNetworkInstrumentation());
}

@Override
public Map<String, String> contextStore() {
return singletonMap("com.couchbase.client.core.message.CouchbaseRequest", Span.class.getName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,9 @@
import static java.util.Arrays.asList;

import com.google.auto.service.AutoService;
import io.opentelemetry.javaagent.instrumentation.api.concurrent.State;
import io.opentelemetry.javaagent.tooling.InstrumentationModule;
import io.opentelemetry.javaagent.tooling.TypeInstrumentation;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ForkJoinTask;
import java.util.concurrent.Future;

@AutoService(InstrumentationModule.class)
public class ExecutorInstrumentationModule extends InstrumentationModule {
Expand All @@ -34,14 +27,4 @@ public List<TypeInstrumentation> typeInstrumentations() {
new JavaForkJoinTaskInstrumentation(),
new RunnableInstrumentation());
}

@Override
public Map<String, String> contextStore() {
Map<String, String> map = new HashMap<>();
map.put(Callable.class.getName(), State.class.getName());
map.put(ForkJoinTask.class.getName(), State.class.getName());
map.put(Future.class.getName(), State.class.getName());
map.put(Runnable.class.getName(), State.class.getName());
return Collections.unmodifiableMap(map);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import static io.opentelemetry.javaagent.instrumentation.api.Java8BytecodeBridge.currentContext;
import static io.opentelemetry.javaagent.instrumentation.googlehttpclient.GoogleHttpClientTracer.tracer;
import static java.util.Collections.singletonList;
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 Down Expand Up @@ -38,11 +37,6 @@ public GoogleHttpClientInstrumentationModule() {
super("google-http-client", "google-http-client-1.19");
}

@Override
public Map<String, String> contextStore() {
return singletonMap("com.google.api.client.http.HttpRequest", Context.class.getName());
}

@Override
public List<TypeInstrumentation> typeInstrumentations() {
return singletonList(new HttpRequestInstrumentation());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ public List<TypeInstrumentation> typeInstrumentations() {
return singletonList(new ListenableFutureInstrumentation());
}

@Override
public Map<String, String> contextStore() {
return singletonMap(Runnable.class.getName(), State.class.getName());
}

public static class ListenableFutureInstrumentation implements TypeInstrumentation {
@Override
public ElementMatcher<TypeDescription> typeMatcher() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@
import static java.util.Arrays.asList;

import com.google.auto.service.AutoService;
import io.opentelemetry.context.Context;
import io.opentelemetry.javaagent.tooling.InstrumentationModule;
import io.opentelemetry.javaagent.tooling.TypeInstrumentation;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.bytebuddy.matcher.ElementMatcher;

@AutoService(InstrumentationModule.class)
Expand Down Expand Up @@ -43,15 +39,4 @@ public List<TypeInstrumentation> typeInstrumentations() {
new SessionInstrumentation(),
new TransactionInstrumentation());
}

@Override
public Map<String, String> contextStore() {
Map<String, String> map = new HashMap<>();
map.put("org.hibernate.Criteria", Context.class.getName());
map.put("org.hibernate.Query", Context.class.getName());
map.put("org.hibernate.Session", Context.class.getName());
map.put("org.hibernate.StatelessSession", Context.class.getName());
map.put("org.hibernate.Transaction", Context.class.getName());
return Collections.unmodifiableMap(map);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@
import static java.util.Arrays.asList;

import com.google.auto.service.AutoService;
import io.opentelemetry.context.Context;
import io.opentelemetry.javaagent.tooling.InstrumentationModule;
import io.opentelemetry.javaagent.tooling.TypeInstrumentation;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@AutoService(InstrumentationModule.class)
public class HibernateInstrumentationModule extends InstrumentationModule {
Expand All @@ -32,14 +28,4 @@ public List<TypeInstrumentation> typeInstrumentations() {
new SessionInstrumentation(),
new TransactionInstrumentation());
}

@Override
public Map<String, String> contextStore() {
Map<String, String> map = new HashMap<>();
map.put("org.hibernate.Criteria", Context.class.getName());
map.put("org.hibernate.Query", Context.class.getName());
map.put("org.hibernate.SharedSessionContract", Context.class.getName());
map.put("org.hibernate.Transaction", Context.class.getName());
return Collections.unmodifiableMap(map);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@
import static java.util.Arrays.asList;

import com.google.auto.service.AutoService;
import io.opentelemetry.context.Context;
import io.opentelemetry.javaagent.tooling.InstrumentationModule;
import io.opentelemetry.javaagent.tooling.TypeInstrumentation;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@AutoService(InstrumentationModule.class)
public class HibernateInstrumentationModule extends InstrumentationModule {
Expand All @@ -26,12 +22,4 @@ public HibernateInstrumentationModule() {
public List<TypeInstrumentation> typeInstrumentations() {
return asList(new ProcedureCallInstrumentation(), new SessionInstrumentation());
}

@Override
public Map<String, String> contextStore() {
Map<String, String> map = new HashMap<>();
map.put("org.hibernate.SharedSessionContract", Context.class.getName());
map.put("org.hibernate.procedure.ProcedureCall", Context.class.getName());
return Collections.unmodifiableMap(map);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import static io.opentelemetry.javaagent.tooling.bytebuddy.matcher.AgentElementMatchers.extendsClass;
import static io.opentelemetry.javaagent.tooling.bytebuddy.matcher.NameMatchers.namedOneOf;
import static java.util.Collections.singletonList;
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.nameStartsWith;
Expand Down Expand Up @@ -52,11 +51,6 @@ public List<TypeInstrumentation> typeInstrumentations() {
return singletonList(new HttpUrlConnectionInstrumentation());
}

@Override
public Map<String, String> contextStore() {
return singletonMap("java.net.HttpURLConnection", getClass().getName() + "$HttpUrlState");
}

public static class HttpUrlConnectionInstrumentation implements TypeInstrumentation {
@Override
public ElementMatcher<TypeDescription> typeMatcher() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@

import static io.opentelemetry.javaagent.tooling.bytebuddy.matcher.ClassLoaderMatcher.hasClassesNamed;
import static java.util.Arrays.asList;
import static java.util.Collections.singletonMap;

import com.google.auto.service.AutoService;
import io.opentelemetry.context.Context;
import io.opentelemetry.javaagent.tooling.InstrumentationModule;
import io.opentelemetry.javaagent.tooling.TypeInstrumentation;
import java.util.List;
import java.util.Map;
import net.bytebuddy.matcher.ElementMatcher;

@AutoService(InstrumentationModule.class)
Expand All @@ -37,9 +34,4 @@ public List<TypeInstrumentation> typeInstrumentations() {
new JaxRsAnnotationsInstrumentation(),
new JaxRsAsyncResponseInstrumentation());
}

@Override
public Map<String, String> contextStore() {
return singletonMap("javax.ws.rs.container.AsyncResponse", Context.class.getName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

package io.opentelemetry.javaagent.instrumentation.jetty.v8_0;

import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
Expand Down Expand Up @@ -45,11 +44,6 @@ public List<TypeInstrumentation> typeInstrumentations() {
new JettyQueuedThreadPoolInstrumentation());
}

@Override
public Map<String, String> contextStore() {
return singletonMap(Runnable.class.getName(), State.class.getName());
}

public static class JettyQueuedThreadPoolInstrumentation implements TypeInstrumentation {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
package io.opentelemetry.javaagent.instrumentation.jms;

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

import com.google.auto.service.AutoService;
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 JmsInstrumentationModule extends InstrumentationModule {
Expand All @@ -27,9 +25,4 @@ public List<TypeInstrumentation> typeInstrumentations() {
new JmsMessageListenerInstrumentation(),
new JmsMessageProducerInstrumentation());
}

@Override
public Map<String, String> contextStore() {
return singletonMap("javax.jms.MessageConsumer", MessageDestination.class.getName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@
package io.opentelemetry.javaagent.instrumentation.log4j.v1_2;

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

import com.google.auto.service.AutoService;
import io.opentelemetry.api.trace.Span;
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 Log4j1InstrumentationModule extends InstrumentationModule {
Expand All @@ -25,9 +22,4 @@ public Log4j1InstrumentationModule() {
public List<TypeInstrumentation> typeInstrumentations() {
return asList(new CategoryInstrumentation(), new LoggingEventInstrumentation());
}

@Override
public Map<String, String> contextStore() {
return singletonMap("org.apache.log4j.spi.LoggingEvent", Span.class.getName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@
package io.opentelemetry.javaagent.instrumentation.logback.v1_0;

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

import com.google.auto.service.AutoService;
import io.opentelemetry.api.trace.Span;
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 LogbackInstrumentationModule extends InstrumentationModule {
Expand All @@ -25,9 +22,4 @@ public LogbackInstrumentationModule() {
public List<TypeInstrumentation> typeInstrumentations() {
return asList(new LoggerInstrumentation(), new LoggingEventInstrumentation());
}

@Override
public Map<String, String> contextStore() {
return singletonMap("ch.qos.logback.classic.spi.ILoggingEvent", Span.class.getName());
}
}
Loading