githubEdit

Linux+Java Application Tracing

This guide is based on a Java application packaged with Maven. Please reference Otels documentation for different setups - Java zero-code instrumentationarrow-up-right

Install the collector

At the time of writing, the latest version of the OpenTelemetry Collector is 0.117.0

  1. Find the latest version of the OpenTelemetry collectors herearrow-up-right. In this guide we will install otelcol-contrib_0.117.0_linux_amd64

  2. Download and install

    1. Deb-based

      1. sudo apt-get update

      2. sudo apt-get -y install wget

      3. wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.117.0/otelcol-contrib_0.117.0_linux_amd64.deb

      4. sudo dpkg -i otelcol-contrib_0.117.0_linux_amd64.deb

    2. RHEL-based

      1. sudo dnf update -y

      2. sudo dnf install -y wget

      3. wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.117.0/otelcol-contrib_0.117.0_linux_amd64.rpm

      4. sudo rpm -ivh otelcol-contrib_0.117.0_linux_amd64.rpm

  3. Navigate to /etc/otelcol-contrib/

  4. Edit the config file with your favourite file editor, for example: nano config.yaml

  5. 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]

    1. Replace <your_domain> with the domain of your Ascent environment e.g company.apica.ioarrow-up-right

    2. Replace <your_token> with your ingest token (How to get your ingest tokenarrow-up-right)

  6. When you’ve finished editing the config, save it and run otelcol-contrib validate --config=config.yaml

    1. If you get no error returned, the config file is valid.

  7. Restart the service with sudo systemctl restart otelcol-contrib

  8. Verify that the service is up and running correctly with sudo systemctl status otelcol-contrib

Install and configure the Java agent

At the time of writing, the latest version of the Java agent is 2.11.0arrow-up-right

  1. Download the agent jar - opentelemetry-javaagent.jararrow-up-right

    1. wget https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v2.11.0/opentelemetry-javaagent.jar

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

Last updated

Was this helpful?