How to Use Datadog Distributed Tracing for Faster RCA

Datadog Distributed Tracing for Faster Root Cause Analysis

Written by: Nimesh Chakravarthi, Co-founder & CTO, Struct | Last updated: October 11, 2026

Key Takeaways

  • Datadog distributed tracing isolates slow or failing spans in Trace Explorer, then confirms the hypothesis with correlated logs, metrics, and deployment evidence before you act.
  • The five-step workflow of detecting the symptom, opening Trace Explorer, finding the suspicious span, correlating logs and metrics, and validating with non-trace signals gives on-call engineers defensible root causes without senior escalation.
  • Broken traces from missing headers, uninstrumented services, or sampling issues need context propagation fixes and retention filter changes before you regain full visibility.
  • Datadog Watchdog and Bits AI surface anomalies and correlations, and manual investigation takes over when traces are incomplete or the slow span is a downstream victim.
  • Struct turns the manual Datadog investigation workflow into an automated loop that reads every PR, creates monitors, triages alerts, and delivers cited root causes with fix PRs attached.

Watch Struct triage your next alert

How Do You Use Datadog Distributed Tracing For Faster Root Cause?

Start by opening Trace Explorer and filtering to the slow or failing service. From there, find the span whose duration changed; that span becomes your hypothesis. Before you open a fix PR, correlate logs and metrics against that span and confirm the cause with at least one non-trace signal. The trace tells you where to look. Non-trace evidence tells you what is wrong.

The five-step workflow:

  1. Detect the symptom in Datadog APM. A p95 latency alert fires or an SLO burn-rate alert triggers. Note the service, endpoint, and time window.
  2. Open the trace in Trace Explorer. Filter to the affected service and environment. Use duration and status predicates to surface the worst requests.
  3. Find the suspicious span. Read the flame graph and waterfall. Identify the span whose duration changed by an order of magnitude compared with a healthy trace.
  4. Correlate logs and metrics. Pivot from the span ID to correlated logs, then check database or downstream service metrics in the same window.
  5. Validate and verify the fix. Confirm the suspected cause with at least one non-trace signal, such as a query plan, connection-pool metric, or deployment diff, before opening a fix PR.

Three instrumentation preconditions make this workflow reliable. Unified service tagging, with consistent service, env, and version tags across traces, metrics, and logs, is the prerequisite for correlating signals across Datadog products. Trace-log correlation requires those tags plus trace context injected into application logs. Deployment tracking in Datadog surfaces the version tag on every span so you can diff behavior across releases.

The Worked Incident: P95 Spike In Order-Service

The five-step workflow is easier to follow in practice. Here is how it plays out when a p95 latency alert fires on order-service in production and the dashboard is green.

Step 1 — Open Trace Explorer and filter. Datadog Trace Explorer distinguishes tag queries from attribute queries. Environment and service filters are tag queries written without the @ prefix. Duration and status are attribute queries written with it. Start with duration before status because duration surfaces slow requests regardless of whether they errored. The p95 spike may be latency without errors:

service:order-service env:prod @duration:>500ms

Then add a status filter to find the subset that also errored:

service:order-service env:prod @status:error

Datadog's documented practice is to apply environment and service tags as scope filters first, then narrow with error, duration, or custom-attribute predicates. A trace search matches only the root span. A span search matches any nested child span. If the slow operation is a database call three levels deep, switch to span search to find it.

Step 2 — Read the flame graph. The flame graph shows where time is spent, and four span shapes reveal whether that time is real cost or a symptom. Read them in this order:

  • Wide span: time actually spent in that operation. A wide postgres.query span is a real cost.
  • Deep span: call depth. Depth alone does not equal cost. A chain of fast spans is fine.
  • Repeated span: the same operation called many times in a loop. This is the N+1 signature, with dozens of narrow SELECT spans where one query should appear.
  • Critical path vs. slowest span: the slowest span often acts as a victim, not the cause. A downstream span waiting on a lock shows as slow while the real cause is upstream. Diff spans systematically instead of eyeballing the graph.

Step 3 — Compare a healthy trace to the slow trace. Pull a healthy trace from the same service, endpoint, and time window, ideally the same hour and day of week if traffic is seasonal. Diff span durations side by side. Look for the span whose duration changed by an order of magnitude. In this incident, the postgres.query span on the order-service inventory lookup was dramatically slower in the slow trace than in the healthy trace. That span becomes the working hypothesis.

For correlation mechanics, see How To Do Effective Trace Analysis In Datadog APM.

Step 4 — Pivot to logs and metrics. Use Datadog trace-log correlation to pull the logs generated during the slow span. Click the span, copy the span ID, and filter Log Management to that ID. In the order-service incident, the logs showed connection pool exhaustion across all 956 failure events. The error read “connection pool exhausted, no connection available after 250ms,” and the attributes confirmed it: error.kind was pool_timeout, the pool size was 8, and zero connections were available. Next, check the database metrics in the same window. Connection pool saturation sits at 98 percent, and lock-wait time has spiked.

