Skip to content

feat(metrics): bound dimensional timeseries groups - #1842

Merged
aleksdotbar merged 8 commits into
mainfrom
feat/1781-weekly-git-output
Jul 23, 2026
Merged

feat(metrics): bound dimensional timeseries groups#1842
aleksdotbar merged 8 commits into
mainfrom
feat/1781-weekly-git-output

Conversation

@aleksdotbar

@aleksdotbar aleksdotbar commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Adds bounded top-N dimension groups with stable Other remainder, ranked series totals, and typed metric-results schemas.

Summary by CodeRabbit

  • New Features
    • Added group_limit support for timeseries results, including ranking by another metric and optional remainder groups.
    • Timeseries responses now return per-series total, rank, remainder, and label metadata.
  • Documentation
    • Expanded analytics OpenAPI documentation with typed request/response schemas for metric results, plus detailed view-specific DTOs.
  • Bug Fixes
    • Improved metric view row-limit enforcement to validate per-view results.
  • Tests
    • Updated OpenAPI and timeseries planning coverage for the new group-limited ranking behavior.

Signed-off-by: Aleksandr Barkhatov <pm@aleks.bar>
@aleksdotbar
aleksdotbar requested a review from a team as a code owner July 22, 2026 07:58
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The metric-results API now exposes typed OpenAPI request and response schemas. Timeseries requests support validated group limits, shared ranking queries, capped SQL grouping, and response metadata for totals, ranks, remainder groups, and labels.

Changes

Metric results API and timeseries flow

Layer / File(s) Summary
Typed metric-results contract
docs/components/backend/analytics/openapi.json, src/backend/services/analytics/src/api/..., src/backend/services/analytics/src/domain/metric_results/dto.rs, src/backend/services/analytics/src/domain/metric_results/view.rs
Metric-results requests, responses, view unions, computations, histogram values, period values, peer values, and timeseries values receive typed OpenAPI schemas.
Group-limit validation
src/backend/services/analytics/src/domain/metric_results/validation.rs
Timeseries group limits resolve ranking metrics, enforce count and compatibility rules, normalize metric keys, and contribute to row-limit projections.
Ranking and capped query planning
src/backend/services/analytics/src/domain/metric_results/batch.rs, src/backend/services/analytics/src/domain/metric_results/compiler.rs
Ranking policies produce shared ranking queries, and timeseries compilation supports capped grouping, totals, ranks, remainder rows, labels, and updated parameter binding.
Timeseries execution and response metadata
src/backend/services/analytics/src/api/metric_results.rs, src/backend/services/analytics/src/domain/metric_results/builder.rs
Ranking rows are fetched concurrently, planned queries consume resolved rankings, and timeseries responses include aggregate metadata with updated ordering and size enforcement.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant metric_results
  participant ranking_queries
  participant planned_queries
  participant response_builder
  Client->>metric_results: POST /v1/metric-results
  metric_results->>ranking_queries: fetch ranking rows
  ranking_queries-->>metric_results: ranked groups
  metric_results->>planned_queries: plan and execute timeseries queries
  planned_queries-->>response_builder: timeseries rows with metadata
  response_builder-->>Client: MetricResultsResponse
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly reflects the bounded timeseries group work, which is a main part of the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/1781-weekly-git-output

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Checkov (3.3.8)
docs/components/backend/analytics/openapi.json

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 `@src/backend/services/analytics/src/domain/metric_results/dto.rs`:
- Around line 40-44: Update MetricGroupLimitRequest.count with a schema
constraint of minimum 1 and maximum 50 to match validate_group_limit’s enforced
range. Regenerate the OpenAPI artifact at
docs/components/backend/analytics/openapi.json; do not edit it manually.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: c1816b95-1520-4b39-aeaa-bcf48e75742d

📥 Commits

Reviewing files that changed from the base of the PR and between 767a66b and a1eb982.

