Skip to content

chore(flushing): refactor flushing#1016

Merged
duncanista merged 6 commits intomainfrom
jordan.gonzalez/flushing/create-service
Feb 5, 2026
Merged

chore(flushing): refactor flushing#1016
duncanista merged 6 commits intomainfrom
jordan.gonzalez/flushing/create-service

Conversation

@duncanista
Copy link
Contributor

@duncanista duncanista commented Feb 4, 2026

Overview

Refactors flushing to become its own service

Motivation

Making it easier for us to handle the flushing code in one place and ensure consistency
SVLS-8505

Notes

Not using dynamic typings for the flushers we accepts so far, in another PR I will standardize it and ensure we can have capacity-based flushing too.

@duncanista duncanista requested a review from a team as a code owner February 4, 2026 18:25
in favor of sugar
Comment on lines +139 to +142
let sf = Arc::clone(&self.stats_flusher);
self.handles
.stats_flush_handles
.push(tokio::spawn(async move { sf.flush(false).await }));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need your review here @lym953

also remove sending interval to flush_blocking
@duncanista duncanista requested a review from Copilot February 4, 2026 19:38
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 flushing logic into a dedicated service module to centralize and standardize flush operations across different data types (logs, traces, metrics, stats, and proxy requests).

Changes:

  • Introduces a new FlushingService that coordinates non-blocking and blocking flush operations across multiple flusher types
  • Adds FlushHandles for tracking in-flight flush operations with retry logic
  • Exposes the new flushing module in the public API

Reviewed changes

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

File Description
bottlecap/src/lib.rs Exposes the new flushing module in the library's public API
bottlecap/src/flushing/mod.rs Defines the module structure and exports the main types
bottlecap/src/flushing/handles.rs Implements handle tracking for in-flight flush operations with retry support
bottlecap/src/flushing/service.rs Implements the core FlushingService with spawn, await, and blocking flush capabilities

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

@duncanista duncanista requested a review from Copilot February 4, 2026 19:41
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

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


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

if let Err(e) = flush_task_handle.await {
error!("Error waiting for background flush task: {e:?}");
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a particular reason we no longer flush on shutdown? If so, would you mind adding a brief comment in the commit to capture the rationale?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It got moved, once we await the flush_task_handle, since it's the last task we wait for, inside of it, it just does its final flush on token cancellation

https://github.com/DataDog/datadog-lambda-extension/pull/1016/changes#diff-0b46a0bd1733b354850b895657f37a662f9a30cc2fa0ae684dfa1655520a53aaR451-R457

easier and cleaner than having it after we already awaited for our flushing task

Copy link
Contributor

@litianningdatadog litianningdatadog left a comment

Choose a reason for hiding this comment

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

Left some comments

Copy link
Contributor

@litianningdatadog litianningdatadog left a comment

Choose a reason for hiding this comment

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

LGTM

@duncanista duncanista merged commit fa9906e into main Feb 5, 2026
50 checks passed
@duncanista duncanista deleted the jordan.gonzalez/flushing/create-service branch February 5, 2026 21:32
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