Skip to content

feat: add report_calls prometheus metric for Report gRPC method#484

Open
RohanKaran wants to merge 1 commit intoKuadrant:mainfrom
RohanKaran:feat/report-calls-metrics
Open

feat: add report_calls prometheus metric for Report gRPC method#484
RohanKaran wants to merge 1 commit intoKuadrant:mainfrom
RohanKaran:feat/report-calls-metrics

Conversation

@RohanKaran
Copy link
Copy Markdown

@RohanKaran RohanKaran commented May 4, 2026

Fixes #440

Adds a new report_calls Prometheus counter to track calls to the Report gRPC method introduced in #439.

The new metric follows the same pattern as the existing authorized_calls and limited_calls counters:

# HELP report_calls Report calls
# TYPE report_calls counter
report_calls{limitador_namespace="test_namespace"} 5

Changes

  • Register report_calls counter with describe_counter! in PrometheusMetrics
  • Add incr_report_calls() helper on PrometheusMetrics
  • Call incr_report_calls() in KuadrantService::report() after a successful update_counters call
  • Add unit tests in prometheus_metrics.rs and kuadrant_service.rs

Summary by CodeRabbit

  • Chores

    • Improved system observability by introducing new Prometheus metrics to track reporting activity by namespace, providing enhanced visibility into performance patterns and resource utilisation across different environments.
  • Tests

    • Added unit tests to validate the accuracy of new metrics tracking and ensure correct namespace-based measurement.

Add a new Prometheus counter 'report_calls' to track calls to the
Report gRPC method introduced in Kuadrant#439.

- Register 'report_calls' counter with describe_counter! in PrometheusMetrics
- Add incr_report_calls() helper method on PrometheusMetrics
- Call incr_report_calls() in KuadrantService::report() after successful
  counter update, consistent with the existing authorized_calls and
  limited_calls pattern in ShouldRateLimit

Closes Kuadrant#440

Signed-off-by: rohankaran <rohankaran001@gmail.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

📝 Walkthrough

Walkthrough

A new Prometheus counter metric report_calls tracks invocations of the Report gRPC method. The PrometheusMetrics struct gains an incr_report_calls method, and KuadrantService::report increments this metric when handling requests. Unit tests verify the metric is correctly recorded per namespace.

Changes

Report Metrics Tracking

Layer / File(s) Summary
Metric Definition
limitador-server/src/prometheus_metrics.rs (line 69)
New Prometheus counter report_calls is registered via describe_counter!.
Metric Increment Logic
limitador-server/src/prometheus_metrics.rs (lines 100–104)
incr_report_calls method increments the counter with namespace and context-derived labels, following the pattern of existing metrics.
Integration
limitador-server/src/envoy_rls/kuadrant_service.rs (lines 167–173)
KuadrantService::report calls self.metrics.incr_report_calls to record each report invocation.
Tests
limitador-server/src/prometheus_metrics.rs (lines 410–442), limitador-server/src/envoy_rls/kuadrant_service.rs (lines 622–697)
Unit tests verify report_calls is incremented and emitted correctly per namespace.

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 The Report now whispers its tale,
Each call counted, metrics prevail,
Prometheus hears every chime—
A counter that tracks passing time! 📊✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 63.64% 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
Title check ✅ Passed The title accurately summarizes the main change: adding a new Prometheus metric for the Report gRPC method.
Linked Issues check ✅ Passed The PR fully addresses issue #440 by implementing the report_calls Prometheus counter metric with namespace labels as requested.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the report_calls metric; no out-of-scope modifications detected.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

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.

ReportRateLimit Metrics

1 participant