Skip to content

[Rust] Add pluggable stats exporter for Arrow streams - #820

Open
flaviofcruz wants to merge 1 commit into
mainfrom
rust-stats-exporter
Open

[Rust] Add pluggable stats exporter for Arrow streams#820
flaviofcruz wants to merge 1 commit into
mainfrom
rust-stats-exporter

Conversation

@flaviofcruz

@flaviofcruz flaviofcruz commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

What changes are proposed in this pull request?

This proposes a different implementation compared to #790. Instead of adding a new take_offset_details, we introduce a mechanism where a user of the SDK can set a stats exporter. The stats exporter can receive different kinds of SDK events such as BatchSent/BatchAcked/Reconnected which can be consumed by the exporter. As a basic exporter we have a channel exporter which can be used by clients to drain the events and decide what to do with them.

The only major complication on the PR is how we handle BatchSent: because we need uncompressed and wired bytes, these are computed in different places so they need to be coordinated. Ditto for the graceful shutdown case, we have to push BatchSent on that scenario.

Non arrow flight path doesn't support stats exporting for now.

Why: this is required so that clients can understand how many bytes are put on the wire.

How is this tested?

Added a few tests.

Add a StatsExporter trait and StreamStat events so callers can route Arrow
Flight stream telemetry into their own metrics systems:

- BatchSent { offset, stats } is emitted when a batch is encoded and sent,
  where stats is a BatchStats { records, wire_bytes, uncompressed_bytes }.
  wire_bytes is the actual on-wire size (after IPC compression);
  uncompressed_bytes is the codec-independent Arrow payload size. It counts
  retransmits and fires even if the batch later fails to ack.
- BatchAcked { offset } is a durability-only signal.
- Reconnected { attempt } fires on recovery.

Byte sizes are held in a single current-batch accumulator in the Flight
encoder and flushed when the next batch is pulled, at natural end-of-stream,
and on graceful close. A batch cut off by recovery/rotation is dropped and
re-sent (and re-emitted) on the next connection. A built-in
ChannelExporter/channel_exporter forwards events to a bounded channel,
dropping and counting when full so a slow consumer never stalls ingestion.

Arrow-only (arrow-flight feature); gRPC keeps its AckCallback. No FFI/JNI/PyO3.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Flavio Cruz <flavio.cruz@databricks.com>
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