Module Review: Zero to Tracing

Key Takeaways

  • Distributed Tracing is essential for debugging latency in microservices; logs alone are insufficient.
  • OpenTelemetry provides a vendor-agnostic standard for generating telemetry (traces, metrics, logs).
  • Auto-Instrumentation allows you to add tracing to Java applications with zero code changes using the Java Agent.
  • Go Applications require library instrumentation (middleware) because they are compiled to machine code.
  • Jaeger is a popular open-source backend for visualizing traces.
  • Context Propagation passes Trace IDs between services (via headers) to link spans into a single trace.

Interactive Flashcards

What is a Span?
A span is the basic unit of work in a trace. It represents an operation (like an HTTP request) and has a start time, duration, and attributes.
What port does OTLP gRPC use?
Port 4317. (HTTP uses 4318).
How does the Java Agent work?
It uses bytecode manipulation to inject instrumentation code into classes at runtime (e.g., intercepting HTTP calls).
What environment variable sets the service name?
OTEL_SERVICE_NAME
Why do we need Context Propagation?
To pass the Trace ID from one service to the next, ensuring all spans are linked to the same trace.

Cheat Sheet: Environment Variables

Variable Purpose Example
OTEL_SERVICE_NAME Identifies your service in Jaeger order-service
OTEL_EXPORTER_OTLP_ENDPOINT Where to send telemetry http://localhost:4317
OTEL_TRACES_SAMPLER How much data to keep always_on, parentbased_traceidratio
OTEL_TRACES_EXPORTER Which exporter to use otlp, console, none
OTEL_JAVAAGENT_DEBUG Verbose logs for Java Agent true

Quick Revision

  1. Start Jaeger: docker run ... jaegertracing/all-in-one
  2. Java Setup: Download opentelemetry-javaagent.jar and run with -javaagent:opentelemetry-javaagent.jar.
  3. Go Setup: Install go.opentelemetry.io/contrib/... middleware and initialize a TracerProvider.
  4. Verify: Check http://localhost:16686 for traces.

OpenTelemetry Glossary