refactor(metrics): untangle metrics from exporter#1118
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (2)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
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.
9e80593 to
9a68c2c
Compare
Description
The
Exportertype used to own the userspaceMetricsobject and all other objects would grab the metrics they needed from there. However, becauseExporterrequires theBpfobject to take the kernel metrics map from it and theBpfobject requires theExporterto 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,
Metricsis no longer owned byExporter, instead an independent instance ofMetricsis created and the bits needed by other components are passed to them, then anExporteris created which registers all metrics from this same object. With this, the newsetup_inputmethod can return a tuple withOption<KernelMetrics>and the receiver end of the generated events, which is cleaner than returning the entire exporter.Checklist
Automated testing
If any of these don't apply, please comment below.
Testing Performed