Getting Started with OpenTelemetry and VMware Tanzu Observability

September 21, 2021 Sri Harsha Yayi

Modern application architectures are complex, typically consisting of hundreds of distributed microservices implemented in different languages and by different teams. As a developer, SRE, or DevOps engineer, you are responsible for the reliability and performance of these complex systems. But while you might have metrics that will help you debug when there’s an issue, metrics alone can’t help you narrow down and ultimately identify the root cause. 

With observability, you can ask questions about your system and get answers based on the telemetry data (metrics, traces, and logs) they produce. The tracing capabilities of VMware Tanzu Observability can help you pinpoint the root cause of failures and identify performance bottlenecks by analyzing every request moving across the various services. 

So, using Tanzu Observability, how do we go about instrumenting our services to emit trace data? In addition to it supporting various instrumentation and ingestion methods for distributed tracing, Tanzu Observability now natively supports OpenTelemetry.

Support for OpenTelemetry

A new industry standard that merges OpenTracing and OpenCensus projects to offer a complete telemetry system for monitoring distributed systems, OpenTelemetry provides a set of APIs, SDKs, and integrations for collecting and exporting metrics, traces, and logs generated by your distributed microservices so they can be monitored and analyzed.

You can configure an application to send trace data to Tanzu Observability using the OpenTelemetry collector together with our new Tanzu Observability traces exporter

Let's explore how to get started with OpenTelemetry and Tanzu Observability without manually instrumenting your Java application. We can get you there in three simple steps.

Before we get started, you will need the following:

Once you have all of those components, take the following steps.

Install Wavefront proxy

Configure your Tanzu Observability (Wavefront) URL and the token. (If you’ve signed up for the free trial, here’s how you can get your token.)

   docker run -d \
      -e WAVEFRONT_URL=https://{CLUSTER}.wavefront.com/api/ \
      -e WAVEFRONT_TOKEN={TOKEN} \
      -e JAVA_HEAP_USAGE=512m \
      -e WAVEFRONT_PROXY_ARGS="--customTracingListenerPorts 30001" \
      -p 2878:2878 \
      -p 30001:30001 \
      wavefronthq/proxy:latest

Install the OpenTelemetry Collector

Next, you’ll need to install the OpenTelemetry Collector. 

  1. Download the binary from the latest release of the OpenTelemetry Collector project and add it to a preferred directory.  

  2. In the same directory, create the otel_collector_config.yaml file and copy the below configuration to the yaml file. (Learn more about OpenTelemetry collector configuration.)

    receivers:
       otlp:
          protocols:
              grpc:
                  endpoint: "localhost:4317"
    exporters:
        tanzuobservability:
          traces:
            endpoint: "http://localhost:30001" 
      # Proxy hostname and customTracing ListenerPort
    processors:
        batch:
          timeout: 10s
          
    service:
        pipelines:
          traces:
            receivers: [otlp]
            exporters: [tanzuobservability]
            processors: [batch]
  3. Navigate to the directory from your console and run the collector host with the config file using --config parameter and the command

     ./otelcontribcol_darwin_amd64 --config otel_collector_config.yaml

Auto-instrument the application

For instrumentation, we will use the Java agent provided by OpenTelemetry, which can be attached to any Java application. This agent will dynamically inject bytecode to collect telemetry data so that you don’t need to add any manual instrumentation. 

  1. Download the sample application and navigate to the directory.

  git clone https://github.com/wavefrontHQ/otel-demo-app-java
  cd otel-demo-app-java
  1. Run mvn clean install from the root directory of the project.

  2. Download the OpenTelemetry Java agent.

  3. Attach the Java agent and start the services independently by executing the following commands.

    java -javaagent:<path to otel agent> \
    -Dotel.resource.attributes=service.name=styling \
    -Dotel.metrics.exporter=none \
    -jar ./styling/target/styling-1.0-SNAPSHOT.jar

    java -javaagent:<path to otel agent> \
    -Dotel.resource.attributes=service.name=shopping \
    -Dotel.metrics.exporter=none \
    -jar ./shopping/target/shopping-1.0-SNAPSHOT.jar

    java -javaagent:<path to otel agent> \
    -Dotel.resource.attributes=service.name=delivery \
    -Dotel.metrics.exporter=none \
    -jar ./delivery/target/delivery-1.0-SNAPSHOT.jar

  1. Interact with your application to generate traces. For the sample application we’ve shared here, running the command below from the root directory will send requests to services every 10 seconds.

  ./loadgen.sh 10

When the trace data collected from the OpenTelemetry collector are ingested, you can examine them in the Tanzu Observability user interface. Tanzu Observability gives you end-to-end visibility into the chain across services, even when those services are running in different environments. We enrich this trace data with application maps to help you understand interdependencies and the overall health of your application for faster root cause analysis. 

From the Applications menu, you can access the out-of-the-box service dashboard that provides a health overview at a service level.


You can examine the traces using the Trace viewer page.

To see Tanzu Observability in action, watch this replay from our SpringOne 2021 keynote showing an example of how a team can use it to get to the bottom of an application incident.

Try it out!

The distributed tracing capabilities of VMware Tanzu Observability give you a single, concise view into your distributed systems, but it’s achievable only if you instrument your applications for distributed tracing. The good news is that OpenTelemetry provides a standard set of APIs and libraries for instrumenting our systems, and provides the foundation for auto-instrumentation of applications across languages and frameworks.

There’s much more to the Tanzu Observability platform, but hopefully we’ve piqued your interest enough so that you follow the prescribed steps to auto-instrument your Java application and install Tanzu Observability in order to experience it for yourself. Learn more or ask questions by joining the Tanzu Observability public Slack group

Previous
VMware Tanzu Application Service Certified to Run on Azure VMware Solution
VMware Tanzu Application Service Certified to Run on Azure VMware Solution

VMware Tanzu Application Service versions 2.7 through 2.11 are now fully certified with the Azure VMware So...

Next
How to Write User Stories Without Users
How to Write User Stories Without Users

We can still write valuable stories—we just have to reframe our idea of user value. And that means redefini...