Set up distributed tracing
✓Works with OpenClaudeYou are a distributed systems engineer. The user wants to set up distributed tracing across microservices to track requests and identify bottlenecks.
What to check first
- Run
docker psto verify a tracing backend (Jaeger, Zipkin) is running on the expected port - Check
npm list opentelemetry-api opentelemetry-sdk-nodeto see if OpenTelemetry is installed - Confirm your service exports traces via
curl http://localhost:16686/api/traces(Jaeger endpoint)
Steps
- Install OpenTelemetry core packages:
npm install @opentelemetry/api @opentelemetry/sdk-node @opentelemetry/auto @opentelemetry/sdk-trace-node @opentelemetry/exporter-trace-otlp-http - Set the
OTEL_EXPORTER_OTLP_ENDPOINTenvironment variable to point to your collector:export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 - Import and initialize the tracing SDK at the very top of your entry file (before other imports) using
NodeSDKwith span processors - Install instrumentation packages for your specific frameworks:
npm install @opentelemetry/instrumentation-http @opentelemetry/instrumentation-express(or appropriate framework) - Register instrumentations when creating the
NodeSDKinstance via theinstrumentationsarray - Add baggage propagators to trace context across service boundaries using
CompositePropagatorwithW3CTraceContextPropagatorandJaegerBaggagePropagator - Configure the OTLP exporter with correct
headersandconcurrencyLimitfor your traffic volume - Test by making HTTP requests and checking the Jaeger UI at
http://localhost:16686for span traces
Code
// tracing.js - Import this FIRST in your entry file (index.js or app.js)
const { NodeSDK } = require('@opentelemetry/sdk-node');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-http');
const { BatchSpanProcessor } = require('@opentelemetry/sdk-trace-node');
const { W3CTraceContextPropagator, JaegerBaggagePropagator } = require('@opentelemetry/core');
const { CompositePropagator } = require('@opentelemetry/core');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const otlpExporter = new OTLPTraceExporter({
url: process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4318
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Monitoring & Logging Skills
Other Claude Code skills in the same category — free to download.
Structured Logging
Implement structured logging (Winston, Pino)
Error Tracking
Set up error tracking (Sentry)
APM Setup
Set up Application Performance Monitoring
Log Rotation
Configure log rotation and management
Health Dashboard
Create health monitoring dashboard
Alert Rules
Configure alerting rules and notifications
Metrics Collector
Implement custom metrics collection
Uptime Monitor
Set up uptime monitoring
Want a Monitoring & Logging skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.