Skip to content

feat(idea): api_counter metric#18080

Draft
parametalol wants to merge 5 commits intomichael/scoped-and-global-trackersfrom
michael/api_counter_metric
Draft

feat(idea): api_counter metric#18080
parametalol wants to merge 5 commits intomichael/scoped-and-global-trackersfrom
michael/api_counter_metric

Conversation

@parametalol
Copy link
Contributor

@parametalol parametalol commented Dec 5, 2025

Description

The idea is to track API requests in order to track problems with API clients. The clients could be identified by their User-Agent.

image

User-facing documentation

Testing and quality

  • the change is production ready: the change is GA, or otherwise the functionality is gated by a feature flag
  • CI results are inspected

Automated testing

  • added unit tests
  • added e2e tests
  • added regression tests
  • added compatibility tests
  • modified existing tests

How I validated my change

User-agent test

sh$ curl -ks https://localhost:8000/metrics -u "admin:admin" | grep api | grep metrics
rox_central_api_request_total{Method="GET",Path="/metrics",Status="200",UserAgent="curl/8.15.0",UserID="admin"} 3
...
sh$ curl -ks https://localhost:8000/metrics -u "admin:admin" --user-agent "test-ua" | grep api | grep metrics
rox_central_api_request_total{Method="GET",Path="/metrics",Status="200",UserAgent="curl/8.15.0",UserID="admin"} 4
rox_central_api_request_total{Method="GET",Path="/metrics",Status="200",UserAgent="test-ua",UserID="admin"} 1

Aggregation test

Having two metrics: total with all labels and some with only Path, Status, UserID:

rox_central_api_request_some{Path="/metrics",Status="200",UserID="admin"} 4
...
rox_central_api_request_total{Method="GET",Path="/metrics",Status="200",UserAgent="curl/8.15.0",UserID="admin"} 3
rox_central_api_request_total{Method="GET",Path="/metrics",Status="200",UserAgent="test",UserID="admin"} 1

Current dependencies on/for this PR:

@openshift-ci
Copy link

openshift-ci bot commented Dec 5, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@rhacs-bot
Copy link
Contributor

rhacs-bot commented Dec 5, 2025

Images are ready for the commit at 0d43fc3.

To use with deploy scripts, first export MAIN_IMAGE_TAG=4.11.x-23-g0d43fc3216.

@codecov
Copy link

codecov bot commented Dec 5, 2025

Codecov Report

❌ Patch coverage is 62.59542% with 49 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.93%. Comparing base (aac1f0a) to head (5430a52).

Files with missing lines Patch % Lines
central/metrics/custom_registry.go 15.00% 31 Missing and 3 partials ⚠️
central/apirequestlog/interceptor.go 69.23% 8 Missing ⚠️
central/metrics/custom/tracker/tracker_base.go 89.09% 3 Missing and 3 partials ⚠️
pkg/telemetry/phonehome/client.go 50.00% 1 Missing ⚠️
Additional details and impacted files
@@                         Coverage Diff                         @@
##           michael/scoped-and-global-trackers   #18080   +/-   ##
===================================================================
  Coverage                               48.93%   48.93%           
===================================================================
  Files                                    2619     2620    +1     
  Lines                                  197581   197664   +83     
===================================================================
+ Hits                                    96686    96734   +48     
- Misses                                  93519    93547   +28     
- Partials                                 7376     7383    +7     
Flag Coverage Δ
go-unit-tests 48.93% <62.59%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@parametalol parametalol force-pushed the michael/scoped-and-global-trackers branch from 58a6dae to e6ac4e1 Compare February 2, 2026 16:47
@parametalol parametalol force-pushed the michael/api_counter_metric branch from 5430a52 to 0d43fc3 Compare February 2, 2026 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants