Commit 8fbcf90
committed
refactor(metrics): extract collect_matching_samples to Metric<T> impl
Improve AI-generated code.
Moves the collect_matching_samples helper method from individual aggregate
implementations to the generic Metric<T> implementation, making it reusable
across all aggregate functions.
- Add collect_matching_samples method to Metric<T> for filtering samples
by label criteria
- Remove code duplication between Sum and Avg aggregate implementations
- Improve code organization by centralizing sample collection logic
- Maintain backward compatibility and all existing functionality
This refactoring improves maintainability by providing a single, well-tested
implementation of sample filtering that can be used by current and future
aggregate functions.1 parent 384b887 commit 8fbcf90
2 files changed
+16
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
| 16 | + | |
20 | 17 | | |
21 | 18 | | |
22 | 19 | | |
23 | 20 | | |
24 | 21 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 22 | + | |
29 | 23 | | |
30 | 24 | | |
31 | 25 | | |
| |||
36 | 30 | | |
37 | 31 | | |
38 | 32 | | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
| 33 | + | |
44 | 34 | | |
45 | 35 | | |
46 | 36 | | |
47 | 37 | | |
48 | 38 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
| 39 | + | |
53 | 40 | | |
54 | 41 | | |
55 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
81 | 92 | | |
82 | 93 | | |
83 | 94 | | |
| |||
0 commit comments