---
title: Synthetic APM
description: APM and Distributed Tracing with Synthetic Monitoring
breadcrumbs: Docs > Synthetic Testing and Monitoring > Platform > Synthetic APM
---

# Synthetic APM

{% video
   url="https://datadog-docs.imgix.net/images/synthetics/apm/synthetics-apm.mp4" /%}

## Overview{% #overview %}

The APM integration with Synthetic Monitoring allows you to go from a test run that potentially failed to the root cause of the issue by looking at the trace generated by that test run.

Having network-related specifics (thanks to your test) as well as backend, infrastructure, and log information (thanks to your trace) allows you to access a new level of details about the way your application is behaving, as experienced by your user.

## Usage{% #usage %}

Statements on this page apply to [HTTP API tests](https://docs.datadoghq.com/synthetics/api_tests/http_tests/?tab=requestoptions), [Multistep API tests](https://docs.datadoghq.com/synthetics/multistep?tab=requestoptions), and [browser tests](https://docs.datadoghq.com/synthetics/browser_tests/) for APM.

### Prerequisites{% #prerequisites %}

- Your service, and the endpoint your test is running on, is [traced on the APM side](https://docs.datadoghq.com/tracing/).
- Your service uses an HTTP server.
- Your HTTP server is using a library that supports distributed tracing.

Create a test that hits your traced HTTP server, and Datadog automatically links the trace generated by your server to the corresponding test result.

To link browser test results, allow the URLs you want the APM integration headers added to. You can do this in [Synthetic Settings](https://app.datadoghq.com/synthetics/settings/integrations). Use `*` for wildcards:

```text
https://*.datadoghq.com/*
```

## Supported libraries{% #supported-libraries %}

The following Datadog tracing libraries are supported:

| Library                                                                               | Minimum Version                                                           |
| ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| [Python](https://docs.datadoghq.com/tracing/trace_collection/dd_libraries/python/)    | [0.50.4](https://github.com/DataDog/dd-trace-py/releases/tag/v0.50.4)     |
| [Go](https://docs.datadoghq.com/tracing/trace_collection/dd_libraries/go/)            | [1.10.0](https://github.com/DataDog/dd-trace-go/releases/tag/v1.10.0)     |
| [Java](https://docs.datadoghq.com/tracing/trace_collection/dd_libraries/java/)        | [0.24.1](https://github.com/DataDog/dd-trace-java/releases/tag/v0.24.1)   |
| [Ruby](https://docs.datadoghq.com/tracing/trace_collection/dd_libraries/ruby/)        | [0.20.0](https://github.com/DataDog/dd-trace-rb/releases/tag/v0.20.0)     |
| [Node.js](https://docs.datadoghq.com/tracing/trace_collection/dd_libraries/nodejs/)   | [0.10.0](https://github.com/DataDog/dd-trace-js/releases/tag/v0.10.0)     |
| [PHP](https://docs.datadoghq.com/tracing/trace_collection/dd_libraries/php/)          | [0.33.0](https://github.com/DataDog/dd-trace-php/releases/tag/0.33.0)     |
| [.NET](https://docs.datadoghq.com/tracing/trace_collection/dd_libraries/dotnet-core/) | [1.18.2](https://github.com/DataDog/dd-trace-dotnet/releases/tag/v1.18.2) |

### How are traces linked to tests?{% #how-are-traces-linked-to-tests %}

Datadog uses the distributed tracing protocol and sets up the following HTTP headers:

{% tab title="Datadog" %}

{% dl %}

{% dt %}
`x-datadog-trace-id`
{% /dt %}

{% dd %}
Generated from the Synthetic Monitoring backend. Allows Datadog to link the trace with the test result.
{% /dd %}

{% dt %}
`x-datadog-parent-id: 0`
{% /dt %}

{% dd %}
To have Synthetic tests be the root span of the generated trace.
{% /dd %}

{% dt %}
`x-datadog-origin: synthetics`
{% /dt %}

{% dd %}
To identify generated traces from your API tests. Spans from these traces are tagged with `ingestion_reason:synthetics`.
{% /dd %}

{% dt %}
`x-datadog-origin: synthetics-browser`
{% /dt %}

{% dd %}
To identify generated traces from your Browser tests. These traces are tagged with `ingestion_reason:synthetics-browser`.
{% /dd %}

{% dt %}
`x-datadog-sampling-priority: 1`
{% /dt %}

{% dd %}
To make sure that the Agent keeps the trace.
{% /dd %}

{% /dl %}

{% /tab %}

{% tab title="W3C Trace Context" %}

{% dl %}

{% dt %}
`traceparent: [version]-[trace id]-[parent id]-[trace flags]`
{% /dt %}

{% dd %}
`version`: The specification assumes version is set to `00`.
{% /dd %}

{% dd %}
`trace id`: 128 bits trace ID, hexadecimal on 32 characters. The source trace ID is 64 bits to maintain compatibility with APM.
{% /dd %}

{% dd %}
`parent id`: 64 bits span ID, hexadecimal on 16 characters.
{% /dd %}

{% dd %}
`trace flags`: Sampled (`01`) or not sampled (`00`)
{% /dd %}

{% dt %}
**Example**:
{% /dt %}

{% dd %}
`traceparent: 00-00000000000000008448eb211c80319c-b7ad6b7169203331s-01`
{% /dd %}

{% /dl %}

{% /tab %}

### How long are traces retained?{% #how-long-are-traces-retained %}

These traces are retained for 15 days with the `Synthetics Default` retention filter, [just like your classical APM traces](https://docs.datadoghq.com/tracing/trace_pipeline/trace_retention/).

## Further Reading{% #further-reading %}

- [Introducing Datadog Synthetic Monitoring](https://www.datadoghq.com/blog/introducing-synthetic-monitoring/)
- [APM and Distributed Tracing](https://docs.datadoghq.com/tracing/)
- [Ease troubleshooting with cross product correlation.](https://docs.datadoghq.com/logs/guide/ease-troubleshooting-with-cross-product-correlation/)