Three span-level signatures matter here:

  • Database bottleneck: one wide query span, high CPU or I/O on the database host metric, and slow query log entries.
  • Lock contention: query span duration is variable and correlated with concurrent write traffic. Lock-wait metrics confirm the pattern.
  • Connection-pool exhaustion: many short spans with connection-acquisition errors in logs and a pool saturation metric at or near the ceiling.

For correlation mechanics, see How To Correlate Logs And Traces For Better Observability.

Stop firefighting. Start shipping.

Validating The Suspected Cause Before You Act

The Datadog trace generates the hypothesis, and non-trace evidence confirms or rejects it. Hold the fix PR until at least one non-trace signal agrees with the trace.

In the order-service incident, the hypothesis is connection-pool exhaustion. Three non-trace signals can confirm or reject it, and each checks a different layer of the stack: query execution, database resource pressure, and recent code changes. If all three agree, the hypothesis is defensible:

  1. Query plan: run EXPLAIN ANALYZE on the slow query. A sequential scan on a large table confirms a missing index is forcing full-table reads and holding connections longer.
  2. Database metrics: pool saturation and lock-wait duration spike in the same window as the p95 alert. The 98 percent saturation noted earlier supports the connection-pool hypothesis.
  3. Deployment diff: Datadog deployment tracking can surface a recent deploy before the alert. The order-service deployment diff included a handler query inserting into orders.customer_email and orders.total_amount. The database schema in cmd/initdb/main.go only created amount and status. There was no corresponding schema migration.

The classic false root cause appears when the slowest span acts as a victim instead of the cause. A downstream service waiting on a lock appears slow while the real cause is the upstream write holding the lock. In this incident, the order-service query span was slow because a hidden N+1 query ran inside an open transaction. That lazy-loaded loop held each HikariCP connection for the full five-second loop while the pool of ten was exhausted. The missing index is the fix, not the connection pool size.

The rule is simple: one non-trace signal must agree with the trace before you act.

When The Trace Is Broken: Fixing Missing Spans And Context Propagation

The workflow above assumes the trace is complete. When it is not, the investigation stalls before it starts. Practitioners on r/sre describe this pattern with consistent vocabulary: “the trace is broken,” “spans are missing,” “propagation isn't working.” The failure is silent. A service that drops the propagation header does not error. It starts a new trace, and you get two tidy-looking traces that each appear complete.

Datadog's context propagation documentation specifies the mechanism. The x-datadog-trace-id header carries the lower 64 bits of the trace ID as a decimal value. The x-datadog-parent-id header carries the current 64-bit span ID, also as a decimal value. At each service boundary, the trace ID stays constant while the parent ID identifies the upstream span. If either header is missing or stripped by a proxy, load balancer, or uninstrumented middleware, the downstream service starts a new trace instead of continuing the existing one.

Three causes of broken traces and their fixes:

  • Missing or stripped headers: verify that automatic instrumentation is active, that HTTP, RPC, and message-client instrumentation injects headers on outbound calls, and that intermediate proxies preserve them. Standardize on W3C Trace Context with Datadog compatibility and add propagation middleware to every service boundary.
  • Uninstrumented services and async workers: an async worker that drops context produces a disconnected downstream trace. Carry context manually in message metadata and restore it in the consumer's active tracing context. Queues and async boundaries are where context most commonly gets lost.
  • Sampling configuration: head-based sampling decides at the entry point and can drop the exact trace you need during an incident. Datadog's retention filters determine what you can still query after the fact. During an active incident, raise sampling temporarily or configure retention filters to keep error and high-latency traces. Datadog's Intelligent Retention automatically prioritizes traces that contain errors or unusual latency, and explicit retention filters give you control.

Set up your AI prod engineer in about 10 minutes

Datadog Watchdog Vs. Manual Trace Investigation: When To Trust Automated Insights

Datadog's Bits Investigation runs a continuous observation-and-reasoning loop. It forms root-cause hypotheses, queries telemetry to validate or reject them, and either produces an evidence-backed conclusion or explicitly marks the investigation inconclusive when available data is insufficient. Watchdog analyzes metric time series for spikes, dips, gradual drifts, and step changes, groups anomalies into issues, and identifies influential tags.

Automated insights work best for anomaly surfacing and correlated-signal discovery. Watchdog and Bits AI excel at finding anomalies you did not know to look for and correlating signals across services. Use them as a starting point.

Manual investigation still matters in three situations:

  • The trace is broken and spans are missing or propagation failed. Automated tools reason over the telemetry they can see, and a disconnected trace gives them an incomplete picture.
  • The anomaly is a downstream victim of an upstream cause. Automated insights surface the symptom, and span-level reasoning identifies whether the slow span is the cause or a downstream effect.
  • Bits Investigation accuracy depends on the quality of organizational context supplied, including monitor messages, runbooks, and prior feedback. When that context is thin, the investigation may be marked inconclusive and manual investigation is required.

For a full treatment of Watchdog mechanics, see How Datadog Watchdog Automated Root Cause Analysis Works.

