diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 1e4c5b1748..65525c4e40 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -33,8 +33,6 @@ updates: - dependency-name: "com.datastax.oss:java-driver-core" - dependency-name: "io.micrometer:*" - dependency-name: "redis.clients:*" - - dependency-name: "org.elasticsearch.client:*" - - dependency-name: "co.elastic.clients:*" - dependency-name: "io.vertx:*" - dependency-name: "org.apache.logging.log4j:*" - dependency-name: "org.springframework.boot:*" diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index cb9f2eb182..6062e6eebf 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -42,6 +42,7 @@ Use subheadings with the "=====" level for adding notes for unreleased changes: ===== Features * Add support for Elasticsearch client 8.9 - {pull}3283[#3283] * Added `baggage_to_attach` config option to allow automatic lifting of baggage into transaction, span and error attributes - {pull}3288[#3288], {pull}3289[#3289] +* Exclude elasticsearch 8.10 and newer clients from instrumentation because they natively support OpenTelemetry - {pull}3303[#3303] [[release-notes-1.x]] === Java Agent version 1.x diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/esrestclient/ElasticsearchRestClientInstrumentation.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/esrestclient/ElasticsearchRestClientInstrumentation.java index 4c54b64108..d32a0eca74 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/esrestclient/ElasticsearchRestClientInstrumentation.java +++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/esrestclient/ElasticsearchRestClientInstrumentation.java @@ -21,10 +21,14 @@ import co.elastic.apm.agent.sdk.ElasticApmInstrumentation; import co.elastic.apm.agent.tracer.GlobalTracer; import co.elastic.apm.agent.tracer.Tracer; +import net.bytebuddy.matcher.ElementMatcher; import java.util.Collection; import java.util.Collections; +import static co.elastic.apm.agent.sdk.bytebuddy.CustomElementMatchers.classLoaderCanLoadClass; +import static net.bytebuddy.matcher.ElementMatchers.not; + public abstract class ElasticsearchRestClientInstrumentation extends ElasticApmInstrumentation { @@ -35,4 +39,10 @@ public Collection getInstrumentationGroupNames() { return Collections.singleton("elasticsearch-restclient"); } + @Override + public ElementMatcher.Junction getClassLoaderMatcher() { + // ensure only ES client versions without native instrumentation are instrumented (8.9 and older) + return not(classLoaderCanLoadClass("co.elastic.clients.transport.instrumentation.Instrumentation")); + } + }