---
schema_version: "1"
id: 31222f83cd4466165149a3ef523d89f7feb943cc4e5857c83e64c3421dbfc90f
title: Tracing Policy
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/gateway/latest/policies-included-tracing.md
canonical_url: https://docs.mulesoft.com/gateway/latest/policies-included-tracing
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 8b68a5a0cfd3ddb6c8610b02f5c41ae76b3509f5d6daae924ad780bea560da61
description: MuleSoft Documentation Site
release: "1.14"
latest: true
---
---
product: Omni Gateway
version: 1.14
is-latest-version: true
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 Omni Gateway version available</strong></p></td><td><p>1.10.0</p></td></tr><tr><td><p><strong>Release Notes</strong></p></td><td><p><a href="https://docs.mulesoft.com/release-notes/gateway/policies/tracing-release-notes">Tracing</a></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 an Omni
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 Omni Gateway Distributed Tracing in Local Mode](https://docs.mulesoft.com/gateway/latest/local-tracing-config)

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

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

## Configuring Policy Parameters

### Omni 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 Omni Gateway and Omni 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>
