> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/guardrails/llms.txt.
> For full documentation content, see https://docs.nvidia.com/nemo/guardrails/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/guardrails/_mcp/server.

# nemoguardrails.tracing.span_formatting

Simple span formatting functions for different output formats.

## Module Contents

### Functions

| Name                                                                                                             | Description                                              |
| ---------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------- |
| [`extract_span_attributes`](#nemoguardrails-tracing-span_formatting-extract_span_attributes)                     | Extract OpenTelemetry attributes from any span type.     |
| [`format_span_for_filesystem`](#nemoguardrails-tracing-span_formatting-format_span_for_filesystem)               | Format any span type for JSON filesystem storage.        |
| [`get_schema_version_for_filesystem`](#nemoguardrails-tracing-span_formatting-get_schema_version_for_filesystem) | Return the schema version string based on the span type. |

### API

```python
nemoguardrails.tracing.span_formatting.extract_span_attributes(
    span
) -> typing.Dict[str, typing.Any]
```

Extract OpenTelemetry attributes from any span type.

**Parameters:**

Either SpanLegacy or typed span

**Returns:** `Dict[str, Any]`

Dictionary of OpenTelemetry attributes

```python
nemoguardrails.tracing.span_formatting.format_span_for_filesystem(
    span
) -> typing.Dict[str, typing.Any]
```

Format any span type for JSON filesystem storage.

**Parameters:**

Either SpanLegacy or typed span (InteractionSpan, RailSpan, etc.)

**Returns:** `Dict[str, Any]`

Dictionary with all span data for JSON serialization

```python
nemoguardrails.tracing.span_formatting.get_schema_version_for_filesystem(
    span
) -> str
```

Return the schema version string based on the span type.