Configuring Flex Gateway Distributed Tracing in Connected Mode | MuleSoft Documentation
# Configuring Flex Gateway Distributed Tracing in Connected Mode
OpenTelemetry provides a unified standard for instrumenting, generating, collecting, and exporting telemetry data across distributed systems. Flex Gateway supports OpenTelemetry, enabling you to configure the generation of distributed tracing data for all API traffic managed by the gateway. This integration delivers deep visibility into API request flows, making it easier to analyze system behavior, troubleshoot issues, and understand interactions between Flex Gateway APIs and external services.
With the Anypoint Monitoring Telemetry Exporter, you can send Flex Gateway trace data to third-party observability and analytics platforms, including Azure Monitor, Splunk HEC, or any OpenTelemetry-compliant tool. This capability allows you to leverage end-to-end observability, correlating API traces with data from other systems to build a comprehensive view of your environment.
## Before You Begin
To use the OpenTelemetry with Flex Gateway, you must be familiar with:
  * Distributed tracing concepts, including traces and spans.
If you’re new to distributed tracing and OpenTelemetry, we recommend starting with What is OpenTelemetry and Understanding distributed tracing.
  * How to export telemetry data to third-party monitoring systems.


## Configure Distributed Tracing for a Flex Gateway API
Tracing enables you to track Flex Gateway API interactions. When multiple systems and services are involved, distributed tracing tracks API requests as they flow through distributed environments, providing a comprehensive view of the API’s execution.
## Enable and Configure Distributed Tracing with a YAML Configuration Resource
Edit and then apply this configuration resource to enable distributed tracing. This configuration resource applies to all API instances. This example sets sampling to 0% for all traces, and sampling is configured on a per-API basis using policies.
```
apiVersion: gateway.mulesoft.com/v1beta1
kind: Configuration
metadata:
 name: tracing
 namespace: test-ns
spec:
 tracing:
  provider:
   type: anypoint
   properties:
    timeout: 10s #
  sampling: # Set all sampling to 0% - this example shows enabling samping for the gateway, but only generating trace data for sampling on a per-API basis using the Tracing policy.
   client: 0
   random: 0
   overall: 0
   #
   # Add labels such as these example labels, if you want to configure labels globally. You can also configure labels on a per-API basis by using the Tracing policy.
   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
```

## Configure Distributed Tracing For Specific APIs
You can override the globally configured distributed tracing settings by applying the Tracing Policy to specific APIs. You must first enable and configure distributed tracing for the gateway. You can then apply this policy to the APIs you want to instrument:
  *