fix(site-explorer): widen duration histogram buckets#2704
Conversation
Default OpenTelemetry histogram buckets top out at 10 seconds, so site explorer iteration latency observations on production sites land in +Inf. Register explicit millisecond buckets up to one hour for site explorer duration histograms. Fixes NVIDIA#2352 Signed-off-by: Susan Poudel <susanpdl77@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
Summary by CodeRabbit
WalkthroughThis PR resolves a histogram bucket misconfiguration for site-explorer latency metrics by introducing explicit millisecond bucket boundaries. It adds ChangesSite Explorer Histogram Bucket Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
This PR improves observability for carbide-site-explorer by configuring explicit OpenTelemetry histogram buckets (in milliseconds) that extend up to 1 hour, so long-running site explorer operations no longer concentrate in the +Inf bucket and become unusable for monitoring.
Changes:
- Add a reusable
site_explorer_latency_histogram_view()helper that builds an explicit-bucket histogram view for site explorer duration metrics. - Export the helper from
carbide-site-explorerand register the views incarbide-api-core’s metrics setup. - Add dependencies (
carbide-metrics-utils,opentelemetry_sdk) and a unit test to ensure the view builder succeeds.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| crates/site-explorer/src/metrics.rs | Adds explicit histogram bucket boundaries + a helper for constructing OTel views; adds a basic build test. |
| crates/site-explorer/src/lib.rs | Re-exports the view helper for use by other crates. |
| crates/site-explorer/Cargo.toml | Adds dependencies needed to build OTel metric views. |
| crates/api-core/src/logging/setup.rs | Registers the new site-explorer histogram views during meter provider construction (and mirrors it in tests). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/site-explorer/src/metrics.rs (1)
769-777: ⚡ Quick winPrefer table-driven cases for the view-construction test.
This test calls the same fallible operation with multiple input variants; converting it to a scenario table will make extension and failure labeling cleaner.
As per coding guidelines, “Reach for a table whenever two or more tests call the same operation with different inputs.”
🤖 Prompt for 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. In `@crates/site-explorer/src/metrics.rs` around lines 769 - 777, The test function site_explorer_latency_histogram_views_build calls the same operation site_explorer_latency_histogram_view multiple times with different inputs. Refactor this into a table-driven test by creating a collection of test case tuples containing the input string and a descriptive label for each variant, then iterate over this collection to call the function once per case. This will make the test more maintainable and easier to extend with additional cases in the future.Source: Coding guidelines
🤖 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.
Nitpick comments:
In `@crates/site-explorer/src/metrics.rs`:
- Around line 769-777: The test function
site_explorer_latency_histogram_views_build calls the same operation
site_explorer_latency_histogram_view multiple times with different inputs.
Refactor this into a table-driven test by creating a collection of test case
tuples containing the input string and a descriptive label for each variant,
then iterate over this collection to call the function once per case. This will
make the test more maintainable and easier to extend with additional cases in
the future.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: c35b0c86-848f-422b-a183-f8d94cf1ebec
📒 Files selected for processing (4)
crates/api-core/src/logging/setup.rscrates/site-explorer/Cargo.tomlcrates/site-explorer/src/lib.rscrates/site-explorer/src/metrics.rs
Keep the default millisecond buckets through 10 seconds so sub-second endpoint timings stay useful, then extend the upper range to one hour. Narrow the view filter to carbide_site_explorer_*_latency so histograms that declare seconds units are not given millisecond bucket boundaries. Signed-off-by: Susan Poudel <susanpdl77@gmail.com>
Summary
Site explorer iteration latency uses the default OpenTelemetry histogram buckets, which top out at 10 seconds. On production sites most observations land in the
+Infbucket, so the metric is not useful for monitoring.This change registers explicit millisecond buckets up to one hour for site explorer duration histograms, including iteration latency and per endpoint exploration duration.
Fixes #2352
Test plan
cargo test -p carbide-site-explorercarbide_site_explorer_iteration_latency_milliseconds_bucketobservations spread across buckets above 10s instead of concentrating in+Inf