refactor(metrics): improve d_instantiate dispatch metric tracking - #1455
refactor(metrics): improve d_instantiate dispatch metric tracking#1455Molter73 wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughThe change adds dedicated mkdir and symlink counters to ChangesKernel metric extensions
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant trace_d_instantiate
participant KernelMetric
participant refresh_labels
trace_d_instantiate->>KernelMetric: provide d_instantiate metrics
KernelMetric->>KernelMetric: encode base, mkdir, and symlink counters
KernelMetric->>refresh_labels: return metric label/value pairs
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## mauro/chore/configurable-d-instantiate-ctx #1455 +/- ##
==============================================================================
- Coverage 34.45% 34.17% -0.28%
==============================================================================
Files 22 22
Lines 3373 3400 +27
Branches 3373 3400 +27
==============================================================================
Hits 1162 1162
- Misses 2206 2233 +27
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
acc07ac to
9ea568b
Compare
9ea568b to
158ce06
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
fact-ebpf/src/lib.rs (1)
217-259: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd focused tests for the new metric contract.
Codecov reports zero patch coverage for these changes. Add tests before merge to protect counter aggregation and label encoding.
fact-ebpf/src/lib.rs#L217-L259: Test base andd_instantiateaccumulation and all encoded label/value pairs.fact/src/metrics/kernel_metrics.rs#L49-L55: Test that encoded d_instantiate labels create and update separate Prometheus counters.fact/src/metrics/mod.rs#L28-L40: Test conversion ofAddedMkDirandAddedSymlinkto metric label values.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@fact-ebpf/src/lib.rs` around lines 217 - 259, Low test coverage leaves the new kernel metric aggregation and encoding contract unprotected. In fact-ebpf/src/lib.rs lines 217-259, add focused tests for metrics_by_hook_t and metrics_d_instantiate_t accumulation and every encoded label/value pair; in fact/src/metrics/kernel_metrics.rs lines 49-55, verify AddedMkDir and AddedSymlink create and update separate Prometheus counters; in fact/src/metrics/mod.rs lines 28-40, verify both labels convert to the expected metric label values.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@fact-ebpf/src/bpf/main.c`:
- Line 367: Move the added_mkdir increment at fact-ebpf/src/bpf/main.c:367 and
the added_symlink increment at fact-ebpf/src/bpf/main.c:379 into the successful
event-emission paths of submit_mkdir_event and submit_symlink_event,
respectively, alongside base.added. Do not increment either subtype counter when
reservation or event preparation returns without emitting an event.
---
Nitpick comments:
In `@fact-ebpf/src/lib.rs`:
- Around line 217-259: Low test coverage leaves the new kernel metric
aggregation and encoding contract unprotected. In fact-ebpf/src/lib.rs lines
217-259, add focused tests for metrics_by_hook_t and metrics_d_instantiate_t
accumulation and every encoded label/value pair; in
fact/src/metrics/kernel_metrics.rs lines 49-55, verify AddedMkDir and
AddedSymlink create and update separate Prometheus counters; in
fact/src/metrics/mod.rs lines 28-40, verify both labels convert to the expected
metric label values.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Enterprise
Run ID: 421c0e08-6f7e-4c3d-8385-c11933dc3286
📒 Files selected for processing (6)
fact-ebpf/src/bpf/main.cfact-ebpf/src/bpf/types.hfact-ebpf/src/lib.rsfact/src/config/mod.rsfact/src/metrics/kernel_metrics.rsfact/src/metrics/mod.rs
Add new metrics to the d_instantiate hook that allow for tracking individual event types dispatched. This is helpful to identify if one of these types are being lost by comparing the `Added` label from the originating hook (like path_mkdir or path_symlink) with the corresponding `Added<hook>` label. In order for `d_instantiate` to have its own type some trait + iterator gymnastics were necessary. The summary for this is: * A new `KernelMetric` trait is created which describes how metrics coming from the kernel should be accumulated and encoded using a `KernelMetricLabel` helper type. * The trait is implemented for `metrics_by_hook_t` and `metrics_d_instantiate_t`. * The metrics module know how to translate from `KernelMetricLabel` to `LabelValues`, so it does the same `accumulate` process it used to do and then uses the iterator produced by `encode` to add metrics dynamically.
158ce06 to
956d0c0
Compare
|
Please provide sample metrics. |
Description
Add new metrics to the d_instantiate hook that allow for tracking individual event types dispatched. This is helpful to identify if one of these types are being lost by comparing the
Addedlabel from the originating hook (like path_mkdir or path_symlink) with the correspondingAdded<hook>label.In order for
d_instantiateto have its own type some trait + iterator gymnastics were necessary. The summary for this is:KernelMetrictrait is created which describes how metrics coming from the kernel should be accumulated and encoded using aKernelMetricLabelhelper type.metrics_by_hook_tandmetrics_d_instantiate_t.KernelMetricLabeltoLabelValues, so it does the sameaccumulateprocess it used to do and then uses the iterator produced byencodeto add metrics dynamically.Checklist
Automated testing
If any of these don't apply, please comment below.
Testing Performed
Example metrics for d_instantiate from a mkdir test:
Full metrics from that same test
Summary by CodeRabbit
New Features
Improvements
d_instantiate_ctx_sizeconfiguration requires adjustment.