Skip to content

Sends billing.events log lines to S3 - #2522

Open
Hazel-Datastax wants to merge 58 commits into
mainfrom
hazel/billing-to-s3
Open

Sends billing.events log lines to S3#2522
Hazel-Datastax wants to merge 58 commits into
mainfrom
hazel/billing-to-s3

Conversation

@Hazel-Datastax

@Hazel-Datastax Hazel-Datastax commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

What this PR does:

Sends billing.events log lines to S3 as batched NDJSON objects

How it works:

  • BillingS3HandlerInstaller wires it up: attaches BillingS3LogHandler to the billing.events JUL logger at startup, detaches/closes it at shutdown.
  • BillingS3LogHandler is the orchestrator. publish() pushes each line into BillingQueue; the handler then decides when to ship — batch sealed (count/bytes), age tick, or close() drain — gates upload concurrency, calls the uploader, and records outcomes via BillingMetrics. Delivery is at-most-once by design: publish never blocks on S3, a full queue drops events, shutdown drains best-effort within a timeout.
  • BillingQueue owns the batching policy (seal by max events/bytes) and hands out drained batches.
  • S3BatchUploader is the only S3-aware piece (AsyncBatchUploader impl) — encodes NDJSON, PUTs to a time-partitioned key.
  • BillingMetrics tracks offered/flushed/failed/dropped counts plus a delivery heartbeat.

Tests

  • BillingS3LogHandlerTest is the main coverage: per-method unit tests (flush triggers, failure containment, close draining), plus concurrency tests (multi-producer no-loss/no-dup, close racing with in-flight publish) and pipeline tests (concurrency gate, auto-chaining the next batch on settle).
  • BillingS3ExportIntegrationTest covers the real path end-to-end against S3Mock, including that a dead S3 endpoint never breaks the API.
  • Remaining unit tests (queue/uploader/metrics/installer) cover their components individually.

Which issue(s) this PR fixes:
Fixes #

Checklist

  • Changes manually tested
  • Automated Tests added/updated
  • Documentation added/updated
  • CLA Signed: DataStax CLA

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

📈 Unit Test Coverage Delta vs Main Branch

Metric Value
Main Branch 52.97%
This PR 53.34%
Delta 🟢 +0.36%
✅ Coverage improved!

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Unit Test Coverage Report

Overall Project 53.34% -0.07% 🍏
Files changed 92.77% 🍏

File Coverage
BillingMetrics.java 100% 🍏
BillingS3HandlerInstaller.java 95.1% -4.9% 🍏
BillingQueue.java 91.09% -8.91% 🍏
BillingS3LogHandler.java 90.94% -9.06% 🍏
S3BatchUploader.java 89.63% -10.37% 🍏

@Hazel-Datastax
Hazel-Datastax marked this pull request as ready for review July 16, 2026 21:49
@Hazel-Datastax
Hazel-Datastax requested a review from a team as a code owner July 16, 2026 21:49
@Hazel-Datastax Hazel-Datastax changed the title Hazel/billing to s3 Sends billing.events log lines to S3 Jul 16, 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