Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable instrumentation for ES client versions with native instrumentation #3303

Merged
merged 5 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:*"
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -35,4 +39,10 @@ public Collection<String> getInstrumentationGroupNames() {
return Collections.singleton("elasticsearch-restclient");
}

@Override
public ElementMatcher.Junction<ClassLoader> getClassLoaderMatcher() {
// ensure only ES client versions without native instrumentation are instrumented (8.9 and older)
return not(classLoaderCanLoadClass("co.elastic.clients.transport.instrumentation.Instrumentation"));
}

}
Loading