Skip to content

fix(otel): preserve Splunk Observability Cloud trace OTLP endpoint - #26183

Merged
ishaan-berri merged 4 commits into
BerriAI:litellm_ishaan_apri21from
milan-berri:litellm_otel_splunk_trace_endpoint
Apr 22, 2026
Merged

fix(otel): preserve Splunk Observability Cloud trace OTLP endpoint#26183
ishaan-berri merged 4 commits into
BerriAI:litellm_ishaan_apri21from
milan-berri:litellm_otel_splunk_trace_endpoint

Conversation

@milan-berri

@milan-berri milan-berri commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Splunk ingest uses /v2/trace/otlp; _normalize_otel_endpoint must not append /v1/traces.

  • Return trace endpoints unchanged when they match Splunk OTLP path patterns
  • Add unit tests for observability.splunkcloud.com, signalfx.com, and /trace/otlp suffix
  • Set OTEL_EXPORTER_OTLP_PROTOCOL in protocol selection tests (from_env precedence over OTEL_EXPORTER)

Relevant issues

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/test_litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

CI (LiteLLM team)

CI status guideline:

  • 50-55 passing tests: main is stable with minor issues.
  • 45-49 passing tests: acceptable but needs attention
  • <= 40 passing tests: unstable; be careful with your merges and assess the risk.
  • Branch creation CI run
    Link:

  • CI run for the last commit
    Link:

  • Merge / cherry-pick CI run
    Links:

Screenshots / Proof of Fix

image

Type

🐛 Bug Fix
✅ Test

Changes

Changes

  • OTLP traces URL: Skip appending /v1/traces when the endpoint is Splunk-style …/v2/trace/otlp (fixes broken …/v2/trace/otlp/v1/traces URLs).
  • Tests: Cover Splunk/SignalFx-style ingest URLs; collapse duplicate cases with parameterized.expand. Set OTEL_EXPORTER_OTLP_PROTOCOL in protocol-selection tests so from_env() stays deterministic.

Splunk ingest uses /v2/trace/otlp; _normalize_otel_endpoint must not append /v1/traces.

- Return trace endpoints unchanged when they match Splunk OTLP path patterns
- Add unit tests for observability.splunkcloud.com, signalfx.com, and /trace/otlp suffix
- Set OTEL_EXPORTER_OTLP_PROTOCOL in protocol selection tests (from_env precedence over OTEL_EXPORTER)

Made-with: Cursor
@greptile-apps

greptile-apps Bot commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a bug in _normalize_otel_endpoint where Splunk Observability Cloud OTLP endpoints (/v2/trace/otlp) were incorrectly having /v1/traces appended, producing broken URLs. The fix adds an early-return guard for the Splunk path pattern, and restores test coverage of the OTEL_EXPORTER env-var fallback that the existing tests were inadvertently bypassing.

Confidence Score: 5/5

Safe to merge — targeted bug fix with no backwards-incompatible changes and full test coverage for the new code paths.

The guard is minimal and correctly scoped: it only fires for signal_type == 'traces' containing /v2/trace/otlp, leaving all other normalization paths unaffected. The prior concern about OTEL_EXPORTER fallback coverage is addressed by the two new dedicated tests. No P0/P1 findings remain.

No files require special attention.

Important Files Changed

Filename Overview
litellm/integrations/opentelemetry.py Four-line guard added to _normalize_otel_endpoint to skip rewriting when the endpoint contains /v2/trace/otlp; fix is correctly placed after the trailing-slash strip and before the standard path logic.
tests/test_litellm/integrations/test_opentelemetry.py Adds parameterized tests for Splunk/SignalFx OTLP URLs; existing protocol tests updated to use OTEL_EXPORTER_OTLP_PROTOCOL for determinism; new fallback tests added to preserve OTEL_EXPORTER regression coverage.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["_normalize_otel_endpoint(endpoint, signal_type)"] --> B{signal_type valid?}
    B -- No --> C[Return endpoint unchanged]
    B -- Yes --> D[Strip trailing slash]
    D --> E{traces signal AND\ncontains /v2/trace/otlp?}
    E -- Yes --> F[Return endpoint unchanged\nSplunk OTLP path preserved]
    E -- No --> G{Already ends with\n/v1/signal_type?}
    G -- Yes --> H[Return endpoint]
    G -- No --> I{Ends with another\n/v1/signal path?}
    I -- Yes --> J[Replace signal segment and return]
    I -- No --> K[Append /v1/signal_type and return]
Loading

Reviews (3): Last reviewed commit: "test(otel): cover OTEL_EXPORTER fallback..." | Re-trigger Greptile

Comment thread litellm/integrations/opentelemetry.py Outdated
@codecov

codecov Bot commented Apr 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@ishaan-berri
ishaan-berri changed the base branch from litellm_internal_staging to litellm_ishaan_apri21 April 22, 2026 02:24
@ishaan-berri
ishaan-berri merged commit 33216b1 into BerriAI:litellm_ishaan_apri21 Apr 22, 2026
42 checks passed
ishaan-berri added a commit that referenced this pull request Apr 22, 2026
* fix(otel): preserve Splunk Observability Cloud trace OTLP endpoint (#26183)

* fix(otel): preserve Splunk Observability Cloud trace OTLP URL

Splunk ingest uses /v2/trace/otlp; _normalize_otel_endpoint must not append /v1/traces.

- Return trace endpoints unchanged when they match Splunk OTLP path patterns
- Add unit tests for observability.splunkcloud.com, signalfx.com, and /trace/otlp suffix
- Set OTEL_EXPORTER_OTLP_PROTOCOL in protocol selection tests (from_env precedence over OTEL_EXPORTER)

Made-with: Cursor

* test(otel): use parameterized.expand for Splunk OTLP URL cases

Made-with: Cursor

* fix(otel): narrow Splunk trace URL guard to /v2/trace/otlp only

Made-with: Cursor

* test(otel): cover OTEL_EXPORTER fallback when OTLP protocol env unset

Made-with: Cursor

* Add Openrouter Opus 4.7 Entry (#26130)

---------

Co-authored-by: milan-berri <milan@berri.ai>
Co-authored-by: Matt Greathouse <matt5316@gmail.com>
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
* fix(otel): preserve Splunk Observability Cloud trace OTLP endpoint (BerriAI#26183)

* fix(otel): preserve Splunk Observability Cloud trace OTLP URL

Splunk ingest uses /v2/trace/otlp; _normalize_otel_endpoint must not append /v1/traces.

- Return trace endpoints unchanged when they match Splunk OTLP path patterns
- Add unit tests for observability.splunkcloud.com, signalfx.com, and /trace/otlp suffix
- Set OTEL_EXPORTER_OTLP_PROTOCOL in protocol selection tests (from_env precedence over OTEL_EXPORTER)

Made-with: Cursor

* test(otel): use parameterized.expand for Splunk OTLP URL cases

Made-with: Cursor

* fix(otel): narrow Splunk trace URL guard to /v2/trace/otlp only

Made-with: Cursor

* test(otel): cover OTEL_EXPORTER fallback when OTLP protocol env unset

Made-with: Cursor

* Add Openrouter Opus 4.7 Entry (BerriAI#26130)

---------

Co-authored-by: milan-berri <milan@berri.ai>
Co-authored-by: Matt Greathouse <matt5316@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants