> This page is for version 0.5.1.
> For other versions, use one of these documentation indexes:
> - Main (default): https://docs.nvidia.com/nemo/gym/main/llms.txt
> - 0.7.0: https://docs.nvidia.com/nemo/gym/v0.7.0/llms.txt
> - 0.6.0: https://docs.nvidia.com/nemo/gym/v0.6.0/llms.txt
> - 0.5.1: https://docs.nvidia.com/nemo/gym/v0.5.1/llms.txt
> - 0.5.0: https://docs.nvidia.com/nemo/gym/v0.5.0/llms.txt
> - 0.4.0: https://docs.nvidia.com/nemo/gym/v0.4.0/llms.txt
> - 0.3.0: https://docs.nvidia.com/nemo/gym/v0.3.0/llms.txt
> - 0.2.1: https://docs.nvidia.com/nemo/gym/v0.2.1/llms.txt

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

# nemo_gym.sandbox.observability

Extra span attributes for the sandbox API, supplied by whoever runs the sandbox.

The sandbox package knows nothing about rollouts. Gym's telemetry setup registers a provider
here that returns the current rollout id; the sandbox spans in `nemo_gym.sandbox.api` add
whatever the provider returns when they open.

## Module Contents

### Functions

| Name                                                                                         | Description                                                                   |
| -------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- |
| [`set_span_attribute_provider`](#nemo_gym-sandbox-observability-set_span_attribute_provider) | Register a callable whose attributes are added to every `gym.sandbox.*` span. |
| [`span_attributes`](#nemo_gym-sandbox-observability-span_attributes)                         | The provider's attributes, overridden key by key by *explicit*.               |

### Data

[`SpanAttributeProvider`](#nemo_gym-sandbox-observability-SpanAttributeProvider)

[`_span_attribute_provider`](#nemo_gym-sandbox-observability-_span_attribute_provider)

### API

```python
nemo_gym.sandbox.observability.set_span_attribute_provider(
    provider: nemo_gym.sandbox.observability.SpanAttributeProvider | None
) -> None
```

Register a callable whose attributes are added to every `gym.sandbox.*` span.

Called once by the telemetry setup of the embedding application; None removes it. The
provider runs when a span opens, so it may read request-scoped state such as a ContextVar.
An explicit `span_attributes` argument to `AsyncSandbox.start` or `AsyncSandbox.exec`
wins over it key by key.

```python
nemo_gym.sandbox.observability.span_attributes(
    explicit: collections.abc.Mapping[str, typing.Any] | None = None
) -> dict[str, typing.Any]
```

The provider's attributes, overridden key by key by *explicit*.

```python
nemo_gym.sandbox.observability.SpanAttributeProvider = Callable[[], Mapping[str, Any]]
```

```python
nemo_gym.sandbox.observability._span_attribute_provider: SpanAttributeProvider | None = None
```