---
title: "How to get started with opentelemetry auto-instrumentation for java"
page_name: "How to get started with OpenTelemetry auto-instrumentation for Java"
type: "blog"
slug: "how-to-get-started-with-opentelemetry-auto-instrumentation-for-java"
published_at: "2022-03-31"
modified_at: "2025-05-09"
url: "https://www.sumologic.com/blog/how-to-get-started-with-opentelemetry-auto-instrumentation-for-java"
canonical: "https://www.sumologic.com/blog/how-to-get-started-with-opentelemetry-auto-instrumentation-for-java"
markdown_url: "https://www.sumologic.com/blog/how-to-get-started-with-opentelemetry-auto-instrumentation-for-java.md"
lang: "en"
excerpt: "Today I’m going to show you how to use a sample Java application called PetClinic to capture application traces using OpenTelemetry for Java auto-instrumentation and send them to Sumo Logic. Ask any Java developer: Spring is the most widely used web application framework and PetClinic is the most popular project in Spring. Thus the choice of the application as our demo subject."
taxonomy_blog_category:
  - "Application Observability"
  - "DevOps &amp; IT Operations"
  - "OpenTelemetry"
---

[ All blogs ](https://www.sumologic.com/blog "blog")[Application Observability](https://www.sumologic.com/blog/application-observability), [DevOps &amp; IT Operations](https://www.sumologic.com/blog/devops-it-operations), [OpenTelemetry](https://www.sumologic.com/blog/opentelemetry)

# How to get started with OpenTelemetry auto-instrumentation for Java

[Pawel Brzoska](#blog-author-block-252)

March 31, 2022

3 min read 

[Application Observability](https://www.sumologic.com/blog/application-observability), [DevOps &amp; IT Operations](https://www.sumologic.com/blog/devops-it-operations), [OpenTelemetry](https://www.sumologic.com/blog/opentelemetry)

##### Table of contents

 

 

 

## Read our quick tutorial on how to auto-instrument your application with OpenTelemetry based on Java Spring

If you’re new to [OpenTelemetry](https://www.sumologic.com/blog/opentelemetry-the-future-of-sumo-logic-observability/), like I was, you might be wondering how to quickly get started. OpenTelemetry is becoming the gold standard to collect all of your machine data and is changing observability as we know it. Instead of learning multiple technologies to collect all data, you can leverage a single cloud-native framework to complete your observability. OpenTelemetry is a collection of tools, APIs, and SDKs that you can use to instrument, generate, collect, and export all machine data, giving you visibility into every layer of the stack.

Today I’m going to show you how to use a sample Java application called PetClinic to capture application traces using [OpenTelemetry for Java auto-instrumentation](https://github.com/open-telemetry/opentelemetry-java-instrumentation) and send them to [Sumo Logic](https://help.sumologic.com/Traces/01Getting_Started_with_Transaction_Tracing). Ask any Java developer: Spring is the most widely used web application framework and [PetClinic](https://spring-petclinic.github.io/) is the most popular project in Spring. Thus the choice of the application as our demo subject. The source code of the example can be found here: [https://github.com/SumoLogic/opentelemetry-petclinic. ](https://github.com/SumoLogic/opentelemetry-petclinic)

The Dockerfile of PetClinic from the above URL already contains linked OpenTelemetry Java auto-instrumentation. If you are interested in learning how to add this to the original default Petclinic app— I recommend this [video.](https://sumo-logic.wistia.com/medias/p46o4kivj4)

Without further ado, let’s dive into what’s required to auto-instrument your application with OpenTelemetry.

## Get started by configuring the Sumo Logic OpenTelemetry endpoint

Before starting with the application, the tracing endpoint, where data is going to be sent, needs to be created. While this happens automatically for Kubernetes environments, where a Helm chart takes care of this, we need to do this manually for other environments like Docker, which we are going to use.

The Sumo Logic documentation describes how to set up Sumo Logic with OpenTelemetry in more detail [here](https://help.sumologic.com/Traces/01Getting_Started_with_Transaction_Tracing/Set_up_traces_collection_for_other_environments).

In my Sumo Logic account, I have created a new hosted collector, named it in a meaningful way and confirmed I want to add a new data source.

To ingest tracing data we should pick the *HTTP traces* data source.

During source creation, we need to copy the data source URL.

## Running the application

Switching back to the application repository, a quick look at the Dockerfile shows that there is already an OpenTelemetry Java agent jar file added to the image.

FROM springcommunity/spring-framework-petclinic
COPY opentelemetry-javaagent.jar /agent/opentelemetry-javaagent.jar 

Next, I build and run the application using Docker. I replaced the  with a URL I copied in the previous step and configured the service name and application name so they appear nicely on the Sumo Logic UI.

docker build -t opentelemetry-petclinic . 

export TRACES_URL=docker run –rm –name ot-petclinic -p 8080:8080
 –env JAVA\_TOOL\_OPTIONS=”-javaagent:/agent/opentelemetry-javaagent.jar”
 –env OTEL\_SERVICE\_NAME=petclinic-svc
 –env OTEL\_RESOURCE\_ATTRIBUTES=application=petclinic-app
 –env OTEL\_EXPORTER\_OTLP\_TRACES\_ENDPOINT=${TRACES\_URL}
 –env OTEL\_EXPORTER\_OTLP\_TRACES\_PROTOCOL=http/protobuf
 opentelemetry-petclinic

## Displaying the traces

The app is up and running, so now I need to trigger some traces. I’ve played a bit with that app at http://localhost:8080 to trigger trace collection. To check if traces are properly pushed to Sumo Logic, I logged into the Sumo Logic UI.

The best is to open a new tab (+ New button) and choose Traces. From there, I was able to use the search filter service.name=petclinic-svc to filter traces.

## **Summary**

This short blog shows how quickly you can set up tracing auto instrumentation with Sumo Logic. I’ve described how to create a new traces collection, instrument Java application, connect to the Sumo Logic receiver and verify that traces are present. Stay tuned for more quick and easy how-tos in future blogs.

If you are not yet a Sumo Logic [Application Observabiltiy](https://www.sumologic.com/solutions/application-monitoring/) customer and want to try this for yourself, signup [here](https://www.sumologic.com/sign-up/) and see how easy it is to auto-instrument your application with OpenTelemetry. You can also learn more in our comprehensive [guide to OpenTelemetry](https://www.sumologic.com/guides/opentelemetry/).

### Article Tags

- [Application Observability](https://www.sumologic.com/blog/application-observability)
- [DevOps &amp; IT Operations](https://www.sumologic.com/blog/devops-it-operations)
- [OpenTelemetry](https://www.sumologic.com/blog/opentelemetry)

Pawel Brzoska

Group Product Manager

Besides sailing and horseback riding, Pawel was always passionate about great user experience. He spent many years working hands-on with the biggest IT organizations in the world, understanding their problems and challenges with digital transformation to help them exceed their customers expectations by building monitoring and observability products that win the market. Pawel joined Sumo in summer 2019 and is busy since then with extending our platform to cover APM/tracing use cases.

[](https://www.sumologic.com/feed "RSS Feed")[](https://twitter.com/intent/tweet?text=How%20to%20get%20started%20with%20OpenTelemetry%20auto-instrumentation%20for%20Java&url=https%3A%2F%2Fwww.sumologic.com%2Fblog%2Fhow-to-get-started-with-opentelemetry-auto-instrumentation-for-java "X")[](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fwww.sumologic.com%2Fblog%2Fhow-to-get-started-with-opentelemetry-auto-instrumentation-for-java "Facebook")[](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fwww.sumologic.com%2Fblog%2Fhow-to-get-started-with-opentelemetry-auto-instrumentation-for-java "Linkedin")

[Previous blog

Mind your Single Sign-On (SSO) logs](https://www.sumologic.com/blog/mind-your-single-sign-on-sso-logs)[Next blog

What it means to be ‘in it’ with our customers every single day](https://www.sumologic.com/blog/what-it-means-to-be-in-it-with-our-customers-every-single-day)

People who read this also enjoyed

[  

Observability is security (We just pretended it wasn’t)

April 28, 2026

 

 ](https://www.sumologic.com/blog/observability-is-security)[  

Get more out of Sumo Logic: five log search hacks you’ll actually use

June 18, 2025

 

 ](https://www.sumologic.com/blog/five-log-search-hacks)[  

How to create and monitor an AWS Lambda function in Java 11

April 15, 2025

 

 ](https://www.sumologic.com/blog/how-to-write-aws-lambda-function-in-java8)[  

Elastic vs Sumo Logic: Build vs buy the right logging platform

December 10, 2024

 ](https://www.sumologic.com/blog/elastic-sumo-logic-build-or-buy)

[AI Instructions](https://www.sumologic.com/ai-instructions.md)
