Repository navigation
fix(otel)!: print OTel v2 spans to stdout only when the operator asks - #48723
Conversation
…dout With LITELLM_OTEL_V2 on and a vendor callback such as langfuse_otel or arize holding operator credentials, the proxy printed every span as JSON to stdout, prompts included, on the request path. Nobody set OTEL_EXPORTER, but the console placeholder that OpenTelemetryV2Config folds in for an empty exporter list stayed next to the vendor's own exporter. The provider now skips that placeholder when the config has any other exporter. A console exporter the operator names with OTEL_EXPORTER=console is kept, and so is the placeholder when it is the only exporter.
|
bugbot run |
[Medium impact] The reviewed changes appear safe to merge, with both numbered findings fixed SummaryThis PR stops unrequested OTel v2 span output while keeping explicitly configured console exporters and the plain The latest changes carry that console choice through service-name routing and remove inherited Langfuse keys from tests that require no global keys. Both numbered findings are fixed. No new actionable issue was found in the changes since the previous review
Reviews (4) · Last reviewed commit: "fix(otel): keep the otel callback's cons..." · Reviewed by Greptile |
Merging this PR will not alter performance1 warning
Comparing |
…L_* env from the stdout check
|
bugbot run |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
The proxy's background V2 logger (published when no callback built one, which is what key-only and team-only Langfuse destinations run under) also kept the unconfigured console exporter, so it printed every span with prompts to stdout. The console default now prints only for a listed otel callback or an exporter the operator named.
…utes A key or team otel_service_name moves the call onto a provider the tenant tracer cache builds, which never got the console choice, so the plain otel callback stopped printing those calls. The no-operator-keys integration rig also drops inherited Langfuse keys.
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 4e50a92. Configure here.
…tdout exporter (#49129) #48718 added TestLangfuseDestinationFields while #48723 made the unconfigured stdout placeholder opt-in (console_default=True, the otel callback's setting). Both merged within a minute, so main's integrations job fails six tests that read the placeholder's exporter. Build those providers with console_default=True so the operator-exporter checks keep their target.
With the OTel v2 path on (
LITELLM_OTEL_V2=true), the proxy printed every span, prompts included, to stdout even though nobody asked for a console exporter: next to a Langfuse or Arize callback, for keys and teams that send traces to their own Langfuse project, and with no callback at all. That costs CPU on the request path and floods logs. After this PR, spans go to stdout only when the operator asks for it:OTEL_EXPORTER=console, a console exporter in the config, or the plainotelcallback with nothing else configured.Details
TLDR
Problem this solves:
How it solves it:
otelcallbackOTEL_EXPORTER=consoleandkind: consoleexporters still print, as beforeIntentional product change: V2 proxies stop printing span JSON to stdout unless the operator asks. Set
OTEL_EXPORTER=consoleto keep it.User Flow
Before: a team's key sends traces to the team's own Langfuse project, and the proxy's stdout fills with every request's span JSON, prompt included
LITELLM_OTEL_V2=trueand noOTEL_EXPORTER, with or withoutcallbacks: ["langfuse_otel"]and global Langfuse keysmetadata.loggingsendslangfuse_oteltraces to the team's Langfuse project{"name": "chat gpt-4o-mini", "context": {...}}block per span, prompt text includedAfter: the same setup sends traces to Langfuse only
OTEL_EXPORTEROTEL_EXPORTER=consolebrings it backLinear ticket
Refs LIT-10205
This fixes the stdout dump the ticket reports (V2, global Langfuse keys) and the one in the reporter's next setup (per-key Langfuse, no global keys). The missing tags and user on per-key traces without global keys is #48718. Both PRs add tests to
test_otel_v2_destinations.py, in different classes.Behavior changes
Removed / renamed
Silent regressions to watch
OTEL_EXPORTER=console.callbacks: ["langfuse_otel", "otel"]with noOTEL_*env stops printing, becauseotellisted second reuses the Langfuse tracer;["otel", "langfuse_otel"]still prints.Migration for existing customers
OTEL_EXPORTER=console.Regression tests
tests/integration/observability/test_langfuse_otel_console_output.py: real proxy and a local Langfuse sink. With global keys, stdout has no span JSON whenOTEL_EXPORTERis unset and has it with=console. With only a key-level Langfuse destination and no global keys, stdout has none, whetherlangfuse_otelis listed or not. Red on main, green here.tests/unit/integrations/otel/test_otel_v2_destinations.py::TestConsolePlaceholder: Langfuse with keys exports only to Langfuse, a named console exporter prints, theotelcallback prints when nothing else is configured, and the proxy's background tracer prints only withOTEL_EXPORTER=console. The background-tracer case fails on main; theotelcase fails if the callback stops asking for the console default.TestArizeTenantOnlytests no longer expect the stdout copy.Pre-Submission checklist
Screenshots / Proof of Fix
Live A/B on one VM, base and head side by side:
cf7c35a1174fada02e3060, which is this PR's head4e50a922e8bmerged intocf7c35a1174gpt-4o-mini, real Langfuse Cloud, Arize AX, AgentOps and W&B Weave/api/public/v2/observationsKey-only Langfuse on the head proxy, no global keys. The dashboard Logs page shows chat, messages and responses calls made with a key whose
metadata.loggingsendslangfuse_otelto its team's Langfuse project. The proxy printed 0 spans to stdout during those calls.The chat call's trace in that key's Langfuse project (
chatcmpl-Ee5WJSOrwSIWTrORnaaMhSJi7iQPI, useraudit-user):Before (
cf7c35a1174): the key-only setup still prints span JSONLITELLM_OTEL_V2=true, noOTEL_EXPORTER, no global Langfuse keys, no callbacksmetadata.loggingsendslangfuse_otelto its team's Langfuse projectAfter (
fada02e3060): same setup, same stepsEvery leg, stdout span JSON blocks before → after:
callbacks: [langfuse_otel], global keys: chat, messages, responses × (SDK sync, SDK async stream, curl), bad model 400, provider 401, unauthenticated 401, same request ×3, disable header, key withlitellm_disabled_callbackssuccess_callback/failure_callbacklangfuse_otelwith global keys, mixed traffic plus a per-key call[langfuse_otel, otel], noOTEL_*env (declared)callbacks: [langfuse_otel], no global keysotelalone /[otel, langfuse_otel]OTEL_EXPORTER=console/kind: consolespec /OTEL_EXPORTER=""langfuse_otel, no keysReporter's prod config, anonymized, run on stock 1.104.1, main
cf7c35a1174and this PR:langfuse_otelsuccess_and_failure, their four-callback list, theirOTEL_BSP_*andLITELLM_LOG=ERROR, 2 workersChaos (2 workers, local Langfuse recorder):
/health/services?service=langfuse_otelduring the outageNotes on the chaos run:
tests/integration/observability/test_langfuse_otel_console_output.pypassed 4 runs in a row atINTEGRATION_WORKERS=4. The OTel unit suites pass: 1563 tests.ran /live-pr-risk on
4e50a922e8band found no regressions/backward incompatible risks beyond the declared stdout changeType
🐛 Bug Fix
Caveats (if any)
Medium
langfuse_otelincallbacksorsuccess_callbackand no global Langfuse keys, the old per-request Langfuse logger still prints its own span once per successful request that has no key destination.failure_callbackprints nothingraw_gen_ai_requestspan with the promptlangfuse_otelwithout keys keeps its own console fallback (4 span blocks on both sides)Low
Final Attestation
Note
Medium Risk
Intentional breaking change for anyone relying on silent stdout span dumps without
OTEL_EXPORTER=console; observability wiring is central but scoped to placeholder console export, not OTLP or fan-out.Overview
Stops unrequested console span dumps on the OTel v2 path. When no exporter was configured, config normalization still folded in a placeholder console spec, so Langfuse/Arize callbacks, per-key destinations, and the proxy background tracer all printed full span JSON (prompts included) to stdout.
How it changes:
build_tracer_providernow skips that placeholder unlessconsole_default=True. That flag is threaded throughOpenTelemetryV2,build_otel_v2_logger, andTenantTracerCache, and is set only when the proxy builds the plainotelcallback inlitellm_logging.py. Explicit operator choices (OTEL_EXPORTER=console, a configured console exporter) still export to stdout.is_unconfigured_placeholdermoves tomodel/config.pyfor shared use with preset helpers.Tests: New integration coverage for Langfuse + stdout behavior; unit
TestConsolePlaceholderand updated Arize tenant tests that no longer expect the extra stdout copy.Reviewed by Cursor Bugbot for commit 4e50a92. Bugbot is set up for automated code reviews on this repo. Configure here.