Skip to content

ref(sentry-core): Refactor logs batching into generic Batcher#1018

Draft
szokeasaurusrex wants to merge 2 commits intomasterfrom
szokeasaurusrex/generic-batcher
Draft

ref(sentry-core): Refactor logs batching into generic Batcher#1018
szokeasaurusrex wants to merge 2 commits intomasterfrom
szokeasaurusrex/generic-batcher

Conversation

@szokeasaurusrex
Copy link
Member

Summary

  • Move logs batching implementation from sentry-core/src/logs.rs to sentry-core/src/batcher.rs so Git tracks it as a rename.
  • Generalize the batcher to Batcher<T> with an injected envelope-item conversion function.
  • Keep logs integration in Client by instantiating Batcher<Log>.
  • Update module wiring in sentry-core/src/lib.rs from logs to batcher.

Why this approach

Behavior parity

  • Preserve flush-at-threshold behavior (100 items).
  • Preserve periodic flush interval (5s).
  • Preserve flush-on-drop and client-shutdown behavior.
  • Keep logs batching tests in place and passing.

Validation

  • Ran cargo fmt --all.
  • Ran cargo clippy -p sentry-core --features "client,logs" -- -Dwarnings.
  • Ran cargo test -p sentry-core --features "client,logs,test" --lib.

Closes #1007
Closes RUST-158
Co-authored-by: Joris Bayer joris.bayer@sentry.io

## Summary
- Move logs batching implementation from `sentry-core/src/logs.rs` to `sentry-core/src/batcher.rs` so Git tracks it as a rename.
- Generalize the batcher to `Batcher<T>` with an injected envelope-item conversion function.
- Keep logs integration in `Client` by instantiating `Batcher<Log>`.
- Update module wiring in `sentry-core/src/lib.rs` from `logs` to `batcher`.

## Why this approach
- Preserve reviewability by starting from a file move and then applying minimal, local generic changes.
- Keep issue #1007 scoped to logs behavior only, without metrics API changes.

## Behavior parity
- Preserve flush-at-threshold behavior (100 items).
- Preserve periodic flush interval (5s).
- Preserve flush-on-drop and client-shutdown behavior.
- Keep logs batching tests in place and passing.

## Validation
- Ran `cargo fmt --all`.
- Ran `cargo clippy -p sentry-core --features "client,logs" -- -Dwarnings`.
- Ran `cargo test -p sentry-core --features "client,logs,test" --lib`.

Closes #1007
Closes [RUST-158](https://linear.app/getsentry/issue/RUST-158/refactor-logs-batching-into-a-reusable-generic-batchert)
Co-authored-by: Joris Bayer <joris.bayer@sentry.io>
@linear
Copy link

linear bot commented Feb 27, 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.

Refactor logs batching into a reusable generic Batcher<T>

1 participant