Skip to content

feat(sensor): Add sensor-scanner config info metrics#19392

Open
vikin91 wants to merge 3 commits intomasterfrom
piotr/qol-sensor-scanner-info-metric
Open

feat(sensor): Add sensor-scanner config info metrics#19392
vikin91 wants to merge 3 commits intomasterfrom
piotr/qol-sensor-scanner-info-metric

Conversation

@vikin91
Copy link
Contributor

@vikin91 vikin91 commented Mar 12, 2026

Description

Add Sensor info metrics that make scanner topology immediately visible from metrics, without depending on startup logs:

  • rox_sensor_scanner_configuration_info{local,mode,delegated} 1
  • rox_sensor_image_indexing_route_info{for_images,indexer} 1

What this solves:

  • Investigators can quickly tell whether local scanning is enabled, whether Sensor is in v2/v4 mode, whether delegated scanning is enabled, and what indexing route is intended for cluster_local vs non_cluster_local images.

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

  • newly added unit tests for the metrics
  • on a cluster
# TYPE rox_sensor_image_indexing_route_info gauge
rox_sensor_image_indexing_route_info{for_images="cluster_local",indexer="central_scanner"} 1
rox_sensor_image_indexing_route_info{for_images="non_cluster_local",indexer="central_scanner"} 1

# TYPE rox_sensor_scanner_configuration_info gauge
rox_sensor_scanner_configuration_info{delegated="false",local="false",mode="none"} 1

Expose static Sensor metrics that describe intended scanner mode and image indexing route (cluster-local vs non-cluster-local), so investigators can infer scanner setup without relying on startup logs. Also refresh values on Central capability handshake and cover mode permutations with unit tests.

AI-assisted: I generated the metric wiring, lifecycle hook, and tests; you defined/refined the metric semantics, naming, and help-text intent in review.
@vikin91
Copy link
Contributor Author

vikin91 commented Mar 12, 2026

This change is part of the following stack:

Change managed by git-spice.

@openshift-ci
Copy link

openshift-ci bot commented Mar 12, 2026

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

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@rhacs-bot
Copy link
Contributor

rhacs-bot commented Mar 12, 2026

Images are ready for the commit at 4454c8b.

To use with deploy scripts, first export MAIN_IMAGE_TAG=4.11.x-312-g4454c8bb9c.

@codecov
Copy link

codecov bot commented Mar 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.68%. Comparing base (52688db) to head (4454c8b).
⚠️ Report is 10 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master   #19392    +/-   ##
========================================
  Coverage   49.68%   49.68%            
========================================
  Files        2700     2701     +1     
  Lines      203278   203392   +114     
========================================
+ Hits       100999   101063    +64     
- Misses      94753    94806    +53     
+ Partials     7526     7523     -3     
Flag Coverage Δ
go-unit-tests 49.68% <100.00%> (+<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.

@vikin91 vikin91 marked this pull request as ready for review March 13, 2026 10:44
@vikin91 vikin91 requested a review from a team as a code owner March 13, 2026 10:44
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Calling UpdateScannerConfigurationInfo() from init() means the initial metric values are computed before Central capabilities are known, so scannerMode will always start as v2; consider only updating after capabilities are set (or documenting this behavior) to avoid a briefly misleading topology view after startup.
  • UpdateScannerConfigurationInfo() relies on Reset() on registered GaugeVecs, which can be problematic under concurrent collection; consider avoiding Reset() and instead explicitly setting only the desired label combinations (e.g., ensure a single With(...).Set(1) per info timeseries and no others) to make the update operation safer and more predictable.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Calling `UpdateScannerConfigurationInfo()` from `init()` means the initial metric values are computed before Central capabilities are known, so `scannerMode` will always start as `v2`; consider only updating after capabilities are set (or documenting this behavior) to avoid a briefly misleading topology view after startup.
- `UpdateScannerConfigurationInfo()` relies on `Reset()` on registered `GaugeVec`s, which can be problematic under concurrent collection; consider avoiding `Reset()` and instead explicitly setting only the desired label combinations (e.g., ensure a single `With(...).Set(1)` per info timeseries and no others) to make the update operation safer and more predictable.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@vikin91
Copy link
Contributor Author

vikin91 commented Mar 13, 2026

/retest

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