> ## Documentation Index
> Fetch the complete documentation index at: https://docs.appsignal.com/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenTelemetry-Installation für Elixir

Stellen Sie sicher, dass Sie [den AppSignal Collector installieren](/opentelemetry/installation), bevor Sie mit diesen Anweisungen fortfahren.

## Die OpenTelemetry-Pakete installieren

Fügen Sie das OpenTelemetry-SDK und den OTLP-Exporter zu den Abhängigkeiten Ihrer Anwendung hinzu:

<CodeGroup>
  ```elixir Elixir theme={null}
  def deps do
    [
      # other dependencies...
      {:opentelemetry, "~> 1.3"},
      {:opentelemetry_api, "~> 1.2"},
      {:opentelemetry_exporter, "~> 1.6"},
    ]
  end
  ```
</CodeGroup>

Fügen Sie auch die OpenTelemetry-Instrumentierungspakete für die Bibliotheken und Frameworks hinzu, die Ihre Anwendung verwendet. Zum Beispiel, wenn Sie Phoenix verwenden:

<CodeGroup>
  ```elixir Elixir theme={null}
  def deps do
    [
      # other dependencies...
      {:opentelemetry_phoenix, "~> 1.1"},
      {:opentelemetry_cowboy, "~> 0.2"},
      {:opentelemetry_ecto, "~> 1.2"}
    ]
  end
  ```
</CodeGroup>

Für andere Bibliotheken und Frameworks können Sie [OpenTelemetry-Instrumentierungspakete im OpenTelemetry-Registry finden](https://opentelemetry.io/ecosystem/registry/?s=\&component=instrumentation\&language=elixir\&flag=all).

## OpenTelemetry in Ihrer Anwendung konfigurieren

Aktualisieren Sie die Datei `config/config.exs` in Ihrer Anwendung mit der OpenTelemetry-Exporter- und AppSignal-Konfiguration.

Stellen Sie sicher, dass Sie die folgenden Werte mit Ihrem AppSignal-Anwendungsnamen, der Umgebung und dem Push API-Schlüssel aktualisieren und den Exporter-Endpunkt durch die Adresse Ihres AppSignal Collectors ersetzen, falls erforderlich.

<CodeGroup>
  ```elixir Elixir theme={null}
  # 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
  ```
</CodeGroup>

## Die App testen!

Nachdem nun alle Komponenten verbunden sind, starten Sie Ihre App und testen Sie, ob Daten in AppSignal eintreffen. Überprüfen Sie insbesondere die Seiten [„Errors > Issue list"](https://appsignal.com/redirect-to/app?to=exceptions) und [„Performance > Traces"](https://appsignal.com/redirect-to/app?to=performance/traces).

Wenn Sie nach dem Befolgen unserer Installationsanweisungen immer noch keine Daten in AppSignal sehen, [lassen Sie es uns wissen](mailto:support@appsignal.com?subject=OpenTelemetry%20issue), und wir helfen Ihnen, Ihre OpenTelemetry-Installation abzuschließen!
