Skip to navigation

nemo_gym.orchestration.executors.otel

View as MarkdownOpen in Claude

The OpenTelemetry collector that runs beside every benchmark job.

One collector per benchmark job, in its own srun --overlap step like any other service. It scrapes each model service’s Prometheus /metrics on localhost, accepts OTLP from the job’s own processes, stamps the resource attributes the shared dashboards filter on (user, run_id, slurm_job_id, plus benchmark, cluster, model), and exports to the configured OTLP/HTTP endpoint (when remote export is enabled) and to <job dir>/otel/*.jsonl (written node-local, copied when it stops).

The local metrics.jsonl is a lighter copy than the remote export, because node_exporter’s full output made up about 90% of its bytes (several GiB per run) and is node health rather than benchmark performance:

  • node_exporter metrics outside otel.local_node_metrics (CPU time, load, memory, pressure stall, network and InfiniBand byte totals by default) are dropped from it. local_node_metrics: null keeps all of them, and local_node_metrics_extra adds patterns;
  • the span_metrics connector feeds only the remote export, since the same call counts and durations come from the spans in traces.jsonl. The remote export is unchanged.

The ingest token travels twice, as the HTTP Authorization header and as an Authorization resource attribute: a routing proxy in front of the backend resolves the tenant from the attribute and silently drops payloads without it while still answering 200.

Module Contents

Functions

NameDescription
_local_node_metrics_filterThe filter processor that drops node_exporter metrics outside otel.local_node_metrics from the local file.
_ottl_stringvalue as an OTTL string literal inside the collector’s YAML: $$ stops the collector’s own $&#123;...&#125; expansion.
_policy_model_name-
collector_config_path-
driver_telemetry_envEnvironment that switches on Gym’s Lens instrumentation and points it at the collector.
gym_telemetry_activeWhether the driver is instrumented with nemo-lens and pointed at the collector.
otel_activeEnabled is enough: Gym’s own servers push telemetry even when there is no local model to scrape.
render_collector_configThe collector’s YAML for one benchmark job.
resolve_tokenResolve the remote ingest token, switching to local collection with a warning if absent.
scrape_targetsService name to serving port for every service that exposes a model (and so /metrics).
validate_destinationRemote export needs a destination; local collection does not.
validate_gym_telemetry-
vllm_traces_envEnvironment for a traced vLLM service.
vllm_traces_flagThe vllm serve flag that sends one span per request to the collector’s OTLP/HTTP receiver.

Data

COLLECTOR_CONFIG_NAME

COLLECTOR_DIR

COLLECTOR_FILE_SIGNALS

COLLECTOR_HEALTH_PORT

COLLECTOR_LOCAL_DIR_ENV

COLLECTOR_LOCAL_DIR_PREFIX

COLLECTOR_SERVICE_NAME

FINAL_SCRAPE_GRACE_SECONDS

GYM_TELEMETRY_EXTRA

NODE_METRICS_FILTER

NODE_SCRAPE_JOB

OTLP_GRPC_PORT

OTLP_HTTP_PORT

SHUTDOWN_WAIT_SECONDS

VLLM_TRACES_FLAG

logger

API

nemo_gym.orchestration.executors.otel._local_node_metrics_filter(
) -> dict | None

The filter processor that drops node_exporter metrics outside otel.local_node_metrics from the local file.

Keyed on the scrape job rather than a name prefix, so it covers every family node_exporter serves (including textfile collectors with their own prefixes) on every scraped node, and leaves DCGM, engine and Gym metrics alone.

nemo_gym.orchestration.executors.otel._ottl_string(
value: str
) -> str

value as an OTTL string literal inside the collector’s YAML: $$ stops the collector’s own ${...} expansion.

nemo_gym.orchestration.executors.otel._policy_model_name(
) -> str | None
nemo_gym.orchestration.executors.otel.collector_config_path(
remote_bench_dir: pathlib.Path
) -> pathlib.Path
nemo_gym.orchestration.executors.otel.driver_telemetry_env(
gym_job_id: str,
span_groups: str,
logs: bool = True
) -> dict[str, str]

Environment that switches on Gym’s Lens instrumentation and points it at the collector.

Gym reads these in every server process (NEMO_GYM_OTEL_* are Gym’s own, the OTEL_* ones are the SDK’s); an explicit value in driver.env wins over these.

nemo_gym.orchestration.executors.otel.gym_telemetry_active(
) -> bool

Whether the driver is instrumented with nemo-lens and pointed at the collector.

nemo_gym.orchestration.executors.otel.otel_active(
) -> bool

Enabled is enough: Gym’s own servers push telemetry even when there is no local model to scrape.

nemo_gym.orchestration.executors.otel.render_collector_config(
benchmark_name: str,
remote_bench_dir: pathlib.Path,
node_local: bool = True
) -> str

The collector’s YAML for one benchmark job.

run_id is the submission’s gym job id, which is the job directory’s parent by construction (<output_path>/<gym_job_id>/<benchmark>); cluster is the sole compute key, the same value SubmissionRecord.cluster records. Values only known inside the job (SLURM_JOB_ID, the token, the node-local directory) are left as ${env:...} for the collector to expand at startup. node_local=False writes the jsonl straight into the job directory, for a job.sh that predates the copy.

nemo_gym.orchestration.executors.otel.resolve_token(
) -> str | None

Resolve the remote ingest token, switching to local collection with a warning if absent.

nemo_gym.orchestration.executors.otel.scrape_targets(
) -> dict[str, int]

Service name to serving port for every service that exposes a model (and so /metrics).

nemo_gym.orchestration.executors.otel.validate_destination(
) -> None

Remote export needs a destination; local collection does not.

nemo_gym.orchestration.executors.otel.validate_gym_telemetry(
) -> None
nemo_gym.orchestration.executors.otel.vllm_traces_env(
component: str,
service_name: str
) -> dict[str, str]

Environment for a traced vLLM service.

vLLM picks the exporter by OTEL_EXPORTER_OTLP_TRACES_PROTOCOL and defaults to gRPC, so the protocol has to match the HTTP endpoint in the flag. vLLM sets no service.name of its own; the collector copies the one given here into service.name.override, so the spans carry the same display identity as the service’s scraped metrics (<component>/<service>).

nemo_gym.orchestration.executors.otel.vllm_traces_flag(
host: str = 'localhost'
) -> str

The vllm serve flag that sends one span per request to the collector’s OTLP/HTTP receiver.

nemo_gym.orchestration.executors.otel.COLLECTOR_CONFIG_NAME = 'collector.yaml'
nemo_gym.orchestration.executors.otel.COLLECTOR_DIR = 'otel'
nemo_gym.orchestration.executors.otel.COLLECTOR_FILE_SIGNALS = ('metrics', 'traces', 'logs')
nemo_gym.orchestration.executors.otel.COLLECTOR_HEALTH_PORT = 4319
nemo_gym.orchestration.executors.otel.COLLECTOR_LOCAL_DIR_ENV = 'GYM_OTEL_LOCAL_DIR'
nemo_gym.orchestration.executors.otel.COLLECTOR_LOCAL_DIR_PREFIX = '/tmp/gym-otel-'
nemo_gym.orchestration.executors.otel.COLLECTOR_SERVICE_NAME = 'otel_collector'
nemo_gym.orchestration.executors.otel.FINAL_SCRAPE_GRACE_SECONDS = 20
nemo_gym.orchestration.executors.otel.GYM_TELEMETRY_EXTRA = 'telemetry'
nemo_gym.orchestration.executors.otel.NODE_METRICS_FILTER = 'filter/local_node_metrics'
nemo_gym.orchestration.executors.otel.NODE_SCRAPE_JOB = 'node'
nemo_gym.orchestration.executors.otel.OTLP_GRPC_PORT = 4317
nemo_gym.orchestration.executors.otel.OTLP_HTTP_PORT = 4318
nemo_gym.orchestration.executors.otel.SHUTDOWN_WAIT_SECONDS = 120
nemo_gym.orchestration.executors.otel.VLLM_TRACES_FLAG = '--otlp-traces-endpoint'
nemo_gym.orchestration.executors.otel.logger = logging.getLogger(__name__)