2
votes

We want to track our elixir phoenix app using elastic apm. But I could not find an apm agent from elastic.

Someone suggested to use opentelemetry along with exporter but I am unable to understand how to use that from the docs. I want to track details like the new relic does like errors and all things.

Previously we used new relic for which there is an open source apm agent but now we want to switch to elastic.I am unable to understand how to use span in the app and how to handle multiple span and where to put them. If anyone can help with that or provide alternate solution to use elastic apm it would be great.

1

1 Answers

5
votes

It's true, there isn't an Elixir agent for Elastic APM - you can upvote this issue to get the topic more attention.

As you discovered, you can use the OpenTelemetry in the meantime. To do that, run the OpenTelemetry contrib collector (otel collector) and configure it to export to elastic - there is a full explanation in the docs along with this sample configuration:

receivers:
  otlp:
    endpoint: localhost:55680
processors:
  batch:
    timeout: 1s
    send_batch_size: 1024
exporters:
  elastic:
    apm_server_url: "https://elasticapm.example.com"
    secret_token: "ESS_TOKEN"
service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [batch]
      exporters: [elastic]

In your application, configure the tracer use the opentelemetry exporter.

At that point you'll have a tracer in your application sending traces to the otel collector. From there, traces will be exported to the Elastic Stack via APM Server. In summary: your app -> otel collector -> apm-server -> elasticsearch

The Erlang/Elixir Agent Docs have sample code for starting and decorating spans.