OpenTelemetry Elixir Installation

Make sure to install the AppSignal collector before proceeding with these instructions.

Install the OpenTelemetry packages

Add the OpenTelemetry SDK and the OTLP exporter to your application's dependencies:

mix.exs
def deps do [ # other dependencies... {:opentelemetry, "~> 1.3"}, {:opentelemetry_api, "~> 1.2"}, {:opentelemetry_exporter, "~> 1.6"}, ] end

Also add the OpenTelemetry instrumentation packages for the libraries and frameworks that your application uses. For example, if you're using Phoenix:

mix.exs
def deps do [ # other dependencies... {:opentelemetry_phoenix, "~> 1.1"}, {:opentelemetry_cowboy, "~> 0.2"}, {:opentelemetry_ecto, "~> 1.2"} ] end

For other libraries and frameworks, you can find OpenTelemetry instrumentation packages at the OpenTelemetry registry.

Configure OpenTelemetry in your application

Update the config/config.exs file in your application with the OpenTelemetry exporter and AppSignal configuration.

Make sure to update the values below with your AppSignal application name, environment and push API key, and to replace the exporter endpoint with the address of your AppSignal collector if needed.

config/config.exs
# Replace these values with your AppSignal application name, environment # (autodetected from Mix) and push API key. These are used by the resource attributes # configuration below. name = "My app" push_api_key = "0000-0000-0000-0000" environment = if Kernel.function_exported?(Mix, :env, 0) do to_string(Mix.env()) else "development" end # Set the name of the service that is being monitored. A common choice is the # name of the framework used. This is used to group traces and metrics in AppSignal. service_name = "My service name" # Replace `http://localhost:8099` with the address of your AppSignal collector # if it's running on another host. endpoint = "http://localhost:8099" {:ok, hostname} = :inet.gethostname() {revision, _exitcode} = System.cmd("git", ["log", "--pretty=format:%h", "-n 1"]) config :opentelemetry, span_processor: :batch, traces_exporter: :otlp, resource: [ {"appsignal.config.name", name}, {"appsignal.config.environment", environment}, {"appsignal.config.push_api_key", push_api_key}, {"appsignal.config.revision", revision}, {"appsignal.config.language_integration", "elixir"}, {"appsignal.config.app_path", File.cwd!()}, {"host.name", hostname}, {"service.name", service_name} ] config :opentelemetry_exporter, otlp_protocol: :http_protobuf, otlp_endpoint: endpoint

Test the app!

Now that all the components are connected, start your app and test if you see data arrive in AppSignal. Check the "Errors > Issue list" and "Performance > Traces" page specifically.

If after following our installation instructions you still don't see data in AppSignal, let us know and we'll help you finalize your OpenTelemetry installation!