Skip to content

fix(otel): send Gym logs to the collector's HTTP port - #4167

Merged
wprazuch merged 3 commits into
mainfrom
wprazuch/otel-logs-endpoint-port
Oct 7, 2026
Merged

wprazuch merged 3 commits into
mainfrom
wprazuch/otel-logs-endpoint-port

Conversation

@wprazuch

@wprazuch wprazuch commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Problem

driver_telemetry_env pins logs to the collector's gRPC port:

"OTEL_EXPORTER_OTLP_PROTOCOL": "http/protobuf",
# nemo-lens builds its log exporter over gRPC regardless of the protocol setting, so logs
# get the collector's gRPC port explicitly (the SDK's per-signal endpoint takes precedence).
"OTEL_EXPORTER_OTLP_LOGS_ENDPOINT": f"http://localhost:{OTLP_GRPC_PORT}",   # 4317

That premise does not hold. Gym depends on nemo-lens[sdk] and never on opentelemetry-exporter-otlp-proto-grpc — the resolved environment contains only opentelemetry/exporter/otlp/proto/http. So the HTTP log exporter is built, it honours the explicit per-signal endpoint, and POSTs HTTP at the collector's gRPC listener.

The collector's own receivers confirm the split this lands on:

grpc: 0.0.0.0:4317
http: 0.0.0.0:4318

Symptom: latent until a run actually ships logs

