Repository navigation
feat(observability): attribute inference traces to admitted routes - #819
Merged
Merged
Conversation
XuPeng-SH
approved these changes
Sep 19, 2026
Contributor
Merge Queue Status
This pull request spent 18 minutes 6 seconds in the queue, including 17 minutes 50 seconds running CI. Required conditions to merge
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add admitted-route attribution to inference request traces as a foundation for model-router evaluation. Accepted and terminal records now identify the route, logical invocation, upstream model, execution placement, and access source.
Correct usage diagnostics so unavailable usage remains unknown and partial usage does not produce full-request budget errors or cache-read ratios. This helps maintainers distinguish retries, execution outcomes, and incomplete telemetry when analyzing model performance.
Related issue
Related to #764. This PR adds tracing foundations; it does not implement automatic model selection.
Change type
User and compatibility impact
Existing request diagnostics and session observability expose an optional
routeprojection. Model-selection behavior and configuration remain unchanged.Older stored records deserialize with unknown route attribution. Because diagnostic readers reject unknown fields, deployment requires upgraded readers and recovery workers before new producers, or a coordinated upgrade that drains older instances.
Unavailable usage now produces absent usage values and nullable diagnostic token columns. Aggregate request counters still include these attempts; token totals represent observed usage rather than complete billing.
Architecture and complexity delta
Canonical owner changed or extended: The existing inference ledger and
ModelRequestContextEventprojection. No new tables or execution authority.Existing implementations and callers searched: Offering admission, inference planning and settlement, recovery, request-context queries, session observability, reflection, and integration tests.
Superseded code, states, tables, shims, or self-only tests removed: Replaced duplicated foreground/recovery usage calculations with one shared projection helper.
If parallel implementations remain, their boundary and retirement condition: Foreground settlement and recovery retain their existing persistence responsibilities and share usage-projection semantics. No parallel routing implementation was introduced.
Verification
Commands and results:
cargo test --locked --offline -p astra-services --lib -q, 1,950 passed, 69 ignored. Rerun outside the sandbox after local mock-server socket restrictions caused failures.Public entrypoint exercised: Public entrypoint exercised: No live HTTP/UI entrypoint exercised. Tests cover inference planning and request-event generation; existing request queries and session observability consume the extended projection.
Unhappy paths exercised: Physical retries, distinct logical invocations and owners, failed/cancelled outcomes, unavailable and partial usage, measured zero usage, stale diagnostic measurements, legacy records without route attribution, recovery projection, and exclusion of admission/owner tokens.
Database verification: No schema migration. Updated MatrixOne integration assertions cover route linkage, nullable unavailable-usage columns, and aggregate request accounting. These tests were statically checked but not executed against MatrixOne because no disposable test database was configured. Query and transaction behavior still requires live database verification.
Final checklist
explained why no test is needed.
change needs no documentation update.
generated files, and other sensitive information.