Skip to navigation

nemo_gym.sandbox.observability

View as Markdown

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

NameDescription
set_span_attribute_providerRegister a callable whose attributes are added to every gym.sandbox.* span.
span_attributesThe provider’s attributes, overridden key by key by explicit.

Data

SpanAttributeProvider

_span_attribute_provider

API

nemo_gym.sandbox.observability.set_span_attribute_provider(
) -> 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.

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.

nemo_gym.sandbox.observability.SpanAttributeProvider = Callable[[], Mapping[str, Any]]
nemo_gym.sandbox.observability._span_attribute_provider: SpanAttributeProvider | None = None