If you are asking about a problem you are experiencing, please use the following template, as it will help us help you. If you have a different problem, please delete all of this text
TIP 1: select at least one tag that further categorizes your topic. For example server
for APM Server related questions, java
for questions regarding the Elastic APM Java agent, or ui
for questions about the APM App within Kibana.
TIP 2: Check out the troubleshooting guide first. Not only will it help you to resolve common problems faster but it also explains in more detail which information we need before we can properly help you.
Kibana version: 8.53
Elasticsearch version: 8.5.3
APM Server version:8.5.3
APM Agent language and version: Java / 8.5.3
Browser version:Chrome 108
Original install method (e.g. download page, yum, deb, from source, etc.) and version:
Fresh install or upgraded from other version? Fresh
Is there anything special in your setup? For example, are you using the Logstash or Kafka outputs? Are you using a load balancer in front of the APM Servers? Have you changed index pattern, generated custom templates, changed agent configuration etc.
Nothing special, basic docker-compose up setup.
Description of the problem including expected versus actual behavior. Please include screenshots (if relevant):
I'm currently trying to instrument a transaction through an entire API service call, but seem to lose the ElasticApm.currentTransaction/Span information after any async call to Elasticsearch.
I setup an extremely simple test application with Jersey endpoints that receive a request. The Java agent automatically instruments the Jersey request and any method I call that has the appropriate Public Api annotations on them. This works for any synchronous calls and asynchronous methos (ExecutorService / CompletableFutures), except when I perform an async request with the Java Elastic client. Why is the context not propagating to any future stages after the call to elastic?
Here's a basic structure of the call I'm making
ExecutorService _executorService = Executors.newFixedThreadPool(10);
return _asyncClient.search(s -> s
.index("products")
.query(q -> q
.term(t -> t
.field("name")
.value(v -> v.stringValue("bicycle"))
)),
Product.class)
.thenApplyAsync(response -> {
/* THE BELOW VALUES ARE ALWAYS NOOP INSTANCES */
Transaction trans1 = ElasticApm.currentTransaction();
Span span1 = ElasticApm.currentSpan();
LOGGER.info("[Apm trans/span id -- {}/{}", trans1.getId(), span1.getId());
return response;
}, _executorService);
Any subsequent stage doesn't have the Trace information and consequently the Public Api annotations don't pick anything up either.
Am I misunderstanding how this should be instrumented with Java Futures and the instrumentation from Executors in APM?
Thanks in advance!