📒 Files selected for processing (12)
  • docs/components/backend/analytics/openapi.json
  • src/backend/services/analytics/src/api/metric_results.rs
  • src/backend/services/analytics/src/api/mod.rs
  • src/backend/services/analytics/src/api/openapi_tests.rs
  • src/backend/services/analytics/src/domain/metric_definitions/definition.rs
  • src/backend/services/analytics/src/domain/metric_results/batch.rs
  • src/backend/services/analytics/src/domain/metric_results/builder.rs
  • src/backend/services/analytics/src/domain/metric_results/compiler.rs
  • src/backend/services/analytics/src/domain/metric_results/dto.rs
  • src/backend/services/analytics/src/domain/metric_results/mod.rs
  • src/backend/services/analytics/src/domain/metric_results/validation.rs
  • src/backend/services/analytics/src/domain/metric_results/view.rs

Comment thread src/backend/services/analytics/src/domain/metric_results/dto.rs
Signed-off-by: Aleksandr Barkhatov <pm@aleks.bar>
Signed-off-by: Aleksandr Barkhatov <pm@aleks.bar>
Signed-off-by: Aleksandr Barkhatov <pm@aleks.bar>
Signed-off-by: Aleksandr Barkhatov <pm@aleks.bar>
@aleksdotbar
aleksdotbar enabled auto-merge July 22, 2026 12:18

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/backend/services/analytics/src/domain/metric_results/compiler.rs (1)

842-885: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add exact ratio-bind regression assertions.

Placeholder-count checks do not catch a numerator/denominator bind swap after splitting grouped_value_params from metric_where_params. Assert exact params order for ratio ranking and both capped and uncapped timeseries queries.

🤖 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 `@src/backend/services/analytics/src/domain/metric_results/compiler.rs` around
lines 842 - 885, Add regression assertions that compare the complete params
vector, including exact ordering, for ratio ranking, capped timeseries, and
uncapped timeseries queries. Cover numerator and denominator bindings explicitly
so swaps are detected, while retaining existing placeholder-count checks and
using the relevant query/compiler test symbols.
🤖 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 `@src/backend/services/analytics/src/domain/metric_results/compiler.rs`:
- Around line 842-885: Add regression assertions that compare the complete
params vector, including exact ordering, for ratio ranking, capped timeseries,
and uncapped timeseries queries. Cover numerator and denominator bindings
explicitly so swaps are detected, while retaining existing placeholder-count
checks and using the relevant query/compiler test symbols.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e4c995a7-db12-43d3-8d50-d5a101dbfb74

📥 Commits

Reviewing files that changed from the base of the PR and between a1eb982 and 7c6d65a.

📒 Files selected for processing (10)
  • docs/components/backend/analytics/openapi.json
  • src/backend/services/analytics/src/api/metric_results.rs
  • src/backend/services/analytics/src/api/mod.rs
  • src/backend/services/analytics/src/domain/metric_definitions/definition.rs
  • src/backend/services/analytics/src/domain/metric_results/batch.rs
  • src/backend/services/analytics/src/domain/metric_results/builder.rs
  • src/backend/services/analytics/src/domain/metric_results/compiler.rs
  • src/backend/services/analytics/src/domain/metric_results/dto.rs
  • src/backend/services/analytics/src/domain/metric_results/mod.rs
  • src/backend/services/analytics/src/domain/metric_results/validation.rs
🚧 Files skipped from review as they are similar to previous changes (8)
  • src/backend/services/analytics/src/domain/metric_results/mod.rs
  • src/backend/services/analytics/src/domain/metric_definitions/definition.rs
  • src/backend/services/analytics/src/api/mod.rs
  • src/backend/services/analytics/src/api/metric_results.rs
  • src/backend/services/analytics/src/domain/metric_results/batch.rs
  • src/backend/services/analytics/src/domain/metric_results/dto.rs
  • docs/components/backend/analytics/openapi.json
  • src/backend/services/analytics/src/domain/metric_results/validation.rs

@aleksdotbar
aleksdotbar merged commit 40d1ed5 into main Jul 23, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants