Disable Elasticsearch instrumentation for ES clients 8.10+ (#9337)
Signed-off-by: Alexander Wert <alexander.wert@elastic.co> Co-authored-by: Lauri Tulmin <tulmin@gmail.com> Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com> Co-authored-by: Lauri Tulmin <ltulmin@splunk.com>
This commit is contained in:
parent
1cb583ab5f
commit
dc523cf990
|
@ -6,7 +6,7 @@ muzzle {
|
|||
pass {
|
||||
group.set("co.elastic.clients")
|
||||
module.set("elasticsearch-java")
|
||||
versions.set("[7.16,)")
|
||||
versions.set("[7.16,8.10)") // 8.10+ has native, on-by-default opentelemetry instrumentation
|
||||
assertInverse.set(true)
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ dependencies {
|
|||
testImplementation("com.fasterxml.jackson.core:jackson-databind:2.14.2")
|
||||
testImplementation("org.testcontainers:elasticsearch")
|
||||
|
||||
// 8.10+ has native, on-by-default opentelemetry instrumentation
|
||||
latestDepTestLibrary("co.elastic.clients:elasticsearch-java:8.0.+")
|
||||
}
|
||||
|
||||
|
|
|
@ -5,12 +5,15 @@
|
|||
|
||||
package io.opentelemetry.javaagent.instrumentation.elasticsearch.apiclient;
|
||||
|
||||
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed;
|
||||
import static java.util.Arrays.asList;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.not;
|
||||
|
||||
import com.google.auto.service.AutoService;
|
||||
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
|
||||
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
|
||||
import java.util.List;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
|
||||
@AutoService(InstrumentationModule.class)
|
||||
public class ElasticsearchApiClientInstrumentationModule extends InstrumentationModule {
|
||||
|
@ -18,6 +21,15 @@ public class ElasticsearchApiClientInstrumentationModule extends Instrumentation
|
|||
super("elasticsearch-api-client-7.16", "elasticsearch");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
|
||||
// Since Elasticsearch client version 8.10, the ES client comes with a native OTel
|
||||
// instrumentation
|
||||
// that introduced the class `co.elastic.clients.transport.instrumentation.Instrumentation`.
|
||||
// Disabling agent instrumentation for those cases.
|
||||
return not(hasClassesNamed("co.elastic.clients.transport.instrumentation.Instrumentation"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TypeInstrumentation> typeInstrumentations() {
|
||||
return asList(
|
||||
|
|
|
@ -22,7 +22,7 @@ public class ElasticsearchRest7InstrumentationModule extends InstrumentationModu
|
|||
|
||||
@Override
|
||||
public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
|
||||
// class introduced in 7.0.0
|
||||
// Class `org.elasticsearch.client.RestClient$InternalRequest` introduced in 7.0.0.
|
||||
return hasClassesNamed("org.elasticsearch.client.RestClient$InternalRequest");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue