Skip to content

Conversation

@duncanista
Copy link
Contributor

@duncanista duncanista commented Feb 4, 2026

Overview

Simplify code for flushing, trying to standardize everything by avoiding code all over the place, ensuring that we only create one client and we can reuse as much as possible for performance improvements

Motivation

SVLS-8507

@duncanista duncanista requested a review from a team as a code owner February 4, 2026 21:14
@duncanista duncanista requested review from Copilot and removed request for a team February 4, 2026 21:14
Copy link
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

This PR refactors the trace flushing code to standardize and simplify HTTP client management. The main goal is to create a single, reusable HTTP client instance that can be shared across multiple flush operations, improving performance through connection pooling and TLS session reuse.

Changes:

  • Removed trait-based abstractions for TraceFlusher and StatsFlusher in favor of concrete types
  • Extracted HTTP client creation logic into a shared hyper_client module
  • Added lazy initialization of HTTP clients using OnceCell for caching and reuse

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
bottlecap/src/traces/trace_flusher.rs Removed TraceFlusher trait and ServerlessTraceFlusher implementation; added cached HTTP client with OnceCell; moved HTTP client creation to separate module
bottlecap/src/traces/stats_flusher.rs Removed StatsFlusher trait and ServerlessStatsFlusher implementation; added cached HTTP client with OnceCell; updated to use shared hyper_client module
bottlecap/src/traces/mod.rs Added new hyper_client module to public exports
bottlecap/src/traces/hyper_client.rs New module containing shared HTTP client creation logic and type definitions
bottlecap/src/flushing/service.rs Removed generic type parameters from FlushingService to use concrete flusher types

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

let client_clone = http_client.clone();
batch_tasks.spawn(async move {
Self::send(traces_clone, Some(&endpoint), &proxy_https, &tls_cert_file).await
Self::send_traces(traces_clone, Some(endpoint), client_clone).await
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

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

Passing Some(endpoint) here while passing None on line 121 creates an inconsistency. The endpoint variable is already an Endpoint from the loop, but send_traces expects Option<Endpoint>. Consider restructuring send_traces to accept &Endpoint directly and have a separate internal method or branch for the default endpoint case to make the API clearer.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems like a pre-existing bug

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be addressed on another PR

@duncanista duncanista requested a review from lym953 February 5, 2026 03:37
@duncanista
Copy link
Contributor Author

@lym953 might need a review from you, I'm adding retries on stats:-) amongst other things

}

impl ServerlessTraceFlusher {
pub fn get_http_client(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this created a client on every call

Base automatically changed from jordan.gonzalez/flushing/create-service to main February 5, 2026 21:32
we were creating a client every time when flushing traces, now we just use one, also removes unnecessary traits as we are not creating more tracing agents for other use cases
@duncanista duncanista force-pushed the jordan.gonzalez/flushing/standardize-mechanisms branch from 030fd5d to 7590bd2 Compare February 5, 2026 21:36
@duncanista duncanista changed the title chore(flushing): standardize code with refactoring on trace flushers chore(flushing): standardize code with refactoring on some flushers and retries Feb 5, 2026
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.

1 participant