← CodeClarityLab Home
Browse by Category
+ added · updated 7d
← Back to glossary

Distributed Tracing

observability Intermediate

TL;DR

Distributed tracing tracks a request as it flows through multiple services — each service adds a span to a shared trace, giving end-to-end visibility into latency and failures.

Explanation

A trace represents one request journey. Each service adds a span (operation + timing). Spans link via trace ID + parent span ID propagated in headers (W3C Trace Context: traceparent header). Tools: Jaeger, Zipkin, Datadog APM, AWS X-Ray, Honeycomb. OpenTelemetry: the standard SDK for instrumentation. PHP: opentelemetry-php SDK, Laravel/Symfony integration. Key use: find where in a multi-service request the latency is — which service is slow, which DB query takes 2s. Without tracing, cross-service debugging requires correlating logs by timestamp — fragile and slow.

Common Misconception

Distributed tracing replaces logging — they're complementary. Traces show the request flow and where time is spent; logs show what happened within each service.

Why It Matters

Distributed tracing is the only way to efficiently debug latency issues in microservices — without it, finding which of 10 services is slow requires educated guessing.

Common Mistakes

  • Not propagating trace headers between services — breaks the trace chain.
  • 100% sampling in production — high volume, high cost. Use sampling.
  • Not adding custom attributes to spans — spans without context are hard to use.

Code Examples

✗ Vulnerable
// No trace propagation — broken traces:
$response = $httpClient->post('/api/orders', $data);
// No traceparent header passed — downstream sees a new root trace
✓ Fixed
// Propagate W3C trace context:
$response = $httpClient->post('/api/orders', $data, [
    'headers' => [
        'traceparent' => $tracer->getCurrentSpan()->getContext()->getTraceId(),
    ]
]);

// OpenTelemetry PHP:
$span = $tracer->spanBuilder('processOrder')->startSpan();
$span->setAttribute('order.id', $orderId);
try { processOrder(); }
finally { $span->end(); }

Added 23 Mar 2026
Views 89
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings W 0 pings T 0 pings F 0 pings S 5 pings S 1 ping M 0 pings T 0 pings W 0 pings T 1 ping F 0 pings S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T 2 pings F 2 pings S 0 pings S 0 pings M 0 pings T 1 ping W 0 pings T 2 pings F 1 ping S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T
No pings yet today
No pings yesterday
Google 38 Amazonbot 15 Perplexity 12 Unknown AI 3 Ahrefs 3 Majestic 2 ChatGPT 1
crawler 73 pre-tracking 1
DEV INTEL Tools & Severity
🟠 High ⚙ Fix effort: High
⚡ Quick Fix
Add OpenTelemetry SDK. Propagate W3C traceparent header in all HTTP/queue calls. Add custom span attributes for key IDs. Sample 5-10% in production.
📦 Applies To
web cli queue-worker Laravel Symfony
🔗 Prerequisites
🔍 Detection Hints
traceparent|X-B3-TraceId
Auto-detectable: ✗ No opentelemetry
🤖 AI Agent
Confidence: Low False Positives: High ✗ Manual fix Fix: High Context: File

✓ schema.org compliant