Skip to content

refactor(stats): take stats_url as a StatsFlusher::new parameter#1210

Open
lucaspimentel wants to merge 1 commit intomainfrom
lpimentel/stats-flusher-url-param
Open

refactor(stats): take stats_url as a StatsFlusher::new parameter#1210
lucaspimentel wants to merge 1 commit intomainfrom
lpimentel/stats-flusher-url-param

Conversation

@lucaspimentel
Copy link
Copy Markdown
Member

@lucaspimentel lucaspimentel commented Apr 24, 2026

Overview

StatsFlusher derived its intake URL internally via trace_stats_url(&config.site), which hardcodes https://trace.agent.{site}/api/v0.2/stats with no override hook. This PR lifts the URL to the caller: StatsFlusher::new now takes a stats_url: String parameter, and main.rs computes trace_stats_url(&config.site) at the call site.

This mirrors how TraceFlusher already works (URL comes from outside via SendData's embedded Endpoint) and unblocks redirecting StatsFlusher to alternate endpoints, which is needed for the upcoming in-process fake-intake test harness (#1194).

Retry-loop debug logs now report endpoint.url so 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 build on the bottlecap crate
  • cargo check --workspace - clean
  • RUSTFLAGS="-D warnings" cargo clippy --workspace --all-targets --features default - clean
  • cargo fmt --all -- --check - clean
  • cargo nextest run --workspace - 526/526 passed
  • CI green

@lucaspimentel lucaspimentel changed the title refactor(stats): take stats_url as a StatsFlusher::new parameter refactor(stats): take stats_url as a StatsFlusher::new parameter Apr 24, 2026
@lucaspimentel lucaspimentel marked this pull request as ready for review April 24, 2026 17:43
@lucaspimentel lucaspimentel requested review from a team as code owners April 24, 2026 17:43
@lucaspimentel lucaspimentel requested review from Copilot and lym953 April 24, 2026 17:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: String parameter to StatsFlusher::new and store it on the flusher.
  • Move trace_stats_url(&config.site) computation into bottlecap’s main.rs at the call site.
  • Update retry-loop debug logs to report the actual endpoint.url used 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.

Comment thread bottlecap/src/traces/stats_flusher.rs
Comment thread bottlecap/src/traces/stats_flusher.rs
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>
@lucaspimentel lucaspimentel force-pushed the lpimentel/stats-flusher-url-param branch from 8f52b41 to 6fbe14b Compare April 24, 2026 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants