---
schema_version: "1"
id: c5263224b67990a5d977561b3edce97d9349f0545db459e109b4d73124b03406
title: Tracing Policy
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/gateway/1.12/policies-included-tracing.md
canonical_url: https://docs.mulesoft.com/gateway/1.12/policies-included-tracing
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 0598549b9d780b8a672707b9ba162d00beb3d70c64c951bcffa00bfa35d41927
description: MuleSoft Documentation Site
release: "1.12"
latest: false
---
---
product: Omni Gateway
version: 1.12
keywords: api gateway, flex gateway, gateway, policy, otel, otel support, OpenTelemetry, distributed tracing
---

# Tracing Policy

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

<table><colgroup><col> <col></colgroup><tbody><tr><td><p><strong>Policy Name</strong></p></td><td><p>Tracing</p></td></tr><tr><td><p><strong>Summary</strong></p></td><td><p>Override global tracing configuration</p></td></tr><tr><td><p><strong>Category</strong></p></td><td><p>Troubleshooting</p></td></tr><tr><td><p><strong>First Flex Gateway version available</strong></p></td><td><p>1.10.0</p></td></tr><tr><td><p><strong>Returned Status Codes</strong></p></td><td><p>No return codes exist for this policy</p></td></tr></tbody></table>

## Summary

The Tracing policy enables you to override the global distributed tracing parameters for an API.

## Before You Begin

Distributed tracing is disabled by default. After you have enabled distributed tracing with a Flex
Gateway global configuration, you can use this policy to override the global distributed tracing
parameters for an API.

For details on how to enable distributed tracing, see:

- [Configuring Flex Gateway Distributed Tracing in Local Mode](https://docs.mulesoft.com/gateway/1.12/flex-local-tracing-config)

- [Configuring Flex Gateway Distributed Tracing in Connected Mode](https://docs.mulesoft.com/gateway/1.12/flex-conn-tracing-config)

- [Configuring Distributed Tracing for Managed Flex Gateway](https://docs.mulesoft.com/gateway/1.12/flex-managed-tracing-config)

## Configuring Policy Parameters

### Flex Gateway Local Mode

When you apply the policy via declarative configuration files, Refer to the following policy
definition and table of parameters:

\- policyRef: name: tracing-flex config: sampling: client: number // REQUIRED random: number //
REQUIRED overall: number // REQUIRED spanName: <string> // OPTIONAL labels: <array> // OPTIONAL,
default: \[\] - name: <string> // REQUIRED type: <string> // REQUIRED keyName: <string> // REQUIRED
defaultValue: <string> // REQUIRED

<table><colgroup><col> <col> <col> <col></colgroup><thead><tr><th>Parameter</th><th>Required or Optional</th><th>Default Value</th><th>Description</th></tr></thead><tbody><tr><td><div><div><p><code>sampling.client</code></p></div></div></td><td><div><div><p>Required</p></div></div></td><td><div><div><p>100</p></div></div></td><td><div><div><p>The target percentage of requests that are force traced if the <code>x-client-trace-id</code> header is set.</p></div></div></td></tr><tr><td><div><div><p><code>sampling.random</code></p></div></div></td><td><div><div><p>Required</p></div></div></td><td><div><div><p>100</p></div></div></td><td><div><div><p>The target percentage of requests that are randomly selected for trace generation, if not requested by the client or not forced.</p></div></div></td></tr><tr><td><div><div><p><code>sampling.overall</code></p></div></div></td><td><div><div><p>Required</p></div></div></td><td><div><div><p>100</p></div></div></td><td><div><div><p>The target percentage of requests that are traced after all other sampling checks have been applied, such as client-directed, force tracing, and random sampling.</p></div></div></td></tr><tr><td><div><div><p><code>spanName</code></p></div></div></td><td><div><div><p>Optional</p></div></div></td><td><div><div><p>N/A</p></div></div></td><td><div><div><p>The name of the span. If no span name is configured, the API name is used.</p></div></div></td></tr><tr><td><div><div><p><code>labels</code></p></div></div></td><td><div><div><p>Optional</p></div></div></td><td><div><div><p>Empty array</p></div></div></td><td><div><div><p>Array of labels that are added to the trace to be used as span attributes in the trace data.</p></div></div></td></tr><tr><td><div><div><p><code>labels.name</code></p></div></div></td><td><div><div><p>Required</p></div></div></td><td><div><div><p>N/A</p></div></div></td><td><div><div><p>The name of the label, used as a span attribute name.</p></div></div></td></tr><tr><td><div><div><p><code>labels.type</code></p></div></div></td><td><div><div><p>Required</p></div></div></td><td><div><div><p>N/A</p></div></div></td><td><div><div><p>The type of the label specifies where the value for the label is taken from. Supported values are <code>literal</code>, <code>environment</code>, and <code>requestHeader</code>.</p></div></div></td></tr><tr><td><div><div><p><code>labels.keyName</code></p></div></div></td><td><div><div><p>Required</p></div></div></td><td><div><div><p>N/A</p></div></div></td><td><div><div><p>The key name of the label.</p></div></div></td></tr><tr><td><div><div><p><code>labels.defaultValue</code></p></div></div></td><td><div><div><p>Required</p></div></div></td><td><div><div><p>N/A</p></div></div></td><td><div><div><p>The default value of the label.</p></div></div></td></tr></tbody></table>

#### Resource Configuration Example

\- policyRef: name: tracing-flex config: sampling: client: 100 random: 100 overall: 100 spanName:
flightsAPI labels: - name: c-env-tag type: environment keyName: FLEX\_NAME defaultValue:
DEFAULT\_VAL - name: c-header-tag type: requestHeader keyName: :method defaultValue:
DEFAULT\_METHOD - name: c-literal-tag type: literal defaultValue: the-tag

### Managed Flex Gateway and Flex Gateway Connected Mode

When you apply the policy from the UI, the following parameters are displayed:

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Element</th><th>Description</th><th>Required</th></tr></thead><tbody><tr><td><div><div><p>Client Sampling</p></div></div></td><td><div><div><p>The target percentage of requests that are force traced if the <code>x-client-trace-id</code> header is set.</p></div></div></td><td><div><div><p>Yes</p></div></div></td></tr><tr><td><div><div><p>Random Sampling</p></div></div></td><td><div><div><p>The target percentage of requests that are randomly selected for trace generation, if not requested by the client or not forced.</p></div></div></td><td><div><div><p>Yes</p></div></div></td></tr><tr><td><div><div><p>Overall Sampling</p></div></div></td><td><div><div><p>The target percentage of requests that are traced after all other sampling checks have been applied, such as client-directed, force tracing, and random sampling.</p></div></div></td><td><div><div><p>Yes</p></div></div></td></tr><tr><td><div><div><p>Span name</p></div></div></td><td><div><div><p>The name of the span. If no span name is configured, the API name is used.</p></div></div></td><td><div><div><p>No</p></div></div></td></tr><tr><td><div><div><p>Labels</p></div></div></td><td><div><div><p>Array of labels that are added to the trace to be used as span attributes in the trace data.</p></div></div></td><td><div><div><p>Optional</p></div></div></td></tr><tr><td><div><div><p>Label Name</p></div></div></td><td><div><div><p>The name of the label, used as a span attribute name.</p></div></div></td><td><div><div><p>Yes</p></div></div></td></tr><tr><td><div><div><p>Label Type</p></div></div></td><td><div><div><p>The type of the label specifies where the value for the label is taken from. Supported values are <code>literal</code>, <code>environment</code>, and <code>requestHeader</code>.</p></div></div></td><td><div><div><p>Yes</p></div></div></td></tr><tr><td><div><div><p>Label Key Name</p></div></div></td><td><div><div><p>The key used to retrieve the value, such as an environment variable or request header name.</p></div></div></td><td><div><div><p>Yes</p></div></div></td></tr><tr><td><div><div><p>Label Default Value</p></div></div></td><td><div><div><p>Default value to use if the key is not found or the retrieved value is empty.</p></div></div></td><td><div><div><p>Yes</p></div></div></td></tr></tbody></table>
