Skip to content

test(integration): wait for the stalled-tenant root span and accept a bare POST name - #49406

Merged
yucheng-berri merged 1 commit into
mainfrom
litellm_lazy_route_server_span_name
Oct 31, 2026
Merged

yucheng-berri merged 1 commit into
mainfrom
litellm_lazy_route_server_span_name

Conversation

@yucheng-berri

@yucheng-berri yucheng-berri commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

test_stalled_tenant_during_a_mixed_burst_keeps_serving_and_each_teams_policy looked for each request's server span by the name prefix "POST ", in a snapshot taken as soon as the model span arrived. Two things made that snapshot miss the root. When the burst is the first /v1/messages traffic a proxy sees, the route is still being registered lazily, so the server span is named plain POST. And the server span ends after the response is sent, so it can land in a later export than the model span. The test now waits for the server span and matches POST with or without the route, and every other check is unchanged

Details

TLDR

Problem this solves:

  • The stalled-tenant test fails when its burst is the proxy's first /v1/messages traffic
  • It can also read the trace before the server span is exported

How it solves it:

  • Wait until the server span arrives, and match names that start with POST
  • Still asserts exactly one root per request, and the redaction checks are untouched

Relevant issues

It failed in 6 of the 8 scheduled integration runs on main from 10-29 to 10-31, always at assert len(roots) == 1 with an empty list. The proxy registers the Anthropic /v1/messages router on its first matching request, and the FastAPI instrumentation names the server span from the routes that exist when the span starts. The requests that trigger or wait on that registration therefore get a span named POST with no http.route, and later requests get POST /v1/messages. Whether the test hits this depends on whether an earlier test in the module already sent /v1/messages to the same proxy

With only the name match loosened, the test still failed once in 7 runs on the VM, with no server span found at all. Waiting for the server span the same way the test already waits for the model span closes that gap

A live run against Langfuse Cloud shows the same naming on a real proxy, with the first burst named POST and the second burst named POST /v1/messages. That naming only affects OTel V2 users and the first requests per worker, so this PR leaves the product as is and fixes the test

Behavior changes

None. Only one integration test changes

Pre-Submission checklist

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

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • Every automated review on my PR's latest commit has finished, and I have addressed or replied to each of its findings before requesting a maintainer review

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

E2E exception at fa75833. The diff only changes how one integration test finds its root span, so there is no proxy behavior to show before and after

The test runs through the real integration runner with a real proxy, Postgres and OTel sinks, on a Linux VM with 2 workers. On main at 837f36e the stalled-tenant test failed 3 of 3 runs. With this change

LEG stalled1 exit=0 1 passed in 77.13s
LEG stalled2 exit=0 1 passed in 78.69s
LEG stalled3 exit=0 1 passed in 79.47s
LEG stalled4 exit=0 1 passed in 80.45s
LEG stalled5 exit=0 1 passed in 80.55s
LEG module21 exit=0 22 passed in 92.04s   (whole module, order seed 21)
LEG module7_1 exit=0 22 passed in 91.52s  (whole module, order seed 7)
LEG module7_2 exit=0 22 passed in 91.76s
LEG module7_3 exit=0 22 passed in 92.33s

Type

✅ Test


Note

Low Risk
Test-only change to integration span polling and naming; no production or proxy behavior modified.

Overview
Fixes flaky test_stalled_tenant_during_a_mixed_burst_keeps_serving_and_each_teams_policy by changing how it collects each request’s OTel server root span from the operator sink.

The test no longer snapshots traces as soon as the model span and marker appear (_with_content). It now eventually waits until a server span is present too, via new helpers _with_root and _is_root. Root detection accepts span names starting with POST (covering bare POST before lazy route registration) instead of requiring the POST prefix with route.

Per-request assertions are unchanged: still exactly one root, then the same redaction vs content twin checks.

Reviewed by Cursor Bugbot for commit fa75833. Bugbot is set up for automated code reviews on this repo. Configure here.

@codspeed

codspeed Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning

⚠️ 1 benchmark is dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 43 untouched benchmarks


Comparing litellm_lazy_route_server_span_name (94e1c25) with main (a392a39)

Open in CodSpeed

@codecov

codecov Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@yucheng-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@yucheng-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@greptile-apps

greptile-apps Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] This test-only change appears safe to merge

Summary

This PR fixes how one integration test finds each request’s server span. It accepts both bare POST and route-qualified names, and waits for that span before counting roots. The root-count and content checks remain in place. No new actionable issues were found

  • The burst test waits for each request’s root span.

Reviews (2) · Last reviewed commit: "test(integration): wait for the stalled-..." · Reviewed by Greptile

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread litellm/integrations/otel/mount.py Resolved
@yucheng-berri
yucheng-berri force-pushed the litellm_lazy_route_server_span_name branch from 94e1c25 to fa75833 Compare October 31, 2026 18:48
@yucheng-berri yucheng-berri changed the title fix(otel): name the server span after a lazily registered route test(integration): wait for the stalled-tenant root span and accept a bare POST name Oct 31, 2026
@yucheng-berri

Copy link
Copy Markdown
Contributor Author

@greptileai review latest head

@yucheng-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 fa75833. Configure here.

@yucheng-berri
yucheng-berri merged commit 8d202fa into main Oct 31, 2026
90 of 91 checks passed
@yucheng-berri
yucheng-berri deleted the litellm_lazy_route_server_span_name branch October 31, 2026 19:24
DeoLeung pushed a commit to aiyou178/litellm that referenced this pull request Nov 5, 2026
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