Remove some no longer needed netty instrumentation
Will follow-up with some related clean-up of `WRITE_CONTEXT` (wanted to
split the changes for clearer review).
DELETE
instrumentation/netty/netty-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v4_0/ChannelInstrumentation.java
-/*
- * 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());
- }
- }
-}

MODIFY
instrumentation/netty/netty-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v4_0/NettyInstrumentationModule.java
instrumentation/netty/netty-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v4_0/NettyInstrumentationModule.java
@@ -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());

DELETE
instrumentation/netty/netty-4.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v4_1/ChannelInstrumentation.java
-/*
- * 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());
- }
- }
-}

MODIFY
instrumentation/netty/netty-4.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v4_1/NettyInstrumentationModule.java
instrumentation/netty/netty-4.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v4_1/NettyInstrumentationModule.java
@@ -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());

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).