Skip to content

refactor(metrics): untangle metrics from exporter#1118

Open
Molter73 wants to merge 1 commit into
mauro/feat/replay-inputfrom
mauro/refactor/untangle-metrics
Open

refactor(metrics): untangle metrics from exporter#1118
Molter73 wants to merge 1 commit into
mauro/feat/replay-inputfrom
mauro/refactor/untangle-metrics

Conversation

@Molter73

@Molter73 Molter73 commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Description

The Exporter type used to own the userspace Metrics object and all other objects would grab the metrics they needed from there. However, because Exporter requires the Bpf object to take the kernel metrics map from it and the Bpf object requires the Exporter to get its userspace metrics from, it created a pretty naste chicken and egg problem. With the addition of the replay feature, this became a bit of a mess.

To clean up the code a bit, Metrics is no longer owned by Exporter, instead an independent instance of Metrics is created and the bits needed by other components are passed to them, then an Exporter is created which registers all metrics from this same object. With this, the new setup_input method can return a tuple with Option<KernelMetrics> and the receiver end of the generated events, which is cleaner than returning the entire exporter.

Checklist

  • Patch has a change log entry OR does not need one.
  • Investigated and inspected CI test results
  • Updated documentation accordingly

Automated testing

  • Added unit tests
  • Added integration tests
  • Added regression tests

If any of these don't apply, please comment below.

Testing Performed

  • Check the result of tests for metrics still being recorded as expected.

@Molter73 Molter73 requested a review from a team as a code owner July 15, 2026 14:34
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (2)
  • main
  • ^release-*$

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Enterprise

Run ID: 79a751d1-b98b-4770-b8bf-ff01274aa3df

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mauro/refactor/untangle-metrics

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

@codecov-commenter

codecov-commenter commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 56 lines in your changes missing coverage. Please review.
✅ Project coverage is 32.17%. Comparing base (a6af5d5) to head (9a68c2c).

Files with missing lines Patch % Lines
fact/src/lib.rs 0.00% 27 Missing ⚠️
fact/src/bpf/mod.rs 0.00% 10 Missing ⚠️
fact/src/metrics/mod.rs 0.00% 9 Missing ⚠️
fact/src/metrics/exporter.rs 0.00% 6 Missing ⚠️
fact/src/metrics/kernel_metrics.rs 0.00% 4 Missing ⚠️
Additional details and impacted files
@@                     Coverage Diff                     @@
##           mauro/feat/replay-input    #1118      +/-   ##
===========================================================
- Coverage                    32.29%   32.17%   -0.13%     
===========================================================
  Files                           22       22              
  Lines                         3090     3102      +12     
  Branches                      3090     3102      +12     
===========================================================
  Hits                           998      998              
- Misses                        2089     2101      +12     
  Partials                         3        3              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The `Exporter` type used to own the userspace `Metrics` object and all
other objects would grab the metrics they needed from there. However,
because `Exporter` requires the `Bpf` object to take the kernel metrics
map from it and the `Bpf` object requires the `Exporter` to get its
userspace metrics from, it created a pretty naste chicken and egg
problem. With the addition of the replay feature, this became a bit of
a mess.

To clean up the code a bit, `Metrics` is no longer owned by `Exporter`,
instead an independent instance of `Metrics` is created and the bits
needed by other components are passed to them, then an `Exporter` is
created which registers all metrics from this same object. With this,
the new `setup_input` method can return a tuple with
`Option<KernelMetrics>` and the receiver end of the generated events,
which is cleaner than returning the entire exporter.
@Molter73 Molter73 force-pushed the mauro/refactor/untangle-metrics branch from 9e80593 to 9a68c2c Compare July 15, 2026 15:00
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