Linux+Java Application Tracing
Last updated
Was this helpful?
Last updated
Was this helpful?
This guide is based on a Java application packaged with Maven. Please reference Otels documentation for different setups -
At the time of writing, the latest version of the OpenTelemetry Collector is 0.117.0
Find the latest version of the OpenTelemetry collectors . In this guide we will install otelcol-contrib_0.117.0_linux_amd64
Download and install
Deb-based
sudo apt-get update
sudo apt-get -y install wget
wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.117.0/otelcol-contrib_0.117.0_linux_amd64.deb
sudo dpkg -i otelcol-contrib_0.117.0_linux_amd64.deb
RHEL-based
sudo dnf update -y
sudo dnf install -y wget
wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.117.0/otelcol-contrib_0.117.0_linux_amd64.rpm
sudo rpm -ivh otelcol-contrib_0.117.0_linux_amd64.rpm
Navigate to /etc/otelcol-contrib/
Edit the config file with your favourite file editor, for example: nano config.yaml
Paste the following into the config file overwriting it completely:
receivers: otlp: protocols: grpc: endpoint: localhost:4317 http: endpoint: localhost:4318 processors: batch: exporters: otlphttp: traces_endpoint: https://<your_domain>/v1/json_batch/otlptraces encoding: json compression: gzip headers: Authorization: "Bearer <your_token>" tls: insecure: false insecure_skip_verify: true service: pipelines: traces: receivers: [otlp] processors: [batch] exporters: [otlphttp]
Replace <your_domain> with the domain of your Ascent environment e.g
Replace <your_token> with your ingest token ()
When you’ve finished editing the config, save it and run otelcol-contrib validate --config=config.yaml
If you get no error returned, the config file is valid.
Restart the service with sudo systemctl restart otelcol-contrib
Verify that the service is up and running correctly with sudo systemctl status otelcol-contrib
wget https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v2.11.0/opentelemetry-javaagent.jar
Run Your Application with the Agent: Add the agent as a JVM option when starting your application:
java -javaagent:/path/to/opentelemetry-javaagent.jar \ -Dotel.exporter.otlp.endpoint=http://localhost:4317 \ -Dotel.exporter.otlp.protocol=grpc \ -Dotel.traces.exporter=otlp \ -Dotel.metrics.exporter=none \ -Dotel.service.name=your-java-app \ -Dotel.resource.attributes=environment=production \ -jar your-app.jar
Depending on the amount of traces generated, you can pretty quickly verify that traces is passing through to Ascent by navigating to Explore > Distributed Tracing and in the dropdown Service you will after a short while see your application appear.
In this case, the service name “your-java-app” would show up as a Service.
At the time of writing, the latest version of the Java agent is
Download the agent jar -