Add monitoring.metrics-return-all-points flag#6
Conversation
Report every data point in the requested interval (each stamped with its own end time) instead of only the most recent one. Defaults to false, so existing behavior is unchanged. In all-points mode a series' points share labels and differ only by timestamp, so the deduplicator now mixes the point end time into its signature (gated on the new flag) to avoid collapsing them into one. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 10 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. 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: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThis PR adds optional timestamp-based deduplication to ChangesReturn-all-points feature
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Exporter as stackdriver_exporter
participant Collector as MonitoringCollector
participant Dedup as MetricDeduplicator
participant Prom as Prometheus Metrics
Exporter->>Collector: NewMonitoringCollector(ReturnAllPoints)
Collector->>Dedup: set includeTimestamp=true
Collector->>Collector: reportTimeSeriesMetrics(timeSeries)
loop for each point (all or newest)
Collector->>Dedup: CheckAndMark(signature, pointEndTime)
alt not duplicate
Collector->>Prom: emit metric value
else duplicate or error
Collector->>Dedup: RevertMark(signature, pointEndTime)
end
end
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@collectors/monitoring_collector.go`:
- Around line 568-584: Sort the return-all-points path in
monitoring_collector.go before iterating: when c.returnAllPoints is true,
pointsToReport should be ordered by Interval.EndTime ascending so older samples
are processed first. Update the logic around timeSeries.Points and the loop in
the collection path to sort pointsToReport by parsed end time before computing
pointEndTime and collecting metrics, preserving the existing nil checks and
parsing behavior.
🪄 Autofix (Beta)
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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b2200464-2ddb-4296-a4d7-096b4a403a04
📒 Files selected for processing (5)
collectors/deduplicator.gocollectors/deduplicator_benchmark_test.gocollectors/deduplicator_test.gocollectors/monitoring_collector.gostackdriver_exporter.go
DELTA metrics under AggregateDeltas only accumulate strictly-newer samples in the counter store. GCP returns points newest-first, so feeding them in that order made the store keep only the newest and drop the rest, silently undercounting. Sort points oldest-first so the full window accumulates in chronological order; the store's ReportTime check still prevents double-counting across overlapping scrape windows. Order is irrelevant for gauges/distributions, so this is harmless there. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
What
Adds a
--monitoring.metrics-return-all-pointsflag (defaultfalse). When enabled, the collector reports every data point in the requested interval, each stamped with its own end time, instead of only the most recent one. Defaultfalse→ existing behavior is byte-for-byte unchanged.Why
The collector keeps only the newest point per series in the request window. For a large window (e.g. a 60m interval), all intermediate points are discarded. This flag lets a caller backfill the full window.
Changes
stackdriver_exporter.go— new flag, wired intoMonitoringCollectorOptions.collectors/monitoring_collector.go— newReturnAllPointsoption;reportTimeSeriesMetricsloops over all points (each with its own parsed end time) when enabled, else the single newest point as before.collectors/deduplicator.go— in all-points mode a series' points share labels and differ only by timestamp, so the deduplicator mixes the point end time into its signature (gated on the flag) to avoid collapsing them into one. Default path untouched.TestMetricDeduplicator_IncludeTimestamp; fixed the benchmark's directhashLabelscall.Not a breaking change
The timestamp is not a new mechanism — the exporter already stamps each emitted metric with its point's end time via
NewMetricWithTimestamp.Note on DELTA + AggregateDeltas
For DELTA metrics with
AggregateDeltas, points feed the delta counter store rather than being emitted directly, and the store only accepts strictly-newer samples. In all-points mode this is at best a no-op (GCP returns points newest-first) and can double-count across overlapping windows. The flag is intended for GAUGE/DISTRIBUTION snapshot metrics; deltas should stay on newest-only or be verified before enabling.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes