Commit 8595e93
[Metrics] Improve relay metrics reliability with early initialization (#1780)
## Summary
Improve relay metrics reliability by initializing variables early and
using deferred metrics recording to ensure consistent data collection.
### Primary Changes:
- Initialize `supplierOperatorAddress` and `serviceId` with default
values before relay request unmarshalling
- Move metrics recording to deferred function to guarantee execution
regardless of function exit path
- Ensure `RelaysTotal` and relay duration metrics are always captured,
even on early error returns
### Secondary changes:
- Updated error reply handling to include default `ServiceId` for
consistent metric labeling
- Improved variable scope and reuse for better code organization
## Issue:
Problem: Relay metrics could be inconsistently recorded when requests
failed early in processing, leading to gaps in monitoring data and
unreliable dashboards.
## Type of change
Select one or more from the following:
- [ ] Bug fix
- [ ] New feature, functionality or library
- [x] Code health or cleanup
- [ ] Documentation
- [ ] Other (specify)
## Sanity Checklist
- [ ] I have updated the GitHub Issue Metadata: `assignees`,
`reviewers`, `labels`, `project`, `iteration` and `milestone`
- [ ] For docs: `make docusaurus_start`
- [ ] For small changes: `make go_develop_and_test` and `make test_e2e`
- [ ] For major changes: `devnet-test-e2e` label to run E2E tests in CI
- [ ] For migration changes: `make test_e2e_oneshot`
- [ ] 'TODO's, configurations and other docs
---------
Co-authored-by: Claude <[email protected]>1 parent 91d56e4 commit 8595e93
3 files changed
+41
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
20 | 29 | | |
21 | 30 | | |
22 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
53 | 76 | | |
54 | 77 | | |
55 | 78 | | |
| |||
72 | 95 | | |
73 | 96 | | |
74 | 97 | | |
75 | | - | |
| 98 | + | |
| 99 | + | |
76 | 100 | | |
77 | 101 | | |
78 | 102 | | |
| |||
83 | 107 | | |
84 | 108 | | |
85 | 109 | | |
86 | | - | |
| 110 | + | |
87 | 111 | | |
88 | 112 | | |
89 | 113 | | |
90 | 114 | | |
91 | 115 | | |
92 | 116 | | |
93 | | - | |
| 117 | + | |
94 | 118 | | |
95 | 119 | | |
96 | 120 | | |
97 | 121 | | |
98 | | - | |
| 122 | + | |
99 | 123 | | |
100 | 124 | | |
101 | 125 | | |
| |||
218 | 242 | | |
219 | 243 | | |
220 | 244 | | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | 245 | | |
232 | 246 | | |
233 | 247 | | |
| |||
360 | 374 | | |
361 | 375 | | |
362 | 376 | | |
363 | | - | |
| 377 | + | |
364 | 378 | | |
365 | 379 | | |
366 | 380 | | |
| |||
0 commit comments