Two runs on the same cluster with the identical env (OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=http://localhost:4317):

a short MCQA leaf an agentic leaf
exporter seen in the driver log http.metric_exporter only http._log_exporter
Failed to export 0 598
driver log size 112K 324K
outcome completed, full artifacts incl. rollout_verdicts.jsonl hung, no verdicts

The first never emitted a log batch, so it never touched the wrong port and certified cleanly. The second emits many; every batch fails:

[opentelemetry.exporter.otlp.proto.http._log_exporter][ERROR]
   Failed to export logs batch due to timeout, max retries or shutdown

The eval itself completes and writes every artifact, then the job never finishes — it sat over an hour past writing rollouts_aggregate_metrics.json before being cancelled, holding its GPUs, and rollout_verdicts.jsonl was never produced.

So this is not visible on short benchmarks, which is why it has gone unnoticed; it bites exactly the long agentic runs that cost the most to lose.

Change

Drop the per-signal override so logs follow OTEL_EXPORTER_OTLP_PROTOCOL to OTEL_EXPORTER_OTLP_ENDPOINT, the HTTP port — consistent with traces and metrics.

OTLP_GRPC_PORT stays: the collector still exposes the gRPC receiver, nothing sends to it.

Testing

pytest tests/unit_tests/test_orchestration_otel.py tests/unit_tests/test_slurm_script.py — 282 passed.

test_script_ships_gym_logs_by_default_and_can_switch_them_off asserted the old endpoint, with a comment repeating the same premise; it now asserts no per-signal logs endpoint is set and that the global endpoint is the HTTP port. The two pd_swebench_pro_*.sh golden fixtures are regenerated.

Caveat

If a host environment installs the gRPC exporter alongside Gym — NeMo-RL resolves one nemo-lens and installs Gym into its environment — nemo-lens could select gRPC there, and logs would then go to the HTTP port over gRPC. I could not verify nemo-lens's selection logic from Gym's dependency closure alone. If that case is real, the fix is to choose the port from the exporter actually in use rather than hardcoding either, and this change should be revisited.

The per-signal override pinned logs to the gRPC port on the premise that
nemo-lens always builds a gRPC log exporter. Gym installs nemo-lens[sdk] and
never the gRPC exporter, so the HTTP exporter runs and POSTs at the gRPC
port; every batch times out and the job hangs past completion.

Signed-off-by: Wojciech Prazuch <[email protected]>
@copy-pr-bot

copy-pr-bot Bot commented Oct 7, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@wprazuch

wprazuch commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 29f106b

@wprazuch
wprazuch enabled auto-merge October 7, 2026 07:36
@yaoyu-33 yaoyu-33 added area:orchestration Job submission, deployment, services, and lifecycle management bug Something isn't working complexity:low Localized change in one scope with a small, straightforward review surface ready-to-merge PR is approved, current, and waiting for final CI or merge labels Oct 7, 2026
@wprazuch

wprazuch commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test bacbfec

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/37596991921

Merged via the queue into main with commit 832d1cb Oct 7, 2026
43 checks passed
@wprazuch
wprazuch deleted the wprazuch/otel-logs-endpoint-port branch October 7, 2026 09:09
iguehring-nvidia added a commit that referenced this pull request Oct 12, 2026
… the OTLP protocol

Bump the nemo-lens pin from b0f977d4 to 4d045c03 (Lens main, includes
NVIDIA-NeMo/Lens#80). Until #80, nemo-lens picked its OTLP log exporter
by import order instead of OTEL_EXPORTER_OTLP_PROTOCOL, unlike spans and
metrics. The driver environment that `gym eval submit` renders sets one
endpoint and one protocol for every signal (#4167), which is only right
when the log exporter honours them: in an environment that carries the
gRPC exporter package the driver built a gRPC log exporter, every batch
to the collector's HTTP port failed, and at shutdown the driver sat in
the exporter's retry loop until the job hit its wall time.

With the new pin the log exporter is chosen from the protocol like the
other two, so the shared endpoint holds whichever exporter packages the
host environment installs and no per-process port probing is needed.

Adapt to the rest of the pin move: mirror the new `span_attributes`
no-op in Gym's fallback shim (Lens#71), and point the span test fixtures
at Lens's cached default-tracer lookup (Lens#73).

Signed-off-by: Ingo Guehring <[email protected]>
iguehring-nvidia added a commit that referenced this pull request Oct 12, 2026
… the OTLP protocol

Bump the nemo-lens pin from b0f977d4 to 4d045c03 (Lens main, includes
NVIDIA-NeMo/Lens#80). Until #80, nemo-lens picked its OTLP log exporter
by import order instead of OTEL_EXPORTER_OTLP_PROTOCOL, unlike spans and
metrics. The driver environment that `gym eval submit` renders sets one
endpoint and one protocol for every signal (#4167), which is only right
when the log exporter honours them: in an environment that carries the
gRPC exporter package the driver built a gRPC log exporter, every batch
to the collector's HTTP port failed, and at shutdown the driver sat in
the exporter's retry loop until the job hit its wall time.

With the new pin the log exporter is chosen from the protocol like the
other two, so the shared endpoint holds whichever exporter packages the
host environment installs and no per-process port probing is needed.

Adapt to the rest of the pin move: mirror the new `span_attributes`
no-op in Gym's fallback shim (Lens#71), and point the span test fixtures
at Lens's cached default-tracer lookup (Lens#73).

Signed-off-by: Ingo Guehring <[email protected]>
khazic pushed a commit to khazic/Gym-lao that referenced this pull request Oct 13, 2026
… the OTLP protocol (NVIDIA-NeMo#4117)

## What does this PR do?

Bumps the nemo-lens pin from `b0f977d4` to `4d045c03` (Lens main,
includes NVIDIA-NeMo/Lens#80) and adapts Gym to the pin move.

Until Lens#80, nemo-lens chose its OTLP **log** exporter by import order
instead of by `OTEL_EXPORTER_OTLP_PROTOCOL`, unlike the span and metric
exporters. The driver environment rendered by `gym eval submit` sets one
endpoint and one protocol for every signal (NVIDIA-NeMo#4167 removed the last
per-signal override). That is only right when the log exporter honours
them. In an environment that carries the gRPC exporter package, the
driver built a gRPC log exporter: every log batch to the collector's
HTTP port failed with `StatusCode.UNAVAILABLE`, and at shutdown the
driver sat in the exporter's retry loop until the job hit its wall time.

With the new pin the log exporter follows the protocol like the other
two, so the shared endpoint holds in every environment and no
per-process port probing is needed.

Changes beyond the pin:

- `nemo_gym/telemetry/_fallbacks.py`: mirrors the new `span_attributes`
no-op (Lens#71); `test_fallbacks.py` enforces parity with
`nemo.lens.fallbacks`.
- `tests/unit_tests/telemetry/test_endpoints.py`, `test_call_sites.py`:
the span-capture fixtures patch `nemo.lens.helpers.get_tracer`, since
Lens#73 resolves default tracers through its own cache rather than
`opentelemetry.trace.get_tracer`.
- `nemo_gym/orchestration/executors/otel.py`: drops the comment that
said Gym never installs the gRPC exporter; `nemo-lens[sdk]` requires it,
and the exporter choice is now made by protocol rather than by what is
installed. No code change;
`test_script_ships_gym_logs_by_default_and_can_switch_them_off` asserts
the shared endpoint and protocol and no per-signal override.

Supersedes the probing approach in NVIDIA-NeMo#4226 if this lands first: with the
pin, `http/protobuf` selects the HTTP log exporter whether or not the
gRPC package is installed.

## Validation

- `pytest tests/unit_tests/test_orchestration_otel.py
tests/unit_tests/test_slurm_script.py tests/unit_tests/telemetry`: 531
passed, 4 failed. The 4
(`test_orchestrator_is_the_only_writer_of_the_active_servers_gauge`,
`test_multi_destination_waits_are_attributed_to_the_binding_limit`, two
`test_memory` cases) need Linux `/proc` or a second loopback address and
fail identically on main at the old pin on this macOS machine.
- `pre-commit run --files ...` on the changed files: pass.
- `uv lock --upgrade-package nemo-lens`: only the nemo-lens entries move
in `uv.lock`; no other dependency changes.
- Cluster run at Lens#80's pre-merge head (`e0f4b7f`) on 2026-10-08,
oci-hsg job 7792824, scicode with 4 tasks: exit 0, job ended 36 s after
the last rollout (main held its node 49 min), zero log-export errors,
driver and server spans and the driver's log records all arrived at the
collector over HTTP.
- Cluster run at the merged pin (`4d045c03`, this PR's head) on
2026-10-12, oci-hsg job 7888521 (run `gym-job-20261012T072113Z-8f5c94`),
same shape: COMPLETED with exit 0 in 9 min 7 s; the job ended 29 s after
the last rollout was written; zero occurrences of
`StatusCode.UNAVAILABLE`, `ConnectionResetError`, `Failed to export
logs` or `Transient error` in the driver log; collector healthy with no
non-debug errors; spans from every process reached the collector
(orchestrator 22, policy model 422, agent 460, environment server 41,
resources server 39); the driver's log records arrived over HTTP (the
servers log nothing at WARNING or above in a clean run, so none were
expected from them). A first attempt (job 7888331) failed the eval
itself on an empty inference key and still exited 30 s after the error,
with the policy model's four WARN records delivered.

## Rollouts

N/A: dependency pin and telemetry test fixtures only; no agent, model or
verifier behaviour changes.

## Compatibility and benchmark impact

Jobs ship Gym logs from every process to the collector's HTTP port and
exit promptly after the driver finishes. An explicit
`driver.env.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT` still wins. nemo-lens
between the pins also adds observable metric kinds to its instrument
registry (Lens#84) and generated semconv constants (Lens#81); Gym's uses
of both pass the existing tests. No benchmark-result impact.

## Checklist

- [x] I have read the [contributing
guidelines](https://github.com/NVIDIA-NeMo/Gym/blob/main/CONTRIBUTING.md).
- [x] The change is focused; unrelated "drive-by" edits are tracked as
separate issues/PRs.
- [x] Tests added or updated and pass locally.
- [x] Documentation added or updated, or N/A with justification (N/A: no
user-facing behaviour change; the docs already describe the shared
endpoint).
- [x] Pre-commit checks pass locally on the changed files.
- [x] New source files include the required Apache-2.0 SPDX header (no
new files).
- [x] All commits have DCO sign-off (`git commit -s`).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Ingo Guehring <[email protected]>

This branch was previously deployed

1 inactive deployment
public — bacbfec6 Deployed Oct 7, 2026 by copy-pr-bot[bot] via release / finalize / notify #4534
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:orchestration Job submission, deployment, services, and lifecycle management bug Something isn't working complexity:low Localized change in one scope with a small, straightforward review surface ready-to-merge PR is approved, current, and waiting for final CI or merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants