Commit dfe419b
## Summary of changes
Refactor `StatsFlusher::new` to accept a `stats_url: String` parameter
instead of deriving the URL internally from `config.site`.
## Reason for change
1. **Removes internal duplication** —
`trace_stats_url(&self.config.site)` was being called in two separate
places inside `StatsFlusher` (in `get_or_init` and again in the retry
loop). It's now computed once at the call site.
2. **Enables future flexibility** — callers can supply any URL (e.g. a
custom endpoint or test harness) without `StatsFlusher` needing to know
about it.
3. **Better separation of concerns** — `StatsFlusher` no longer owns URL
resolution; it simply uses the URL it's given. This mirrors how
`TraceFlusher` already works, where the URL comes from outside via
`SendData`'s embedded `Endpoint`.
## Implementation details
- Added a `stats_url: String` field to `StatsFlusher` and a
corresponding parameter to `StatsFlusher::new`.
- Removed the `trace_stats_url` import from `stats_flusher.rs`; the call
now lives in `main.rs::start_trace_agent`.
- Replaced the two internal `trace_stats_url(&self.config.site)` calls
with `self.stats_url`.
- Retry-loop debug logs now report `endpoint.url` so they reflect the
URL actually contacted instead of a re-derived site URL.
## Test coverage
No new tests — this is a pure refactor of an internal constructor
signature with no behavior change. Verified existing checks pass:
- [x] `cargo build` on the bottlecap crate
- [x] `cargo check --workspace` — clean
- [x] `RUSTFLAGS="-D warnings" cargo clippy --workspace --all-targets
--features default` — clean
- [x] `cargo fmt --all -- --check` — clean
- [x] `cargo nextest run --workspace` — 526/526 passed
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 5586013 commit dfe419b
2 files changed
Lines changed: 10 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1131 | 1131 | | |
1132 | 1132 | | |
1133 | 1133 | | |
| 1134 | + | |
1134 | 1135 | | |
1135 | 1136 | | |
1136 | 1137 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
| 42 | + | |
40 | 43 | | |
41 | 44 | | |
42 | 45 | | |
| |||
64 | 67 | | |
65 | 68 | | |
66 | 69 | | |
67 | | - | |
68 | 70 | | |
69 | | - | |
| 71 | + | |
70 | 72 | | |
71 | 73 | | |
72 | 74 | | |
| |||
92 | 94 | | |
93 | 95 | | |
94 | 96 | | |
95 | | - | |
96 | | - | |
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
| 111 | + | |
| 112 | + | |
112 | 113 | | |
113 | 114 | | |
114 | 115 | | |
115 | 116 | | |
116 | 117 | | |
117 | 118 | | |
118 | | - | |
| 119 | + | |
| 120 | + | |
119 | 121 | | |
120 | 122 | | |
121 | 123 | | |
| |||
0 commit comments