This guide provides step-by-step instructions for setting up OpenTelemetry (OTel) instrumentation in your Tomcat applications to enable comprehensive observability. OpenTelemetry is an open-source framework that helps you collect telemetry data—such as traces, metrics, and logs—from your app to monitor its performance and health.

Once your telemetry data is captured, you can configure an exporter to send it directly to Atatus for advanced monitoring and insights.

The process of setting up OpenTelemetry in Tomcat involves three key steps:

Instrumenting Your Tomcat Application: Add the necessary OpenTelemetry components to your Tomcat app for trace and metric collection.
Configuring the Exporter: Set up the exporter to send your telemetry data to Atatus.
Validating the Setup: Verify that the configuration is working and that your data is being correctly sent to Atatus.

Requirements

  • Java 8 or newer

Sending Telemetry Data to Atatus in Two Ways

Send Telemetry Traces to Atatus
Send Traces Using the OTel Collector Binary

Send Telemetry Traces to Atatus

  1. Download otel java binary agent

    wget https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar
    
    
  2. To run your .war package, place it in the webapps folder. Then, simply add a setenv.sh file in the bin folder of your Tomcat installation. This will configure the necessary environment variables and begin sending telemetry data to Atatus Cloud.

    export CATALINA_OPTS="$CATALINA_OPTS -javaagent:/path/to/opentelemetry-javaagent.jar"
    export OTEL_EXPORTER_OTLP_HEADERS="api-key=<ATATUS_INGESTION_KEY>"
    export OTEL_EXPORTER_OTLP_ENDPOINT=https://otel-rx.atatus.com
    export OTEL_RESOURCE_ATTRIBUTES=service.name=<app_name>
    

You can get the ATATUS_INGESTION_KEY from Settings -> Account Settings -> API Keys in Atatus dashboard.

Send Traces Using the OTel Collector Binary

To collect and send traces to Atatus, it's recommended to install the OpenTelemetry (OTel) Collector binary. The OTel Collector helps gather logs, host metrics, resource, and infrastructure attributes, enabling richer contextual data and easier signal correlation.

For detailed instructions on setting up the OTel Collector binary on your VM, please refer to the official installation guide. Once the Collector is up and running, you can proceed with instrumenting your Java application to start sending telemetry data to Atatus.

  1. Download otel java binary agent

    wget https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar
    
    
  2. To run your .war package, place it in the webapps folder. Then, simply add a setenv.sh file in the bin folder of your Tomcat installation. This will configure the necessary environment variables and begin sending telemetry data to Atatus Cloud.

    export CATALINA_OPTS="$CATALINA_OPTS -javaagent:/path/to/opentelemetry-javaagent.jar"