Add reusable latency histogram helpers - #416
Conversation
|
Warning Review limit reached
Next review available in: 51 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdded ChangesLatency metrics
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 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 `@ovos_utils/metrics.py`:
- Around line 120-123: Update the bucket key construction in the metrics method
containing the buckets comprehension to use a round-trip-safe bound
representation such as .17g instead of :g, ensuring distinct close bounds retain
separate dictionary entries. Add a test using bounds like 1.0000001 and
1.0000002 to verify both keys and cumulative counts are preserved.
- Around line 53-59: Update the measurement class’s finish method to synchronize
access to _running, _finished, and _elapsed_ms with a measurement-level lock. In
finish, acquire the lock, return for an already-finished measurement,
pause/update the elapsed state as needed, and set _finished before calling
_histogram.observe_ms so concurrent calls record exactly once.
🪄 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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 43dd5b75-a757-449d-bd79-bfb255f7c8ce
📒 Files selected for processing (2)
ovos_utils/metrics.pytest/unittests/test_metrics.py
Summary
Add reusable, dependency-free latency histogram primitives to
ovos_utils.metrics:Why
OVOS Core, Workshop, and intent pipeline packages need the same low-level timing and histogram storage without importing one another or creating a dependency cycle. This keeps metric ownership in each instrumented package while giving their process-local metrics providers one shared implementation.
The helper intentionally has no Prometheus server, labels, request identifiers, or runtime policy. Export remains the host runtime's responsibility through the existing metrics-provider entry point.
This is the prerequisite proposed in the architecture discussion on OpenVoiceOS/ovos-workshop#509. Consumer PRs can switch to this API after an
ovos-utilsalpha containing it is published, with explicit minimum-version bumps.Validation
ruff check ovos_utils/metrics.py test/unittests/test_metrics.pyPYTHONPATH=. pytest -q test/unittests/test_metrics.py— 19 passedgit diff --checkSummary by CodeRabbit
New Features
Bug Fixes