refactor(stats): take stats_url as a StatsFlusher::new parameter#1210
Merged
lucaspimentel merged 1 commit intomainfrom May 5, 2026
Merged
refactor(stats): take stats_url as a StatsFlusher::new parameter#1210lucaspimentel merged 1 commit intomainfrom
stats_url as a StatsFlusher::new parameter#1210lucaspimentel merged 1 commit intomainfrom
Conversation
stats_url as a StatsFlusher::new parameter
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors StatsFlusher so its stats intake URL is provided by the caller instead of being derived internally, enabling future use cases like redirecting stats flushing to alternate endpoints (e.g., a fake intake for integration tests).
Changes:
- Add a
stats_url: Stringparameter toStatsFlusher::newand store it on the flusher. - Move
trace_stats_url(&config.site)computation intobottlecap’smain.rsat the call site. - Update retry-loop debug logs to report the actual
endpoint.urlused for requests.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| bottlecap/src/traces/stats_flusher.rs | Accepts/stores stats_url, uses it to build the Endpoint, and logs the contacted endpoint URL. |
| bottlecap/src/bin/bottlecap/main.rs | Computes trace_stats_url(&config.site) and passes it into StatsFlusher::new. |
8f52b41 to
6fbe14b
Compare
6fbe14b to
56162d9
Compare
StatsFlusher derived its intake URL internally via trace_stats_url(&config.site), which hardcodes https://trace.agent.{site}/api/v0.2/stats. Lift the URL to the caller: main.rs now computes trace_stats_url at the call site and passes it in. Mirrors how TraceFlusher already works (URL comes from outside via SendData's embedded Endpoint) and unblocks redirecting StatsFlusher to alternate endpoints such as in-process test harnesses. Retry-loop debug logs now report endpoint.url so they match the URL actually contacted. Co-Authored-By: Claude <noreply@anthropic.com>
56162d9 to
1850777
Compare
duncanista
approved these changes
May 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of changes
Refactor
StatsFlusher::newto accept astats_url: Stringparameter instead of deriving the URL internally fromconfig.site.Reason for change
trace_stats_url(&self.config.site)was being called in two separate places insideStatsFlusher(inget_or_initand again in the retry loop). It's now computed once at the call site.StatsFlusherneeding to know about it.StatsFlusherno longer owns URL resolution; it simply uses the URL it's given. This mirrors howTraceFlusheralready works, where the URL comes from outside viaSendData's embeddedEndpoint.Implementation details
stats_url: Stringfield toStatsFlusherand a corresponding parameter toStatsFlusher::new.trace_stats_urlimport fromstats_flusher.rs; the call now lives inmain.rs::start_trace_agent.trace_stats_url(&self.config.site)calls withself.stats_url.endpoint.urlso 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:
cargo buildon the bottlecap cratecargo check --workspace— cleanRUSTFLAGS="-D warnings" cargo clippy --workspace --all-targets --features default— cleancargo fmt --all -- --check— cleancargo nextest run --workspace— 526/526 passed