Elastic APM with Playframework

Hi all,
I try to integrate Elastic APM with playframework.

For this reason I wrote a simple filter:

package filters;

import akka.stream.Materializer;
import co.elastic.apm.api.ElasticApm;
import co.elastic.apm.api.Transaction;

import javax.inject.Inject;
import java.util.concurrent.CompletionStage;
import java.util.function.Function;

import co.elastic.apm.attach.ElasticApmAttacher;
import play.mvc.*;

public class APMFilter extends Filter {

    public APMFilter(Materializer mat) {

    public CompletionStage<Result> apply(Function<Http.RequestHeader, CompletionStage<Result>> next, Http.RequestHeader rh) {

        Transaction transaction = ElasticApm.startTransaction();

        return next.apply(rh).thenApply(result -> {
            return result;


but in elastic APM nothing is visualized.

Someone can help me?



Hi and thanks for trying it out.

I don't have any experience with Play, but I'll try :slight_smile:

I am not sure why you imported co.elastic.apm.attach.ElasticApmAttacher, which is used for remote attachment to the JVM. Please review the different available setup options.
Basically, the Java agent is either provided as the javaagent command line argument (e.g. using these Play options to specify JVM arguments), or remotely attached.

In any case, the agent itself needs to be installed. Note that the API jar (which contains the co.elastic.apm.api.ElasticApm you are using here) is acting as noop as long as the Java agent is not installed.

I hope this makes sense.

thank for reply!

Actually the co.elastic.apm.attach.ElasticApmAttacher import it's not used (but thanks for reporting).

In the end the only way to make it work was to use cinnamon and connect it via opentracing to ElasticApm.
To do this, however, I had to start 2 agents (apm and cinnamon).

...and add a custom tracer factory like this:

import co.elastic.apm.opentracing.ElasticApmTracer;
import com.lightbend.cinnamon.opentracing.TracerFactory;
import io.opentracing.Tracer;

public class CustomTracerFactory implements TracerFactory {

    public Tracer create() {
        return new ElasticApmTracer();


I hope this is useful to someone


This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.