Remove some no longer needed netty instrumentation (#7732)

Will follow-up with some related clean-up of `WRITE_CONTEXT` (wanted to
split the changes for clearer review).
This commit is contained in:
Trask Stalnaker 2023-02-06 08:15:34 -08:00 committed by GitHub
parent e638201cc4
commit 9979d8f620
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 0 additions and 115 deletions

View File

@ -1,56 +0,0 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.javaagent.instrumentation.netty.v4_0;
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed;
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.implementsInterface;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.namedOneOf;
import io.netty.channel.Channel;
import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
/**
* This instrumentation preserves the context that was active during call to any "write" operation
* on Netty Channel in that channel's attribute. This context is later used by our various tracing
* handlers to scope the work.
*/
public class ChannelInstrumentation implements TypeInstrumentation {
@Override
public ElementMatcher<ClassLoader> classLoaderOptimization() {
return hasClassesNamed("io.netty.channel.Channel");
}
@Override
public ElementMatcher<TypeDescription> typeMatcher() {
return implementsInterface(named("io.netty.channel.Channel"));
}
@Override
public void transform(TypeTransformer transformer) {
transformer.applyAdviceToMethod(
isMethod().and(namedOneOf("write", "writeAndFlush")),
ChannelInstrumentation.class.getName() + "$AttachContextAdvice");
}
@SuppressWarnings("unused")
public static class AttachContextAdvice {
@Advice.OnMethodEnter
public static void attachContext(@Advice.This Channel channel) {
channel
.attr(AttributeKeys.WRITE_CONTEXT)
.compareAndSet(null, Java8BytecodeBridge.currentContext());
}
}
}

View File

@ -35,7 +35,6 @@ public class NettyInstrumentationModule extends InstrumentationModule {
public List<TypeInstrumentation> typeInstrumentations() {
return asList(
new BootstrapInstrumentation(),
new ChannelInstrumentation(),
new NettyFutureInstrumentation(),
new NettyChannelPipelineInstrumentation(),
new AbstractChannelHandlerContextInstrumentation());

View File

@ -1,57 +0,0 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.javaagent.instrumentation.netty.v4_1;
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed;
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.implementsInterface;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.namedOneOf;
import io.netty.channel.Channel;
import io.opentelemetry.instrumentation.netty.v4_1.internal.AttributeKeys;
import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
/**
* This instrumentation preserves the context that was active during call to any "write" operation
* on Netty Channel in that channel's attribute. This context is later used by our various tracing
* handlers to scope the work.
*/
public class ChannelInstrumentation implements TypeInstrumentation {
@Override
public ElementMatcher<ClassLoader> classLoaderOptimization() {
return hasClassesNamed("io.netty.channel.Channel");
}
@Override
public ElementMatcher<TypeDescription> typeMatcher() {
return implementsInterface(named("io.netty.channel.Channel"));
}
@Override
public void transform(TypeTransformer transformer) {
transformer.applyAdviceToMethod(
isMethod().and(namedOneOf("write", "writeAndFlush")),
ChannelInstrumentation.class.getName() + "$AttachContextAdvice");
}
@SuppressWarnings("unused")
public static class AttachContextAdvice {
@Advice.OnMethodEnter
public static void attachContext(@Advice.This Channel channel) {
channel
.attr(AttributeKeys.WRITE_CONTEXT)
.compareAndSet(null, Java8BytecodeBridge.currentContext());
}
}
}

View File

@ -32,7 +32,6 @@ public class NettyInstrumentationModule extends InstrumentationModule {
public List<TypeInstrumentation> typeInstrumentations() {
return asList(
new BootstrapInstrumentation(),
new ChannelInstrumentation(),
new NettyFutureInstrumentation(),
new NettyChannelPipelineInstrumentation(),
new AbstractChannelHandlerContextInstrumentation());