> ## 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-Java-Installation

Bitte folgen Sie zuerst dem [Installationsleitfaden](/guides/new-application), wenn Sie eine neue Anwendung zu AppSignal hinzufügen.

Stellen Sie anschließend sicher, dass Sie [den AppSignal-Collector installiert](/collector/installation) haben, bevor Sie fortfahren.

Um OpenTelemetry für Ihre Java-Anwendung zu installieren und zu konfigurieren, empfehlen wir die Verwendung des OpenTelemetry-Java-Agenten, um Daten an den AppSignal-Collector zu exportieren. Dieser Agent instrumentiert Ihre Anwendung automatisch.

## OpenTelemetry-Java-Agenten herunterladen

Laden Sie den OpenTelemetry-Java-Agenten aus dem [neuesten Release auf GitHub](https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar) herunter. Beim Ausführen Ihrer Anwendung muss der OpenTelemetry-Java-Agent vorhanden sein.

## Anwendung mit dem Agenten ausführen

Beim Ausführen Ihrer Anwendung müssen Sie die Java-Laufzeitumgebung so konfigurieren, dass sie den OpenTelemetry-Java-Agenten lädt. Ändern Sie die Art, wie Sie Ihre Anwendung starten, damit der OpenTelemetry-Java-Agent zusammen mit Ihrer Anwendung geladen wird:

<CodeGroup>
  ```shell Shell theme={null}
  java -javaagent:/path/to/opentelemetry-javaagent.jar -jar your-application.jar
  ```
</CodeGroup>

Ersetzen Sie `/path/to/opentelemetry-javaagent.jar` durch den Pfad zum heruntergeladenen Agenten und `your-application.jar` durch den Pfad zur JAR-Datei Ihrer Anwendung.

### Gradle

Wenn Sie Gradle verwenden, können Sie den Agenten in der Datei `build.gradle` zu der Task hinzufügen, die Ihre Anwendung startet:

<CodeGroup>
  ```groovy title="build.gradle.kts" theme={null}
  tasks.bootRun {
      jvmArgs = listOf("-javaagent:/path/to/opentelemetry-javaagent.jar")
      // With any other configuration after
  }
  ```
</CodeGroup>

## Agenten konfigurieren

Der Agent kann über Java-Properties oder Umgebungsvariablen konfiguriert werden. Wir empfehlen die Verwendung von Umgebungsvariablen zur Konfiguration. Konfigurieren Sie den Agenten zunächst so, dass er Traces und Logs an den AppSignal-Collector exportiert:

<CodeGroup>
  ```shell Shell theme={null}
  # Export traces and metrics to the AppSignal collector using the OTLP protocol.
  # Replace `http://localhost:8099` with the address of your AppSignal collector
  # if it's running on another host.
  export OTEL_TRACES_EXPORTER=otlp
  export OTEL_METRICS_EXPORTER=otlp
  export OTEL_LOGS_EXPORTER=otlp
  export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
  export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:8099
  ```
</CodeGroup>

Konfigurieren Sie anschließend die von AppSignal benötigten OpenTelemetry-Resource-Attribute:

<CodeGroup>
  ```shell Shell theme={null}
  # Replace these values with your AppSignal application name, environment
  # and push API key. These are used by the resource attributes configuration below.
  APPSIGNAL_APP_NAME=your-app-name
  APPSIGNAL_APP_ENV=production
  APPSIGNAL_PUSH_API_KEY=your-push-api-key

  # Optionally, set a custom revision and hostname. If not set, the resource attributes
  # configuration below will use the current Git revision and system hostname.
  # REVISION=your-custom-revision
  # HOSTNAME=your-custom-hostname

  # 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.
  export OTEL_SERVICE_NAME=my-service-name

  export OTEL_RESOURCE_ATTRIBUTES="\
  appsignal.config.name=$APPSIGNAL_APP_NAME,\
  appsignal.config.environment=$APPSIGNAL_APP_ENV,\
  appsignal.config.push_api_key=$APPSIGNAL_PUSH_API_KEY,\
  appsignal.config.revision=${REVISION:-$(git rev-parse --short HEAD 2>/dev/null || echo unknown)},\
  appsignal.config.language_integration=java,\
  appsignal.config.app_path=$PWD,\
  host.name=${HOSTNAME:-$(hostname)}\
  "
  ```
</CodeGroup>

## Anwendung testen!

Nachdem nun alle Komponenten verbunden sind, starten Sie Ihre Anwendung mit den erforderlichen Umgebungsvariablen und prüfen Sie, ob Daten in AppSignal eintreffen. Sehen Sie sich 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) an.

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%20beta%20issue) und wir helfen Ihnen, Ihre OpenTelemetry-Installation abzuschließen!