Where Datadog Tracing Stops And Struct Picks Up

Even with Watchdog and Bits AI, the investigation workflow remains manual. Struct is the AI prod engineer that sits on top of Datadog and automates the loop. Monitors Struct creates live in your own Datadog account, where they are free.

The five-step investigation workflow above is manual. Struct turns it into an owned, self-healing loop by handling each stage of the investigation, from monitor creation to fix PR, automatically:

  • PR-intent monitors: Struct reads every PR to understand what changed, then creates the monitors that change needs and baselines them after deploy. The p95 spike in the worked incident, caused by a new unindexed query, is caught before a customer reports it and traced to the exact PR that introduced it.
  • Alert triage: every alert, whether Struct's or pre-existing in Datadog, is triaged as dismissed, retuned, or escalated. What reaches Slack arrives with a cited root cause and suggested fix.
  • Cited investigation: Struct correlates code, logs, traces, metrics, and exceptions into a cited timeline, with p50 time-to-root-cause under four minutes. Every claim links to its evidence with a confidence score and the full investigation path.
  • Auto-fix: when confident, Struct opens the fix PR or hands full context to your coding agent. Resolution is then verified against live telemetry.
  • Setup: setup takes about 10 minutes against GitHub, Slack, and Datadog or Sentry. SOC 2 Type II and HIPAA compliant; data never used for training. Shadow mode runs silently next to your real alert channel for one week, with nothing rerouted and no charge.

One named proof point: Arcana investigates every Sentry alert with no exceptions and cut investigation time from 30 minutes to 2 minutes.

“We investigate every Sentry alert — no exceptions. Struct made that sustainable by eliminating manual triage. Senior engineers got their time back for higher-leverage work, and the broader team adopted it without friction.” — Siva Visakan Sooriyan, CTO, Arcana

Frequently Asked Questions (FAQ)

What Do I Do If My Datadog Trace Is Missing Spans?

Start with context propagation. Verify that x-datadog-trace-id and x-datadog-parent-id are present on outbound requests at every service boundary and that intermediate proxies are not stripping them. If propagation headers are intact, check for uninstrumented services. Any service in the call chain that lacks Datadog APM instrumentation will start a new trace rather than continue the existing one. For async workers and message queues, carry context manually in message metadata and restore it in the consumer. Finally, check sampling configuration. Head-based sampling can drop the exact trace you need during an incident. Configure retention filters to keep error and high-latency traces, or raise sampling temporarily while the incident is active.

How Do I Compare A Healthy Trace To A Slow Trace In Datadog?

Pull both traces from the same service, endpoint, and time window, ideally the same hour and day of week if traffic patterns are seasonal. Diff span durations side by side in a structured way instead of eyeballing the graph. The span whose duration changed by an order of magnitude becomes the hypothesis. A healthy postgres.query span that is dramatically faster than the slow one is a clear signal. Confirm the critical path. A downstream span waiting on a lock appears slow while the real cause is upstream. Systematic diffing surfaces the actual change. Eyeballing surfaces the most visually prominent span, which is often a victim.

When Should I Trust Datadog Watchdog Instead Of Investigating Manually?

Trust Watchdog and Bits AI for anomaly surfacing and correlated-signal discovery, especially when you need signals you did not know to look for across services and time windows. Investigate manually when the trace is broken or spans are missing, because automated tools reason over the telemetry they can see and a disconnected trace gives them an incomplete picture. Also investigate manually when the anomaly is likely a victim of an upstream cause. Automated insights surface the symptom, and span-level reasoning is required to determine whether the slow span is the cause or a downstream effect of something upstream. Bits Investigation will explicitly mark an investigation inconclusive when available data is insufficient, and that signal tells you to take over manually.

Does Struct Replace Datadog?

Struct does not replace Datadog. Struct sits on top of Datadog as the engineer who uses it. Monitors Struct creates live in your own Datadog account, where they are free. Struct reads every PR to create the monitors that change needs, baselines them after deploy, triages every alert, and root-causes what breaks. Datadog provides the telemetry. Struct provides the maintenance loop and the investigation that turns that telemetry into a cited root cause and a fix PR.

Conclusion: The Trace Is A Hypothesis Generator

The five-step Datadog investigation workflow above gives on-call engineers a repeatable path from alert to defensible root cause. The editorial spine holds throughout: the trace tells you where to look, and non-trace evidence tells you what is wrong. Hold the fix PR until at least one non-trace signal agrees with the trace.

Logical next topics from here include alert design and tuning to reduce the noise that obscures real incidents, incident postmortems that encode investigation paths as runbooks, and deploy health checks that catch regressions before customers do.

Struct turns the manual investigation sequence above into an owned loop by reading every PR, creating the monitors that change needs, triaging every alert, and delivering a cited root cause with a fix PR attached. Shadow mode runs silently next to your real Datadog alert channel for one week, with nothing rerouted and no charge.

See Struct handle your next production incident in shadow mode

Read Next