Remove unused code (#319)
* Remove unused/deprecated code * Remove unused code * Remove unused return value * Remove unnecessary throws clauses * Remove unused code * Remove default attribute value * Remove unused code * Remove unused code * Remove unused code * Remove unused constants * Remove unused constant * Remove unused parameter * Remove unused PostMatchHook * Remove unused constants
This commit is contained in:
parent
d94bf95bcf
commit
bf5b009ef8
|
@ -82,7 +82,7 @@ public class Agent {
|
|||
*/
|
||||
if (isJavaBefore9WithJFR() && appUsingCustomLogManager) {
|
||||
log.debug("Custom logger detected. Delaying Agent Tracer initialization.");
|
||||
registerLogManagerCallback(new InstallAgentTracerCallback(bootstrapURL));
|
||||
registerLogManagerCallback(new InstallAgentTracerCallback());
|
||||
} else {
|
||||
installAgentTracer();
|
||||
}
|
||||
|
@ -102,12 +102,6 @@ public class Agent {
|
|||
|
||||
protected abstract static class ClassLoadCallBack implements Runnable {
|
||||
|
||||
final URL bootstrapURL;
|
||||
|
||||
ClassLoadCallBack(final URL bootstrapURL) {
|
||||
this.bootstrapURL = bootstrapURL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
/*
|
||||
|
@ -138,9 +132,6 @@ public class Agent {
|
|||
}
|
||||
|
||||
protected static class InstallAgentTracerCallback extends ClassLoadCallBack {
|
||||
InstallAgentTracerCallback(final URL bootstrapURL) {
|
||||
super(bootstrapURL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
|
|
@ -85,14 +85,6 @@ public class AgentClassLoader extends URLClassLoader {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param className binary name of class
|
||||
* @return true if this loader has attempted to load the given class
|
||||
*/
|
||||
public boolean hasLoadedClass(final String className) {
|
||||
return findLoadedClass(className) != null;
|
||||
}
|
||||
|
||||
public BootstrapClassLoaderProxy getBootstrapProxy() {
|
||||
return bootstrapProxy;
|
||||
}
|
||||
|
|
|
@ -87,12 +87,12 @@ public class InternalJarURLHandler extends URLStreamHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void connect() throws IOException {
|
||||
public void connect() {
|
||||
connected = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream() throws IOException {
|
||||
public InputStream getInputStream() {
|
||||
return inputStream;
|
||||
}
|
||||
|
||||
|
|
|
@ -76,12 +76,10 @@ public class ExecutorInstrumentationUtils {
|
|||
/**
|
||||
* Clean up after job submission method has exited.
|
||||
*
|
||||
* @param executor the current executor
|
||||
* @param state task instrumentation state
|
||||
* @param throwable throwable that may have been thrown
|
||||
*/
|
||||
public static void cleanUpOnMethodExit(
|
||||
final Executor executor, final State state, final Throwable throwable) {
|
||||
public static void cleanUpOnMethodExit(final State state, final Throwable throwable) {
|
||||
if (null != state && null != throwable) {
|
||||
/*
|
||||
Note: this may potentially clear somebody else's parent span if we didn't set it
|
||||
|
|
|
@ -35,7 +35,7 @@ public class State {
|
|||
|
||||
private State() {}
|
||||
|
||||
public boolean setParentSpan(final Span parentSpan) {
|
||||
public void setParentSpan(final Span parentSpan) {
|
||||
final boolean result = parentSpanRef.compareAndSet(null, parentSpan);
|
||||
if (!result && parentSpanRef.get() != parentSpan) {
|
||||
log.debug(
|
||||
|
@ -44,7 +44,6 @@ public class State {
|
|||
parentSpan,
|
||||
parentSpanRef.get());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void clearParentSpan() {
|
||||
|
|
|
@ -90,8 +90,6 @@ public class Config {
|
|||
public static final boolean DEFAULT_LOG_INJECTION_ENABLED = false;
|
||||
public static final String DEFAULT_EXPERIMENTAL_LOG_CAPTURE_THRESHOLD = null;
|
||||
|
||||
private static final String SPLIT_BY_SPACE_OR_COMMA_REGEX = "[,\\s]+";
|
||||
|
||||
private static final String DEFAULT_TRACE_ANNOTATIONS = null;
|
||||
private static final boolean DEFAULT_TRACE_EXECUTORS_ALL = false;
|
||||
private static final String DEFAULT_TRACE_EXECUTORS = "";
|
||||
|
@ -247,19 +245,6 @@ public class Config {
|
|||
|
||||
public boolean isIntegrationEnabled(
|
||||
final SortedSet<String> integrationNames, final boolean defaultEnabled) {
|
||||
return integrationEnabled(integrationNames, defaultEnabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integrationNames
|
||||
* @param defaultEnabled
|
||||
* @return
|
||||
* @deprecated This method should only be used internally. Use the instance getter instead {@link
|
||||
* #isIntegrationEnabled(SortedSet, boolean)}.
|
||||
*/
|
||||
@Deprecated
|
||||
private static boolean integrationEnabled(
|
||||
final SortedSet<String> integrationNames, final boolean defaultEnabled) {
|
||||
// If default is enabled, we want to enable individually,
|
||||
// if default is disabled, we want to disable individually.
|
||||
boolean anyEnabled = defaultEnabled;
|
||||
|
@ -314,8 +299,6 @@ public class Config {
|
|||
/**
|
||||
* Calls {@link #getSettingFromEnvironment(String, String)} and converts the result to a list by
|
||||
* splitting on `,`.
|
||||
*
|
||||
* @deprecated This method should only be used internally. Use the explicit getter instead.
|
||||
*/
|
||||
@NonNull
|
||||
private static List<String> getListSettingFromEnvironment(
|
||||
|
@ -325,23 +308,12 @@ public class Config {
|
|||
|
||||
/**
|
||||
* Calls {@link #getSettingFromEnvironment(String, String)} and converts the result to a Boolean.
|
||||
*
|
||||
* @deprecated This method should only be used internally. Use the explicit getter instead.
|
||||
*/
|
||||
public static Boolean getBooleanSettingFromEnvironment(
|
||||
private static Boolean getBooleanSettingFromEnvironment(
|
||||
final String name, final Boolean defaultValue) {
|
||||
return getSettingFromEnvironmentWithLog(name, Boolean.class, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls {@link #getSettingFromEnvironment(String, String)} and converts the result to a Float.
|
||||
*
|
||||
* @deprecated This method should only be used internally. Use the explicit getter instead.
|
||||
*/
|
||||
public static Float getFloatSettingFromEnvironment(final String name, final Float defaultValue) {
|
||||
return getSettingFromEnvironmentWithLog(name, Float.class, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls {@link #getSettingFromEnvironment(String, String)} and converts the result to a Integer.
|
||||
*/
|
||||
|
|
|
@ -16,10 +16,6 @@
|
|||
package io.opentelemetry.auto.instrumentation.api;
|
||||
|
||||
public class MoreTags {
|
||||
public static final String SERVICE_NAME = "service.name";
|
||||
public static final String RESOURCE_NAME = "resource.name";
|
||||
public static final String DB_STATEMENT = "sql.query";
|
||||
|
||||
public static final String HTTP_QUERY = "http.query.string";
|
||||
public static final String HTTP_FRAGMENT = "http.fragment.string";
|
||||
|
||||
|
|
|
@ -21,12 +21,6 @@ public class Tags {
|
|||
public static final String HTTP_URL = "http.url";
|
||||
public static final String HTTP_STATUS = "http.status_code";
|
||||
public static final String HTTP_METHOD = "http.method";
|
||||
public static final String PEER_HOST_IPV4 = "peer.ipv4";
|
||||
public static final String PEER_HOST_IPV6 = "peer.ipv6";
|
||||
public static final String PEER_SERVICE = "peer.service";
|
||||
public static final String PEER_HOSTNAME = "peer.hostname";
|
||||
public static final String PEER_PORT = "peer.port";
|
||||
public static final String COMPONENT = "component";
|
||||
public static final String DB_TYPE = "db.type";
|
||||
public static final String DB_INSTANCE = "db.instance";
|
||||
public static final String DB_USER = "db.user";
|
||||
|
|
|
@ -221,35 +221,6 @@ class ConfigTest extends AgentSpecification {
|
|||
integrationNames = new TreeSet<>(names)
|
||||
}
|
||||
|
||||
def "test getFloatSettingFromEnvironment(#name)"() {
|
||||
setup:
|
||||
environmentVariables.set("OTA_ENV_ZERO_TEST", "0.0")
|
||||
environmentVariables.set("OTA_ENV_FLOAT_TEST", "1.0")
|
||||
environmentVariables.set("OTA_FLOAT_TEST", "0.2")
|
||||
|
||||
System.setProperty("ota.prop.zero.test", "0")
|
||||
System.setProperty("ota.prop.float.test", "0.3")
|
||||
System.setProperty("ota.float.test", "0.4")
|
||||
System.setProperty("ota.garbage.test", "garbage")
|
||||
System.setProperty("ota.negative.test", "-1")
|
||||
|
||||
expect:
|
||||
Config.getFloatSettingFromEnvironment(name, defaultValue) == (float) expected
|
||||
|
||||
where:
|
||||
name | expected
|
||||
"env.zero.test" | 0.0
|
||||
"prop.zero.test" | 0
|
||||
"env.float.test" | 1.0
|
||||
"prop.float.test" | 0.3
|
||||
"float.test" | 0.4
|
||||
"negative.test" | -1.0
|
||||
"garbage.test" | 10.0
|
||||
"default.test" | 10.0
|
||||
|
||||
defaultValue = 10.0
|
||||
}
|
||||
|
||||
def "verify integer range configs on tracer"() {
|
||||
setup:
|
||||
System.setProperty(PREFIX + HTTP_SERVER_ERROR_STATUSES, value)
|
||||
|
|
|
@ -108,7 +108,6 @@ public interface Instrumenter {
|
|||
+ getClass().getName()))
|
||||
.and(NOT_DECORATOR_MATCHER)
|
||||
.and(new MuzzleMatcher())
|
||||
.and(new PostMatchHook())
|
||||
.transform(AgentTransformers.defaultTransformers());
|
||||
agentBuilder = injectHelperClasses(agentBuilder);
|
||||
agentBuilder = contextProvider.instrumentationTransformer(agentBuilder);
|
||||
|
@ -183,19 +182,6 @@ public interface Instrumenter {
|
|||
}
|
||||
}
|
||||
|
||||
private class PostMatchHook implements AgentBuilder.RawMatcher {
|
||||
@Override
|
||||
public boolean matches(
|
||||
final TypeDescription typeDescription,
|
||||
final ClassLoader classLoader,
|
||||
final JavaModule module,
|
||||
final Class<?> classBeingRedefined,
|
||||
final ProtectionDomain protectionDomain) {
|
||||
postMatch(typeDescription, classLoader, module, classBeingRedefined, protectionDomain);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is implemented dynamically by compile-time bytecode transformations.
|
||||
*
|
||||
|
@ -218,25 +204,6 @@ public interface Instrumenter {
|
|||
/** @return A type matcher used to match the class under transform. */
|
||||
public abstract ElementMatcher<? super TypeDescription> typeMatcher();
|
||||
|
||||
/**
|
||||
* A hook invoked after matching has succeeded and before transformers have run.
|
||||
*
|
||||
* <p>Implementation note: This hook runs inside of the bytebuddy matching phase.
|
||||
*
|
||||
* @param typeDescription type description of the matched type
|
||||
* @param classLoader classloader loading the class under transform
|
||||
* @param module java module
|
||||
* @param classBeingRedefined null when the matched class is being loaded for the first time.
|
||||
* The instance of the active class during retransforms.
|
||||
* @param protectionDomain protection domain of the class under load.
|
||||
*/
|
||||
public void postMatch(
|
||||
final TypeDescription typeDescription,
|
||||
final ClassLoader classLoader,
|
||||
final JavaModule module,
|
||||
final Class<?> classBeingRedefined,
|
||||
final ProtectionDomain protectionDomain) {}
|
||||
|
||||
/** @return A map of matcher->advice */
|
||||
public abstract Map<? extends ElementMatcher<? super MethodDescription>, String> transformers();
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ package io.opentelemetry.auto.tooling.muzzle;
|
|||
|
||||
import io.opentelemetry.auto.bootstrap.WeakMap;
|
||||
import io.opentelemetry.auto.tooling.Instrumenter;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.WeakHashMap;
|
||||
import net.bytebuddy.build.Plugin;
|
||||
|
@ -69,7 +68,7 @@ public class MuzzleGradlePlugin implements Plugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {}
|
||||
public void close() {}
|
||||
|
||||
/** Compile-time Optimization used by gradle buildscripts. */
|
||||
public static class NoOp implements Plugin {
|
||||
|
@ -87,6 +86,6 @@ public class MuzzleGradlePlugin implements Plugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {}
|
||||
public void close() {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,23 +49,16 @@ public class ReferenceCreator extends ClassVisitor {
|
|||
*/
|
||||
private static final String REFERENCE_CREATION_PACKAGE = "io.opentelemetry.auto.instrumentation.";
|
||||
|
||||
public static Map<String, Reference> createReferencesFrom(
|
||||
final String entryPointClassName, final ClassLoader loader) {
|
||||
return ReferenceCreator.createReferencesFrom(entryPointClassName, loader, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate all references reachable from a given class.
|
||||
*
|
||||
* @param entryPointClassName Starting point for generating references.
|
||||
* @param loader Classloader used to read class bytes.
|
||||
* @param startFromMethodBodies if true only create refs from method bodies.
|
||||
* @return Map of [referenceClassName -> Reference]
|
||||
* @throws IllegalStateException if class is not found or unable to be loaded.
|
||||
*/
|
||||
private static Map<String, Reference> createReferencesFrom(
|
||||
final String entryPointClassName, final ClassLoader loader, boolean startFromMethodBodies)
|
||||
throws IllegalStateException {
|
||||
public static Map<String, Reference> createReferencesFrom(
|
||||
final String entryPointClassName, final ClassLoader loader) {
|
||||
final Set<String> visitedSources = new HashSet<>();
|
||||
final Map<String, Reference> references = new HashMap<>();
|
||||
|
||||
|
@ -77,9 +70,8 @@ public class ReferenceCreator extends ClassVisitor {
|
|||
visitedSources.add(className);
|
||||
final InputStream in = loader.getResourceAsStream(Utils.getResourceName(className));
|
||||
try {
|
||||
final ReferenceCreator cv = new ReferenceCreator(null, startFromMethodBodies);
|
||||
final ReferenceCreator cv = new ReferenceCreator();
|
||||
// only start from method bodies on the first pass
|
||||
startFromMethodBodies = false;
|
||||
final ClassReader reader = new ClassReader(in);
|
||||
reader.accept(cv, ClassReader.SKIP_FRAMES);
|
||||
|
||||
|
@ -185,12 +177,9 @@ public class ReferenceCreator extends ClassVisitor {
|
|||
private final Map<String, Reference> references = new HashMap<>();
|
||||
private String refSourceClassName;
|
||||
private Type refSourceType;
|
||||
private final boolean createFromMethodBodiesOnly;
|
||||
|
||||
private ReferenceCreator(
|
||||
final ClassVisitor classVisitor, final boolean createFromMethodBodiesOnly) {
|
||||
super(Opcodes.ASM7, classVisitor);
|
||||
this.createFromMethodBodiesOnly = createFromMethodBodiesOnly;
|
||||
private ReferenceCreator() {
|
||||
super(Opcodes.ASM7);
|
||||
}
|
||||
|
||||
public Map<String, Reference> getReferences() {
|
||||
|
|
|
@ -23,7 +23,6 @@ import io.opentelemetry.perftest.Worker;
|
|||
import io.opentelemetry.trace.Span;
|
||||
import io.opentelemetry.trace.Tracer;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -65,7 +64,7 @@ public class JettyPerftest {
|
|||
public static class PerfServlet extends HttpServlet {
|
||||
@Override
|
||||
protected void doGet(final HttpServletRequest request, final HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
throws IOException {
|
||||
if (request.getParameter("error") != null) {
|
||||
throw new RuntimeException("some sync error");
|
||||
}
|
||||
|
|
|
@ -71,8 +71,7 @@ public class CassandraClientInstrumentation extends Instrumenter.Default {
|
|||
* @throws Exception
|
||||
*/
|
||||
@Advice.OnMethodExit(suppress = Throwable.class)
|
||||
public static void injectTracingSession(@Advice.Return(readOnly = false) Session session)
|
||||
throws Exception {
|
||||
public static void injectTracingSession(@Advice.Return(readOnly = false) Session session) {
|
||||
// This should cover ours and OT's TracingSession
|
||||
if (session.getClass().getName().endsWith("cassandra.TracingSession")) {
|
||||
return;
|
||||
|
|
|
@ -21,7 +21,6 @@ import io.opentelemetry.OpenTelemetry;
|
|||
import io.opentelemetry.auto.bootstrap.instrumentation.decorator.HttpServerDecorator;
|
||||
import io.opentelemetry.trace.Tracer;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
public class FinatraDecorator extends HttpServerDecorator<Request, Request, Response> {
|
||||
public static final FinatraDecorator DECORATE = new FinatraDecorator();
|
||||
|
@ -40,7 +39,7 @@ public class FinatraDecorator extends HttpServerDecorator<Request, Request, Resp
|
|||
}
|
||||
|
||||
@Override
|
||||
protected URI url(final Request request) throws URISyntaxException {
|
||||
protected URI url(final Request request) {
|
||||
return URI.create(request.uri());
|
||||
}
|
||||
|
||||
|
|
|
@ -172,10 +172,6 @@ public class HttpUrlConnectionInstrumentation extends Instrumenter.Default {
|
|||
return finished;
|
||||
}
|
||||
|
||||
public void finish() {
|
||||
finished = true;
|
||||
}
|
||||
|
||||
public void finishSpan(final Throwable throwable) {
|
||||
try (final Scope scope = currentContextWith(span)) {
|
||||
DECORATE.onError(span, throwable);
|
||||
|
|
|
@ -61,7 +61,7 @@ public class AkkaAsyncChild extends ForkJoinTask implements Runnable, Callable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
public Object call() {
|
||||
runImpl();
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ public class ScalaAsyncChild extends ForkJoinTask implements Runnable, Callable
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
public Object call() {
|
||||
runImpl();
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ public final class AkkaExecutorInstrumentation extends AbstractExecutorInstrumen
|
|||
@Advice.This final Executor executor,
|
||||
@Advice.Enter final State state,
|
||||
@Advice.Thrown final Throwable throwable) {
|
||||
ExecutorInstrumentationUtils.cleanUpOnMethodExit(executor, state, throwable);
|
||||
ExecutorInstrumentationUtils.cleanUpOnMethodExit(state, throwable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ public final class JavaExecutorInstrumentation extends AbstractExecutorInstrumen
|
|||
@Advice.This final Executor executor,
|
||||
@Advice.Enter final State state,
|
||||
@Advice.Thrown final Throwable throwable) {
|
||||
ExecutorInstrumentationUtils.cleanUpOnMethodExit(executor, state, throwable);
|
||||
ExecutorInstrumentationUtils.cleanUpOnMethodExit(state, throwable);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ public final class JavaExecutorInstrumentation extends AbstractExecutorInstrumen
|
|||
@Advice.This final Executor executor,
|
||||
@Advice.Enter final State state,
|
||||
@Advice.Thrown final Throwable throwable) {
|
||||
ExecutorInstrumentationUtils.cleanUpOnMethodExit(executor, state, throwable);
|
||||
ExecutorInstrumentationUtils.cleanUpOnMethodExit(state, throwable);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,7 +171,7 @@ public final class JavaExecutorInstrumentation extends AbstractExecutorInstrumen
|
|||
InstrumentationContext.get(Future.class, State.class);
|
||||
contextStore.put(future, state);
|
||||
}
|
||||
ExecutorInstrumentationUtils.cleanUpOnMethodExit(executor, state, throwable);
|
||||
ExecutorInstrumentationUtils.cleanUpOnMethodExit(state, throwable);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -205,7 +205,7 @@ public final class JavaExecutorInstrumentation extends AbstractExecutorInstrumen
|
|||
InstrumentationContext.get(Future.class, State.class);
|
||||
contextStore.put(future, state);
|
||||
}
|
||||
ExecutorInstrumentationUtils.cleanUpOnMethodExit(executor, state, throwable);
|
||||
ExecutorInstrumentationUtils.cleanUpOnMethodExit(state, throwable);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ public final class ScalaExecutorInstrumentation extends AbstractExecutorInstrume
|
|||
@Advice.This final Executor executor,
|
||||
@Advice.Enter final State state,
|
||||
@Advice.Thrown final Throwable throwable) {
|
||||
ExecutorInstrumentationUtils.cleanUpOnMethodExit(executor, state, throwable);
|
||||
ExecutorInstrumentationUtils.cleanUpOnMethodExit(state, throwable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ public class JavaAsyncChild extends ForkJoinTask implements Runnable, Callable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
public Object call() {
|
||||
runImpl();
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import static io.opentelemetry.auto.instrumentation.jetty.JettyDecorator.DECORAT
|
|||
import io.opentelemetry.auto.instrumentation.api.Tags;
|
||||
import io.opentelemetry.trace.Span;
|
||||
import io.opentelemetry.trace.Status;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import javax.servlet.AsyncEvent;
|
||||
import javax.servlet.AsyncListener;
|
||||
|
@ -36,7 +35,7 @@ public class TagSettingAsyncListener implements AsyncListener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onComplete(final AsyncEvent event) throws IOException {
|
||||
public void onComplete(final AsyncEvent event) {
|
||||
if (activated.compareAndSet(false, true)) {
|
||||
DECORATE.onResponse(span, (HttpServletResponse) event.getSuppliedResponse());
|
||||
DECORATE.beforeFinish(span);
|
||||
|
@ -45,7 +44,7 @@ public class TagSettingAsyncListener implements AsyncListener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout(final AsyncEvent event) throws IOException {
|
||||
public void onTimeout(final AsyncEvent event) {
|
||||
if (activated.compareAndSet(false, true)) {
|
||||
span.setStatus(Status.UNKNOWN);
|
||||
span.setAttribute("timeout", event.getAsyncContext().getTimeout());
|
||||
|
@ -55,7 +54,7 @@ public class TagSettingAsyncListener implements AsyncListener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onError(final AsyncEvent event) throws IOException {
|
||||
public void onError(final AsyncEvent event) {
|
||||
final Throwable throwable = event.getThrowable();
|
||||
if (throwable != null && activated.compareAndSet(false, true)) {
|
||||
DECORATE.onResponse(span, (HttpServletResponse) event.getSuppliedResponse());
|
||||
|
@ -71,5 +70,5 @@ public class TagSettingAsyncListener implements AsyncListener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onStartAsync(final AsyncEvent event) throws IOException {}
|
||||
public void onStartAsync(final AsyncEvent event) {}
|
||||
}
|
||||
|
|
|
@ -46,8 +46,7 @@ public class HttpClientRequestTracingHandler extends SimpleChannelDownstreamHand
|
|||
}
|
||||
|
||||
@Override
|
||||
public void writeRequested(final ChannelHandlerContext ctx, final MessageEvent msg)
|
||||
throws Exception {
|
||||
public void writeRequested(final ChannelHandlerContext ctx, final MessageEvent msg) {
|
||||
if (!(msg.getMessage() instanceof HttpRequest)) {
|
||||
ctx.sendDownstream(msg);
|
||||
return;
|
||||
|
|
|
@ -39,8 +39,7 @@ public class HttpClientResponseTracingHandler extends SimpleChannelUpstreamHandl
|
|||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(final ChannelHandlerContext ctx, final MessageEvent msg)
|
||||
throws Exception {
|
||||
public void messageReceived(final ChannelHandlerContext ctx, final MessageEvent msg) {
|
||||
final ChannelTraceContext channelTraceContext =
|
||||
contextStore.putIfAbsent(ctx.getChannel(), ChannelTraceContext.Factory.INSTANCE);
|
||||
|
||||
|
|
|
@ -42,8 +42,7 @@ public class HttpServerRequestTracingHandler extends SimpleChannelUpstreamHandle
|
|||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(final ChannelHandlerContext ctx, final MessageEvent msg)
|
||||
throws Exception {
|
||||
public void messageReceived(final ChannelHandlerContext ctx, final MessageEvent msg) {
|
||||
final ChannelTraceContext channelTraceContext =
|
||||
contextStore.putIfAbsent(ctx.getChannel(), ChannelTraceContext.Factory.INSTANCE);
|
||||
|
||||
|
|
|
@ -35,8 +35,7 @@ public class HttpServerResponseTracingHandler extends SimpleChannelDownstreamHan
|
|||
}
|
||||
|
||||
@Override
|
||||
public void writeRequested(final ChannelHandlerContext ctx, final MessageEvent msg)
|
||||
throws Exception {
|
||||
public void writeRequested(final ChannelHandlerContext ctx, final MessageEvent msg) {
|
||||
final ChannelTraceContext channelTraceContext =
|
||||
contextStore.putIfAbsent(ctx.getChannel(), ChannelTraceContext.Factory.INSTANCE);
|
||||
|
||||
|
|
|
@ -58,8 +58,7 @@ public final class FluxAndMonoInstrumentation extends Instrumenter.Default {
|
|||
public String[] helperClassNames() {
|
||||
return new String[] {
|
||||
packageName + ".ReactorCoreAdviceUtils",
|
||||
packageName + ".ReactorCoreAdviceUtils$TracingSubscriber",
|
||||
packageName + ".ReactorCoreDecorator"
|
||||
packageName + ".ReactorCoreAdviceUtils$TracingSubscriber"
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.instrumentation.reactor;
|
||||
|
||||
import static io.opentelemetry.auto.instrumentation.reactor.ReactorCoreDecorator.DECORATE;
|
||||
import static reactor.core.publisher.Operators.lift;
|
||||
|
||||
import io.opentelemetry.auto.bootstrap.instrumentation.decorator.BaseDecorator;
|
||||
import io.opentelemetry.trace.Span;
|
||||
import io.opentelemetry.trace.Status;
|
||||
import java.util.function.Function;
|
||||
|
@ -63,7 +63,7 @@ public class ReactorCoreAdviceUtils {
|
|||
if (span != null) {
|
||||
if (throwable != null) {
|
||||
span.setStatus(Status.UNKNOWN);
|
||||
DECORATE.addThrowable(span, throwable);
|
||||
BaseDecorator.addThrowable(span, throwable);
|
||||
}
|
||||
span.end();
|
||||
}
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* Copyright 2020, OpenTelemetry 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.auto.instrumentation.reactor;
|
||||
|
||||
import io.opentelemetry.OpenTelemetry;
|
||||
import io.opentelemetry.auto.bootstrap.instrumentation.decorator.BaseDecorator;
|
||||
import io.opentelemetry.trace.Tracer;
|
||||
|
||||
public class ReactorCoreDecorator extends BaseDecorator {
|
||||
public static ReactorCoreDecorator DECORATE = new ReactorCoreDecorator();
|
||||
public static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.reactor-3.1");
|
||||
|
||||
@Override
|
||||
protected String getComponentName() {
|
||||
return "reactor-core";
|
||||
}
|
||||
}
|
|
@ -66,7 +66,7 @@ public final class RmiServerInstrumentation extends Instrumenter.Default {
|
|||
}
|
||||
|
||||
public static class ServerAdvice {
|
||||
@Advice.OnMethodEnter(suppress = Throwable.class, inline = true)
|
||||
@Advice.OnMethodEnter(suppress = Throwable.class)
|
||||
public static SpanWithScope onEnter(
|
||||
@Advice.This final Object thiz, @Advice.Origin final Method method) {
|
||||
final int callDepth = CallDepthThreadLocalMap.incrementCallDepth(RemoteServer.class);
|
||||
|
|
|
@ -17,17 +17,13 @@ package io.opentelemetry.auto.instrumentation.rxjava;
|
|||
|
||||
import static io.opentelemetry.trace.TracingContextUtils.currentContextWith;
|
||||
|
||||
import io.opentelemetry.OpenTelemetry;
|
||||
import io.opentelemetry.auto.bootstrap.instrumentation.decorator.BaseDecorator;
|
||||
import io.opentelemetry.context.Scope;
|
||||
import io.opentelemetry.trace.Span;
|
||||
import io.opentelemetry.trace.Tracer;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import rx.Subscriber;
|
||||
|
||||
public class TracedSubscriber<T> extends Subscriber<T> {
|
||||
private static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.rxjava-1.0");
|
||||
|
||||
private final AtomicReference<Span> spanRef;
|
||||
private final Subscriber<T> delegate;
|
||||
|
|
|
@ -20,7 +20,6 @@ import static io.opentelemetry.auto.instrumentation.servlet.v3_0.Servlet3Decorat
|
|||
import io.opentelemetry.auto.instrumentation.api.Tags;
|
||||
import io.opentelemetry.trace.Span;
|
||||
import io.opentelemetry.trace.Status;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import javax.servlet.AsyncEvent;
|
||||
import javax.servlet.AsyncListener;
|
||||
|
@ -36,7 +35,7 @@ public class TagSettingAsyncListener implements AsyncListener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onComplete(final AsyncEvent event) throws IOException {
|
||||
public void onComplete(final AsyncEvent event) {
|
||||
if (activated.compareAndSet(false, true)) {
|
||||
DECORATE.onResponse(span, (HttpServletResponse) event.getSuppliedResponse());
|
||||
DECORATE.beforeFinish(span);
|
||||
|
@ -45,7 +44,7 @@ public class TagSettingAsyncListener implements AsyncListener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout(final AsyncEvent event) throws IOException {
|
||||
public void onTimeout(final AsyncEvent event) {
|
||||
if (activated.compareAndSet(false, true)) {
|
||||
span.setStatus(Status.UNKNOWN);
|
||||
span.setAttribute("timeout", event.getAsyncContext().getTimeout());
|
||||
|
@ -55,7 +54,7 @@ public class TagSettingAsyncListener implements AsyncListener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onError(final AsyncEvent event) throws IOException {
|
||||
public void onError(final AsyncEvent event) {
|
||||
if (event.getThrowable() != null && activated.compareAndSet(false, true)) {
|
||||
DECORATE.onResponse(span, (HttpServletResponse) event.getSuppliedResponse());
|
||||
if (((HttpServletResponse) event.getSuppliedResponse()).getStatus()
|
||||
|
@ -72,7 +71,7 @@ public class TagSettingAsyncListener implements AsyncListener {
|
|||
|
||||
/** Transfer the listener over to the new context. */
|
||||
@Override
|
||||
public void onStartAsync(final AsyncEvent event) throws IOException {
|
||||
public void onStartAsync(final AsyncEvent event) {
|
||||
event.getAsyncContext().addListener(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ import static io.opentelemetry.auto.test.utils.TraceUtils.runUnderTrace;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Set;
|
||||
|
@ -94,7 +93,7 @@ public class RequestDispatcherUtils {
|
|||
}
|
||||
|
||||
@Override
|
||||
public URL getResource(final String s) throws MalformedURLException {
|
||||
public URL getResource(final String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -114,7 +113,7 @@ public class RequestDispatcherUtils {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Servlet getServlet(final String s) throws ServletException {
|
||||
public Servlet getServlet(final String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -187,7 +186,7 @@ public class RequestDispatcherUtils {
|
|||
"forward-child",
|
||||
new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
public Object call() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
@ -203,7 +202,7 @@ public class RequestDispatcherUtils {
|
|||
"include-child",
|
||||
new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
public Object call() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -28,7 +28,6 @@ public abstract class AbstractWebfluxInstrumentation extends Instrumenter.Defaul
|
|||
return new String[] {
|
||||
packageName + ".SpringWebfluxHttpServerDecorator",
|
||||
// Some code comes from reactor's instrumentation's helper
|
||||
"io.opentelemetry.auto.instrumentation.reactor.ReactorCoreDecorator",
|
||||
"io.opentelemetry.auto.instrumentation.reactor.ReactorCoreAdviceUtils",
|
||||
"io.opentelemetry.auto.instrumentation.reactor.ReactorCoreAdviceUtils$TracingSubscriber",
|
||||
packageName + ".AdviceUtils",
|
||||
|
|
|
@ -20,7 +20,6 @@ import static io.opentelemetry.auto.instrumentation.springwebflux.server.SpringW
|
|||
import io.opentelemetry.auto.instrumentation.reactor.ReactorCoreAdviceUtils;
|
||||
import io.opentelemetry.trace.Span;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.reactive.function.client.ClientRequest;
|
||||
import org.springframework.web.reactive.function.server.ServerRequest;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
|
@ -56,10 +55,4 @@ public class AdviceUtils {
|
|||
ReactorCoreAdviceUtils.finishSpanIfPresent(
|
||||
(Span) serverRequest.attributes().remove(SPAN_ATTRIBUTE), throwable);
|
||||
}
|
||||
|
||||
public static void finishSpanIfPresent(
|
||||
final ClientRequest clientRequest, final Throwable throwable) {
|
||||
ReactorCoreAdviceUtils.finishSpanIfPresent(
|
||||
(Span) clientRequest.attributes().remove(SPAN_ATTRIBUTE), throwable);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,9 +22,7 @@ import static io.opentelemetry.trace.TracingContextUtils.currentContextWith;
|
|||
import io.opentelemetry.auto.instrumentation.api.SpanWithScope;
|
||||
import io.opentelemetry.auto.instrumentation.reactor.ReactorCoreAdviceUtils;
|
||||
import io.opentelemetry.trace.Span;
|
||||
import java.util.function.Function;
|
||||
import net.bytebuddy.asm.Advice;
|
||||
import org.reactivestreams.Publisher;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
|
@ -62,8 +60,6 @@ public class DispatcherHandlerAdvice {
|
|||
return;
|
||||
}
|
||||
if (throwable == null && mono != null) {
|
||||
final Function<? super Mono<Object>, ? extends Publisher<Object>> function =
|
||||
ReactorCoreAdviceUtils.finishSpanNextOrError();
|
||||
mono = ReactorCoreAdviceUtils.setPublisherSpan(mono, spanWithScope.getSpan());
|
||||
} else if (throwable != null) {
|
||||
AdviceUtils.finishSpanIfPresent(exchange, throwable);
|
||||
|
|
|
@ -30,9 +30,6 @@ import net.spy.memcached.MemcachedConnection;
|
|||
@Slf4j
|
||||
public abstract class CompletionListener<T> {
|
||||
|
||||
static final String SERVICE_NAME = "memcached";
|
||||
static final String COMPONENT_NAME = "java-spymemcached";
|
||||
static final String DB_TYPE = "memcached";
|
||||
static final String DB_COMMAND_CANCELLED = "db.command.cancelled";
|
||||
static final String MEMCACHED_RESULT = "memcaced.result";
|
||||
static final String HIT = "hit";
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
package io.opentelemetry.auto.instrumentation.spymemcached;
|
||||
|
||||
import io.opentelemetry.trace.Span;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.spy.memcached.MemcachedConnection;
|
||||
|
||||
|
@ -27,8 +26,7 @@ public class SyncCompletionListener extends CompletionListener<Void> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void processResult(final Span span, final Void future)
|
||||
throws ExecutionException, InterruptedException {
|
||||
protected void processResult(final Span span, final Void future) {
|
||||
log.error("processResult was called on SyncCompletionListener. This should never happen. ");
|
||||
}
|
||||
|
||||
|
|
|
@ -639,7 +639,7 @@ class SpymemcachedTest extends AgentTestRunner {
|
|||
errored(error != null && error != "canceled")
|
||||
|
||||
tags {
|
||||
"$Tags.DB_TYPE" CompletionListener.DB_TYPE
|
||||
"$Tags.DB_TYPE" "memcached"
|
||||
|
||||
if (error == "canceled") {
|
||||
"${CompletionListener.DB_COMMAND_CANCELLED}" true
|
||||
|
|
|
@ -66,7 +66,7 @@ public final class TraceAnnotationsInstrumentation extends Instrumenter.Default
|
|||
final String configString = Config.get().getTraceAnnotations();
|
||||
if (configString == null) {
|
||||
additionalTraceAnnotations =
|
||||
Collections.unmodifiableSet(Sets.<String>newHashSet(DEFAULT_ANNOTATIONS));
|
||||
Collections.unmodifiableSet(Sets.newHashSet(DEFAULT_ANNOTATIONS));
|
||||
} else if (configString.trim().isEmpty()) {
|
||||
additionalTraceAnnotations = Collections.emptySet();
|
||||
} else if (!configString.matches(CONFIG_FORMAT)) {
|
||||
|
|
|
@ -42,21 +42,21 @@ public class SayTracedHello {
|
|||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
public static String fromCallable() throws Exception {
|
||||
public static String fromCallable() {
|
||||
return new Callable<String>() {
|
||||
@com.newrelic.api.agent.Trace
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
public String call() {
|
||||
return "Howdy!";
|
||||
}
|
||||
}.call();
|
||||
}
|
||||
|
||||
public static String fromCallableWhenDisabled() throws Exception {
|
||||
public static String fromCallableWhenDisabled() {
|
||||
return new Callable<String>() {
|
||||
@com.newrelic.api.agent.Trace
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
public String call() {
|
||||
return "Howdy!";
|
||||
}
|
||||
}.call();
|
||||
|
|
|
@ -17,9 +17,10 @@ package jvmbootstraptest;
|
|||
|
||||
public class LogLevelChecker {
|
||||
// returns an exception if logs are not in DEBUG
|
||||
public static void main(final String[] args) throws ClassNotFoundException {
|
||||
public static void main(final String[] args) {
|
||||
|
||||
String str = System.getProperty("io.opentelemetry.auto.slf4j.simpleLogger.defaultLogLevel");
|
||||
final String str =
|
||||
System.getProperty("io.opentelemetry.auto.slf4j.simpleLogger.defaultLogLevel");
|
||||
|
||||
if ((str == null) || (str != null && !str.equalsIgnoreCase("debug"))) {
|
||||
throw new RuntimeException("debug mode not set");
|
||||
|
|
|
@ -111,10 +111,6 @@ public abstract class AgentTestRunner extends AgentSpecification {
|
|||
return TEST_TRACER;
|
||||
}
|
||||
|
||||
protected static ListWriter getTestWriter() {
|
||||
return TEST_WRITER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked when Bytebuddy encounters an instrumentation error. Fails the test by default.
|
||||
*
|
||||
|
@ -302,7 +298,7 @@ public abstract class AgentTestRunner extends AgentSpecification {
|
|||
}
|
||||
}
|
||||
|
||||
protected static String getClassName(Class clazz) {
|
||||
protected static String getClassName(final Class clazz) {
|
||||
String className = clazz.getSimpleName();
|
||||
if (className.isEmpty()) {
|
||||
className = clazz.getName();
|
||||
|
|
Loading…
Reference in New Issue