feat(capture): implement v1 BatchResponse and sink result merging#59757
Conversation
e6e3745 to
5fac4c4
Compare
|
jose-sequeira
left a comment
There was a problem hiding this comment.
LGTM, just small comments
Implement the 200 OK response path for the V1 capture analytics API: - Add BatchResponse and BatchEntryStatus types with per-event Ok/Drop/Limited/Retry statuses keyed by UUID - Implement merge_sink_results to correlate publish outcomes back to WrappedEvent metadata after Kafka produce - Wire process_batch to call the v1 sink router, merge results, and build the typed response - Add v1_sink_router field to router::State (Option, not yet wired in production setup.rs) - Include inline unit and integration tests for response serialization, merge logic, and sink result correlation
f4b7219 to
fc606d6
Compare
Problem
The V1 capture analytics API needs to return structured per-event responses so SDKs know exactly which events succeeded, were dropped, rate-limited, or should be retried.
Changes
Implements the 200 OK response path for
POST /i/v1/general/events:response.rs—BatchResponseandBatchEntryStatustypes withIntoResponseimpl; per-eventOk/Drop/Limited/Retrystatuses keyed by UUID with optional cause and detail fieldsprocess.rs—merge_sink_resultscorrelates publish outcomes from the sink back intoWrappedEventmetadata;process_batchnow calls the v1 sink router, merges results, and builds the typed responsehandler.rs— return type updated toResult<Response, Error>router.rs—v1_sink_router: Option<Arc<...>>field added to app state (not yet wired insetup.rs— gated behindCAPTURE_V1_SINKSenv var)test_utils.rs—MockSinkResultand fixture helpers for response/merge unit teststypes.rs— partition key parity tests,serialize_intoedge case testsInline unit and integration tests cover: response serialization (JSON field ordering, optional fields), merge logic (all outcome variants, partial failures, multi-destination), and the
ServiceUnavailableguard when no sink router is configured.How did you test this code?
Locally and in CI
This is PR 1 of a 3-PR stack:
Publish to changelog?
N/A
🤖 Agent context
Eli planned, Claude coded, Eli reviewed