Skip to content

feat(epp): add OTel span to prefix cache affinity filter decisions - #2594

Open
sudoalok wants to merge 1 commit into
llm-d:mainfrom
sudoalok:feat/2539-prefix-filter-traces
Open

feat(epp): add OTel span to prefix cache affinity filter decisions#2594
sudoalok wants to merge 1 commit into
llm-d:mainfrom
sudoalok:feat/2539-prefix-filter-traces

Conversation

@sudoalok

Copy link
Copy Markdown
Contributor

The prefix-cache-affinity filter already records its decision as a metric,
but there's no span for it. So when you look at a trace you can see the
request went through the filter, but not what it decided or why.

This adds a filter_prefix_cache_affinity span, following the same
pattern as pd_profile_handler.go.

What's on the span:

  • llm_d.epp.filter.decision - the outcome. I'm setting this from the
    same outcome* constants that recordDecision already uses, so the
    span value and the metric label are always the same thing and can't
    drift apart later.
  • llm_d.epp.filter.candidate_endpoints and
    llm_d.epp.filter.sticky_endpoints - so you can see how much the
    filter narrowed things down.
  • llm_d.epp.filter.ttft_penalty_ms - what the load gate actually
    measured. I set this before the threshold check, so you still see the
    number on traces where the gate didn't trip.
  • gen_ai.request.model and gen_ai.request.id, same as the other
    scheduling plugins.

Two small things while I was in there: the request param was _ so I
named it, since I need it for the request attributes. And
bestStickyTTFT-bestNonStickyTTFT was being calculated twice, so I
pulled it into a penalty variable.

I didn't add a span test - disagg and preciseprefixcache don't assert
spans in their unit tests either, so I followed what they do. Let me know
if you'd rather have one.

Also left out mmobs.SpanAttributes(request) that the siblings have,
since this filter doesn't deal with multimodal at all. Easy to add if you
want it for consistency.

Fixes #2539

Filter records one of five decision outcomes as a metric but emits no
span, so a trace shows a request passing through the filter without
showing what it decided or why.

Adds a filter_prefix_cache_affinity span carrying the decision using the
same outcome constants the metric records, so the trace and the metric
cannot drift. Also records the candidate and sticky endpoint counts, and
the TTFT penalty the load gate compares against its threshold; the
penalty is recorded whether or not the gate trips.

Fixes llm-d#2539

Signed-off-by: Alok Behera <alokbeherak061@gmail.com>
@sudoalok
sudoalok requested review from a team and kaushikmitr as code owners August 27, 2026 12:51
@sudoalok
sudoalok requested review from hexfusion and vMaroon August 27, 2026 12:51
@github-actions github-actions Bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. area/epp area/scheduling labels Aug 27, 2026
@ahg-g

ahg-g commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

pls see #2503, we have a new pattern for setting attributes, can we please follow that?

/assign @gyliu513

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/epp area/scheduling size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add OTL traces to prefix cache filter decisions

2 participants