feat: Move observation from libsy to libsy-llm-client - #332
Conversation
The client is in a better position to time the call, because it makes the call. That gives us more accurate stats and locates the observation in the natural place. Finally it means you can use `run_stream` without having to implement an observer. Mostly a straight code move. Now supports timing multiple concurrent overlapping LLM calls. Thanks Opus for catching that! I also renamed testing function `drive` to `test_drive`, because it clashed with regular function `drive`. And a minor `metrics::` import change for readability. Part of #310 Assisted-by: Codex:GPT 5.6 Sol medium Reviewed-by: Claude:Opus 5 medium Signed-off-by: Graham King <grahamk@nvidia.com>
|
@CodeRabbit review |
|
✅ Action performedReview finished.
|
WalkthroughThe change moves request-scoped observations into ChangesRun observability migration
Estimated code review effort: 4 (Complex) | ~45 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/libsy-llm-client/src/run.rs`:
- Around line 181-195: Capture the end timestamp immediately after
RoutedLlmClient::call completes, before invoking
observability::observe_client_call(result), and compute the duration from that
timestamp. Keep the subsequent observation and result handling unchanged so
LlmCallObservation::duration measures only the client call.
In `@docs/internal/metrics_reference.md`:
- Line 60: Update the `switchyard_routing_overhead_ms` documentation to state
that successful algorithm completion is required for recording, or move the
`RoutingOverhead` emission in `run` before propagating errors from
`drive(...).await?`. Ensure runs with a successful routed call followed by an
algorithm or concurrent-serving error still record the overhead metric.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 89d1d284-9904-41a1-bbc0-a9a95483133c
📒 Files selected for processing (21)
crates/libsy-llm-client/Cargo.tomlcrates/libsy-llm-client/src/client.rscrates/libsy-llm-client/src/lib.rscrates/libsy-llm-client/src/metrics.rscrates/libsy-llm-client/src/observability.rscrates/libsy-llm-client/src/observation.rscrates/libsy-llm-client/src/run.rscrates/libsy-llm-client/tests/observability.rscrates/libsy/src/algorithms/fall_through.rscrates/libsy/src/algorithms/llm_class.rscrates/libsy/src/algorithms/noop.rscrates/libsy/src/algorithms/passthrough.rscrates/libsy/src/algorithms/rand.rscrates/libsy/src/algorithms/stage.rscrates/libsy/src/algorithms/subagent_affinity_tests.rscrates/libsy/src/core/algorithm.rscrates/libsy/src/core/testing.rscrates/libsy/src/lib.rscrates/libsy/src/observability.rscrates/switchyard-server/src/lib.rsdocs/internal/metrics_reference.md
💤 Files with no reviewable changes (1)
- crates/libsy-llm-client/src/observability.rs
Thanks Code Rabbit! Signed-off-by: Graham King <grahamk@nvidia.com>
ayushag-nv
left a comment
There was a problem hiding this comment.
lgtm ! RoutedCallWindows approach is cool
The client is in a better position to time the call, because it makes
the call. That gives us more accurate stats and locates the observation
in the natural place. Finally it means you can use
run_streamwithouthaving to implement an observer.
Mostly a straight code move.
Now supports timing multiple concurrent overlapping LLM calls. Thanks Opus
for catching that!
I also renamed testing function
drivetotest_drive, because itclashed with regular function
drive. And a minormetrics::importchange for readability.
Part of #310
Assisted-by: Codex:GPT 5.6 Sol medium
Reviewed-by: Claude:Opus 5 medium
Signed-off-by: Graham King grahamk@nvidia.com
Summary by CodeRabbit