refactor(stats): take stats_url as a StatsFlusher::new parameter#1210
Open
lucaspimentel wants to merge 1 commit intomainfrom
Open
refactor(stats): take stats_url as a StatsFlusher::new parameter#1210lucaspimentel wants to merge 1 commit intomainfrom
stats_url as a StatsFlusher::new parameter#1210lucaspimentel wants to merge 1 commit intomainfrom
Conversation
4 tasks
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. |
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>
8f52b41 to
6fbe14b
Compare
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.
Overview
StatsFlusherderived its intake URL internally viatrace_stats_url(&config.site), which hardcodeshttps://trace.agent.{site}/api/v0.2/statswith no override hook. This PR lifts the URL to the caller:StatsFlusher::newnow takes astats_url: Stringparameter, andmain.rscomputestrace_stats_url(&config.site)at the call site.This mirrors how
TraceFlusheralready works (URL comes from outside viaSendData's embeddedEndpoint) and unblocks redirectingStatsFlusherto alternate endpoints, which is needed for the upcoming in-process fake-intake test harness (#1194).Retry-loop debug logs now report
endpoint.urlso they reflect the URL actually contacted instead of a re-derived site URL.This refactor was split out of #1194 per review feedback to keep the production signature change separate from the test-harness addition.
Testing
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