nemo_gym.telemetry.contrib
nemo_gym.telemetry.contrib
Gym’s boundary onto nemo-lens’s propagation and framework-instrumentation helpers.
nemo_gym.telemetry is the only package that imports nemo.lens. Everything outside it
reaches telemetry through this package, so a reader never has to work out whether a given
nemo.lens import is reachable when the extra is not installed. The invariant is
enforced by tests/unit_tests/telemetry/test_call_sites.py.
_fallbacks covers the primitives used at instrumentation sites. This module covers the
two helpers that are not primitives: W3C context injection at Gym’s HTTP egress, and
FastAPI auto-instrumentation at each server’s startup. Both are called only on paths that
already established telemetry is active, so neither needs a no-op twin — but both are
defensive anyway, because telemetry must never be the reason a server fails to start or a
request fails to send.
Module Contents
Functions
Data
API
Write the current span’s W3C traceparent into headers.
The egress half of cross-process propagation. A no-op when there is no recording span, because the propagator has no context to write.
Call only behind a span-group gate: the import below is function-local so a disabled site never reaches it.
Apply OpenTelemetry FastAPI auto-instrumentation to app.
The ingress half of cross-process propagation: it extracts an inbound traceparent
and parents this server’s SERVER span to the caller’s span.
service_name is deliberately not passed. nemo.lens.contrib.fastapi’s helper
accepts it and never uses it at the pinned commit; the name comes from
OTEL_SERVICE_NAME, which init_telemetry resolves.
Returns: bool
True when instrumentation was applied. False when the optional instrumentation