litellm/tests/unit/integrations/otel
Mateo Wang fd2c0b3236
fix(otel): honor message redaction and the mask flags on Langfuse OTel v2 observations (#55716)
* fix(otel): keep the prompt and reply off the Langfuse root observation when message logging is redacted

* fix(otel): honor the otel callback's own message logging settings on the Langfuse root observation

* fix(otel): honor mask_input and mask_output on the Langfuse root observation and generation, and leave other loggers' roots alone

The OTel v2 Langfuse integration ignored the mask_input and mask_output request flags (body metadata or the
langfuse_mask_* headers), so Langfuse showed the prompt and reply on both the root observation and the generation.
Each masked side is now written as redacted-by-litellm on both, matching the older langfuse callback.

The Langfuse logger also stamped its root input and output on a request root another OTel v2 logger started, so
with callbacks ["otel", "langfuse_otel"] the otel callback's own message_logging: false was bypassed. The stamp
now needs the root to come from this logger's own tracer provider.

* fix(otel): keep masked content off Langfuse entirely and let any source turn a mask on

The Langfuse export view now drops the raw gen_ai and other vendor copies of an input or output whose
Langfuse observation is masked, so a masked request sends no prompt or reply text to Langfuse. Other
exporters keep them, since plain OpenTelemetry does not read the Langfuse mask flags.

A mask is on when the body, an admin default, or a langfuse_mask_* header turns it on, so a header set
to false can no longer unmask it. A masked stream no longer buffers its chunks for the root output.

* fix(otel): keep logging fields an admin excluded off the Langfuse root observation

With standard_logging_payload_excluded_fields set to messages or response, the
generation already dropped them but the root observation still carried the raw
prompt and reply. The root now leaves out its input when messages is excluded
and its output when response is excluded

* fix(otel): keep a masked Langfuse observation on a span at its attribute limit

When a key or team sends to Langfuse and the proxy's own logger does not map
Langfuse, the Langfuse fields written for that destination shed first once a span
reaches its attribute limit. The masked input and output went with them, so the
Langfuse view no longer knew to drop the raw gen_ai copies and sent them on.

A masked observation now stays on the span, so a masked prompt or response never
reaches Langfuse raw however full the span is

* fix(otel): stamp the Langfuse root another logger started when that logger logs content, and carry masks to Langfuse without attribute slots

* fix(otel): keep a masked call masked on the operator's own Langfuse export at its attribute limit

* test(otel): annotate the new single-assignment test variables as Final
2026-12-04 04:29:20 +00:00
..
__init__.py test: move tests/test_litellm integrations and secret_managers into tests/unit (#43194) 2026-09-25 12:57:07 -07:00
test_db_endpoint.py fix(otel): name postgres service spans by operation and table (#44240) 2026-10-03 09:20:28 -07:00
test_langfuse_logger.py fix(otel): honor message redaction and the mask flags on Langfuse OTel v2 observations (#55716) 2026-12-04 04:29:20 +00:00
test_otel_v2_baggage.py feat(otel): add Mixpanel OpenTelemetry v2 preset callback (#49999) 2026-11-25 10:27:02 -08:00
test_otel_v2_components.py fix(otel): honour OTEL_METRIC_EXPORT_INTERVAL for the OTel metric readers (#55868) 2026-12-04 03:30:23 +00:00
test_otel_v2_config_baggage_parenting_guardrails.py fix(otel): tolerate non-dict callback_settings.otel and ignore bare EXCLUDED_SERVICES env (#44086) 2026-10-02 12:36:46 -07:00
test_otel_v2_destinations.py fix(otel): honor message redaction and the mask flags on Langfuse OTel v2 observations (#55716) 2026-12-04 04:29:20 +00:00
test_otel_v2_dynamic.py refactor(typing): clear 66 basedpyright Any errors across 50 files (#55237) 2026-12-01 04:58:03 +00:00
test_otel_v2_emitter.py fix(otel): honor redact_user_api_key_info for key identity on OTel v2 spans (#55724) 2026-12-02 13:25:08 -08:00
test_otel_v2_logger.py fix(otel): honor redact_user_api_key_info for key identity on OTel v2 spans (#55724) 2026-12-02 13:25:08 -08:00
test_otel_v2_metrics.py fix(otel): label configured pass-through routes litellm.passthrough and read the operation from the upstream (#48675) 2026-10-28 10:48:34 -07:00
test_otel_v2_mount.py fix(otel): keep the FastAPI server span when the proxy runs under ddtrace-run (#54016) 2026-11-30 16:47:05 -08:00
test_otel_v2_multibackend.py test: move tests/test_litellm integrations and secret_managers into tests/unit (#43194) 2026-09-25 12:57:07 -07:00
test_otel_v2_named_trace.py fix(decisions): accept multipart image uploads on /v1/systemone (#55352) 2026-12-03 21:27:26 +00:00
test_otel_v2_presets.py test(unit): make 21 flaky unit tests deterministic (#54785) 2026-11-26 20:48:13 -08:00
test_otel_v2_sources_of_truth.py feat(otel): group service spans by background job run (#54513) 2026-11-27 20:53:04 -08:00
test_otel_v2_vendor_mappers.py fix(otel): honor message redaction and the mask flags on Langfuse OTel v2 observations (#55716) 2026-12-04 04:29:20 +00:00
test_runtime.py feat(otel): trace auto-router configuration and classifier failures (#44926) 2026-10-06 15:40:34 -07:00