> ## 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-installatie

Volg eerst de [installatiegids](/guides/new-application) wanneer u een nieuwe applicatie aan AppSignal toevoegt.

Zorg er vervolgens voor dat u de [AppSignal collector installeert](/collector/installation) voordat u verdergaat.

Om OpenTelemetry voor uw Java-applicatie te installeren en te configureren, raden wij u aan de OpenTelemetry Java-agent te gebruiken om gegevens naar de AppSignal collector te exporteren. Deze agent instrumenteert uw applicatie automatisch.

## De OpenTelemetry Java-agent downloaden

Download de OpenTelemetry Java-agent van de [laatste release op GitHub](https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar). Wanneer u uw applicatie uitvoert, moet de OpenTelemetry Java-agent aanwezig zijn.

## Voer uw applicatie uit met de agent

Wanneer u uw applicatie uitvoert, moet u de Java-runtime configureren om de OpenTelemetry Java-agent te laden. Pas de manier waarop u uw applicatie start aan om de OpenTelemetry Java-agent samen met uw applicatie te laden:

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

Vervang `/path/to/opentelemetry-javaagent.jar` door het pad naar de gedownloade agent en `your-application.jar` door het pad naar het JAR-bestand van uw applicatie.

### Gradle

Bij gebruik van Gradle kunt u de agent toevoegen aan de task die uw applicatie start in het bestand `build.gradle`:

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

## De agent configureren

De agent kan worden geconfigureerd met Java-properties of omgevingsvariabelen. Wij raden aan om omgevingsvariabelen te gebruiken voor de configuratie. Configureer de agent eerst om traces en logs te exporteren naar de AppSignal collector:

<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>

Configureer vervolgens de OpenTelemetry-resource-attributen die door AppSignal vereist worden:

<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>

## Test de app!

Nu alle componenten verbonden zijn, start u uw app met de vereiste omgevingsvariabelen en test u of u gegevens ziet binnenkomen in AppSignal. Bekijk in het bijzonder de pagina's ["Errors > Issue list"](https://appsignal.com/redirect-to/app?to=exceptions) en ["Performance > Traces"](https://appsignal.com/redirect-to/app?to=performance/traces).

Als u na het volgen van onze installatie-instructies nog steeds geen gegevens ziet in AppSignal, [laat het ons weten](mailto:support@appsignal.com?subject=OpenTelemetry%20beta%20issue) en wij helpen u om uw OpenTelemetry-installatie af te ronden!
