Prompt

How do I set up OpenTelemetry tracing across microservices?

Technology / Observability1 observationLast seen Oct 28, 2026

Latest observation

Oct 28, 2026OpenAI APIWeb search: off

To set up OpenTelemetry tracing across microservices, you want to do 4 things:

  1. Instrument each service
  2. Propagate trace context between services
  3. Export traces to a backend
  4. Standardize service naming, sampling, and correlation

Here’s a practical setup.


1) Pick an OpenTelemetry strategy

There are two common approaches:

  • Auto-instrumentation: quickest to start, minimal code changes.
  • Manual instrumentation: more control, better for custom spans and business events.

Most teams use:

  • auto-instrumentation for HTTP/gRPC/database calls
  • manual spans around important business operations

2) Add the OpenTelemetry SDK/agent to every service

Install the OpenTelemetry libraries for your language/runtime.

Examples:

  • Java: OpenTelemetry Java Agent
  • Node.js: @opentelemetry/sdk-node
  • Python: opentelemetry-sdk, instrumentations
  • .NET: OpenTelemetry packages
  • Go: OpenTelemetry SDK + instrumentation libs

Make sure each service sets:

  • service.name
  • service.version
  • deployment.environment

These become important in your trace backend.


3) Propagate trace context across service boundaries

This is the key part for “across microservices.”

OpenTelemetry uses standards like:

  • W3C Trace Context (traceparent, tracestate)
  • optional baggage headers

When Service A calls Service B, the trace context must be injected into outgoing requests and extracted on incoming requests.

Example flow

  • Request enters API Gateway / Service A
  • Trace starts there
  • Service A calls Service B with propagated headers
  • Service B continues the same trace
  • Any downstream DB/cache calls become child spans

If you use OTel auto-instrumentation, this propagation is usually handled automatically for supported frameworks and clients.


4) Send telemetry to an OpenTelemetry Collector

A very common architecture is:

Services → OpenTelemetry Collector → tracing backend

Why use the Collector?

  • central place to batch, retry, sample, and transform
  • avoids each app talking directly to your vendor
  • makes backend switching easier

Collector responsibilities

  • receive OTLP data
  • batch spans
  • apply sampling
  • export to backend such as:
    • Jaeger
    • Grafana Tempo
    • Honeycomb
    • Datadog
    • New Relic
    • Elastic
    • AWS X-Ray (via exporters)

5) Configure sampling

Tracing everything can be expensive at scale.

Common sampling options:

  • AlwaysOn: useful in dev
  • ParentBased + TraceIdRatioBased: common in prod
  • Tail-based sampling via Collector: keep traces based on latency/errors after seeing the whole trace

For microservices, tail-based sampling is often best if you want to keep:

  • slow traces
  • error traces
  • specific endpoints

6) Instrument inbound and outbound requests

You want spans for:

  • HTTP/gRPC server requests
  • HTTP/gRPC client calls
  • database queries
  • message queue publish/consume
  • cache calls
  • critical internal operations

A good trace usually shows:

  • API gateway span
  • service request spans
  • DB spans
  • queue spans
  • downstream service spans

7) Add logs correlation

Not strictly tracing, but very helpful.

Include trace IDs in logs so you can jump from a log line to a trace.

Typical fields:

  • trace_id
  • span_id
  • service.name

This makes debugging much easier.


8) Define conventions

Use consistent naming:

  • spans: short verb-noun names like GET /orders/{id} or process payment
  • attributes:
    • http.method
    • http.route
    • user.id only if safe
    • db.system
    • messaging.system

Avoid high-cardinality attributes unless needed.


9) Verify end-to-end propagation

Test with a request that crosses several services and confirm:

  • one trace ID across all services
  • parent/child span relationships are correct
  • errors appear on the right span
  • timestamps look reasonable

10) Minimal architecture example

Client
  ↓
API Gateway / Service A
  ↓
Service B
  ↓
Service C
  ↓
DB / Queue

All services send OTLP → OpenTelemetry Collector → Trace backend

Example: common environment variables

Many SDKs/agents can be configured with env vars:

OTEL_SERVICE_NAME=orders-service
OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317
OTEL_TRACES_EXPORTER=otlp
OTEL_PROPAGATORS=tracecontext,baggage
OTEL_TRACES_SAMPLER=parentbased_traceidratio
OTEL_TRACES_SAMPLER_ARG=0.1

Best practices

  • Use the Collector
  • Enable auto-instrumentation first
  • Set service.name consistently
  • Propagate context on every network hop
  • Correlate logs with trace IDs
  • Sample intelligently
  • Add custom spans only where they add value
  • Don’t record sensitive data in span attributes

Recommended rollout plan

  1. Instrument one service end-to-end
  2. Add the Collector
  3. Confirm trace propagation across one downstream service
  4. Roll out to all services
  5. Add custom spans for business-critical workflows
  6. Tune sampling and backend retention

If you want, I can give you a working setup example for:

  • Java Spring Boot
  • Node.js Express
  • Python FastAPI
  • Go
  • .NET
  • or a Docker Compose + OpenTelemetry Collector example for multiple microservices.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.