> For the complete documentation index, see [llms.txt](https://docs.cennso.com/components/smc/latest/llms.txt) (all documentation: [llms.txt](https://docs.cennso.com/llms.txt)). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cennso.com/components/smc/latest/observability/tracing.md).

# Distributed tracing

Session Management Controller (SMC) supports distributed tracing based on [OpenTelemetry](https://opentelemetry.io/). A trace records the path of one signaling transaction through SMC and its peers as a tree of timed spans. Tracing complements metrics and logs: metrics show aggregate behavior, logs show individual events, and traces show how one request moved through the system and where it spent its time.

Tracing is disabled by default and adds no measurable overhead while disabled. To enable and configure it, see the [Tracing configuration](https://docs.cennso.com/components/smc/latest/guides/tracing.md) page.

## Why tracing

A single session-management transaction spans multiple protocols. A GTP-C Create Session Request, for example, triggers a Packet Forwarding Control Protocol (PFCP) exchange with the User Plane Function (UPF) and Diameter or Npcf exchanges with policy and charging systems before SMC responds. When that transaction is slow or fails, metrics show only that latency increased. Log lines show isolated events without timing relations between them.

A trace closes this gap. For a single transaction, the trace shows:

- The end-to-end duration plus the time spent in each protocol exchange, so the slow one is immediately visible.
- The order and nesting of the protocol exchanges that the transaction triggered.
- Which protocol exchange failed first when the transaction failed.
- The trace ID, which also appears as the `trace_id` field in SMC log lines, linking the trace to the logs of the same transaction.

## Tracing in Cennso

SMC exports trace data over the OpenTelemetry Protocol (OTLP) to a collector. In a Cennso deployment, the central telemetry storage based on the Grafana LGTM stack receives traces in Tempo, next to logs and metrics. Cennso supports tracing requests exchanged between SMC, Policy Provisioning Engine (PPE), Network Service Registry (NSR), and Charging Data Function (CDF), so one trace can span several components.

SMC propagates the World Wide Web Consortium (W3C) `traceparent` header on its Service Based Interface (SBI) requests. A peer that runs an OpenTelemetry SDK, such as a Policy Control Function (PCF), continues the trace instead of starting a new one.

## What SMC traces

When tracing is enabled, SMC emits spans for the signaling hot paths:

| Span | Kind | When |
|---|---|---|
| `gtpc.<message_type>` | server | One span per inbound GTP-C request. On proxy contexts the span covers the full request to forwarded-response round trip and carries a `gtp.proxy` attribute. |
| `gtpc.<message_type>` | client | One span per gateway-initiated outbound GTP-C request, such as Delete Bearer Request. |
| `pfcp.<message_type>` | client | One span per outbound PFCP call to a UPF. |
| `pfcp.session_report_request` | server | One span per inbound PFCP Session Report Request from a UPF. |
| `aaa.invoke` | client | One span per Authentication, Authorization, and Accounting (AAA) procedure invocation (Gx, Gy/Ro, Rf, NASREQ). |
| `aaa.rar.<application>`, `aaa.asr` | server | One span per inbound AAA re-authorization or abort-session event at the gateway. |
| `diameter.<command>` | client | One span per outbound Diameter request. |
| `diameter.RAR`, `diameter.ASR` | server | One span per inbound Diameter Re-Auth-Request or Abort-Session-Request. |
| `sbi.npcf.<operation>` | client | One span per outbound Npcf request, with `traceparent` propagation to the PCF. |
| `HTTP <method>` | server | One span per request to the management and metrics HTTP API. |

The entry-point server spans (GTP-C, AAA, PFCP Session Report, Diameter) record subscriber identifiers as span attributes: `3gpp.imsi`, `3gpp.imei`, and `3gpp.msisdn`, plus their 5G-prefixed equivalents `3gpp.supi`, `3gpp.pei`, and `3gpp.gpsi`. Diameter server spans additionally carry `diameter.session.id`. These attributes make traces searchable by subscriber in the trace backend.

SMC does not trace per-packet user-plane traffic, background heartbeats (GTP echo, PFCP heartbeat), or inbound RADIUS requests.

Diameter and PFCP do not carry a `traceparent` header on the wire, so spans for inbound Diameter and PFCP requests start new traces instead of continuing the sender's trace. The related traces of one transaction share the subscriber identifier attributes, which the trace backend can search for.

## Sampling

The sampler decides which transactions produce trace data. SMC uses parent-based sampling by default: a request that arrives with a sampled `traceparent` header is always traced, and a new transaction is traced with a configurable probability. This bounds the tracing overhead at high signaling rates while keeping cross-component traces complete. See [Tracing configuration](https://docs.cennso.com/components/smc/latest/guides/tracing.md#choose-a-sampler) for the available samplers.

## Correlating logs and traces

The OpenTelemetry SDK writes the active span context into the Erlang logger metadata, with no SMC-specific logger plumbing involved. While a span is active, every SMC log line carries the `trace_id` field holding the 128-bit trace ID as 32 lowercase hexadecimal characters and the `span_id` field holding the 64-bit span ID. The `trace_id` value matches the trace ID in the trace backend, so a log line leads directly to the trace of the same transaction, and a trace leads to all its log lines. [Troubleshooting with traces](https://docs.cennso.com/components/smc/latest/troubleshooting/tracing.md) shows this workflow.

## Data sensitivity

> [!CAUTION]
> Traces carry subscriber data by design, and SMC does not filter span attributes. The entry-point server spans record subscriber identifiers (`3gpp.imsi`, `3gpp.imei`, `3gpp.msisdn`, `3gpp.supi`, `3gpp.pei`, `3gpp.gpsi`) so that operators can search traces by subscriber. In addition, HTTP server spans capture the request path and headers, and the request path on Npcf spans can contain a subscriber identifier when the PCF encodes it in the policy resource path. Handle data-protection compliance at the tracing backend: apply collector-side attribute redaction, retention limits, and access controls, or keep tracing disabled in environments where this is not acceptable.

Sampling reduces the volume of trace data but not the sensitivity of an individual trace.
