Repository navigation
[FLINK-40281][connector-http] Improve HTTP sink failure observability - #61
Open
bharathgunapati wants to merge 1 commit into
Open
bharathgunapati wants to merge 1 commit into
bharathgunapati wants to merge 1 commit into
Conversation
bharathgunapati
added a commit
to bharathgunapati/flink-http-sink-examples
that referenced
this pull request
Oct 26, 2026
Read the http_sink_connector metrics back after each job through a recording metric reporter registered with the mini-cluster, covering apache/flink-connector-http#61: a batch that succeeds on retry, a fatal response, an ignored response, retry exhaustion, per-entry weighting of a batch response, and an unreachable endpoint. - RecordingMetricReporter + META-INF/services registration; metrics are looked up by the tail of their identifier and stay readable after the job finished. - DataStreamHttpSinkMetricsIT with six scenarios. - CI builds the connector from examples-ci-open-prs, an integration branch of apache main plus the open PRs #58 and #61, so one snapshot covers every scenario in this repo. - README: document the metrics scenarios and that `mvn clean verify` is needed after reinstalling the snapshot (failsafe runs the shaded jar). Generated-by: Claude Code (Claude Fable 5.1)
Add sink metrics in the http_sink_connector group (request and failure counters, a request latency histogram, one counter per HTTP status code), carry observability data from the HTTP client to the writer through a new SinkHttpClientStatistics value on SinkHttpClientResponses, log failures with endpoint, method, status and affected entry count, and keep the original exception of requests that failed before a response was received. Generated-by: Cursor (auto mode) for the original draft; Claude Code (Claude Fable 5.1) for the port onto main
bharathgunapati
force-pushed
the
FLINK-40281-sink-metrics
branch
from
October 26, 2026 15:02
613ba66 to
95a9a7c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose of the change
https://issues.apache.org/jira/browse/FLINK-40281
The HTTP sink only reported failures through Flink's generic
numRecordsSendErrorscounter and a few logs without request context. With configurable status-code classification and retries (FLINK-40277, FLINK-40278), operators need to see why writes fail or retry. This change adds sink metrics, status-code counters, a request latency histogram, and failure logs with request context, and keeps the cause of client-side exceptions.Replaces the earlier stacked draft on my fork; rebuilt on top of main after #54 and #57.
Brief change log
SinkHttpClientStatistics(new,@PublicEvolving): observability data aSinkHttpClientcollects for one write across all retry attempts: HTTP request count, request latencies, request entries per status code, retryable responses, transport failures, and retry attempts.SinkHttpClientResponsescarries it as one new field with a new constructor; the existing constructors keep working and returnSinkHttpClientStatistics.empty(), so custom clients are unaffected.HttpSinkWriterregisters metrics in thehttp_sink_connectorgroup next to the lookup source'shttp_lookup_connectorgroup:numHttpRequests,requestLatencyMs(histogram),numRetryableResponseFailures,numRequestExceptions,numRetryAttempts,numRetryExhausted,numFatalResponseFailures,numIgnoredResponses, and one counter per HTTP status code in thestatus_codesubgroup, all counted in request entries. Failure logs now name the endpoint and the number of affected entries.JavaNetSinkHttpClientrecords a status code and latency per HTTP response, counts transport failures, and logs each retryable, fatal or ignored response with status, method, endpoint and entry count. The retryable-without-response log carries the original exception as its cause.JavaNetHttpResponseWrappercarries the duration and the failure.HttpSinkClientWithRetryaggregates statistics over attempts and counts entries scheduled for another attempt; the last allowed attempt counts as exhausted, not as a retry.HttpSinkRequestLatencyHistogram: a bounded, lock-free histogram over the last 1024 samples. Flink'sDescriptiveStatisticsHistogramlives in flink-runtime, which the connector does not import in production code, so this avoids a new dependency surface.Verifying this change
HttpSinkWriterTest: each client outcome increments the matching counters and status-code counters; latency samples reach the histogram; a transport error before any response counts as a request exception; a status-code counter is registered once and reused.JavaNetSinkHttpClientTest: statistics for a mixed set of responses; one batch response with three entries counts three for its status code; transport failures without a response; retry attempts counted across attempts and the exhausted attempt not counted as a retry; a failing HTTP client through both submitters; both submitters keep the original exception and elapsed time of a failed request; the old constructors return empty statistics; null statistics collections are rejected.BatchRequestSubmitterTest: a failed request keeps its cause and duration.HttpSinkRequestLatencyHistogramTest: statistics, bounded retention, empty state, concurrent updates.mvn -pl flink-connector-http -DskipITs test: full unit suite including ArchUnit;spotless:check checkstyle:checkclean.DataStreamHttpSinkMetricsIT(commit 6209f74, CI run, 32 tests green). A recording metric reporter reads thehttp_sink_connectormetrics back after each job:numHttpRequests2,numRetryableResponseFailures2,numRetryAttempts2,status_code.5032,status_code.2002, latency histogram count 2,numRecordsSendErrors0status_code.5033,numRetryAttempts3numRetryableResponseFailures2,numRetryAttempts1,numRetryExhausted1numFatalResponseFailures1,status_code.4001,numRecordsSendErrors1numIgnoredResponses1, no send errorsnumRequestExceptions1,numRetryExhausted1, no status-code counterImpact and documentation
SinkHttpClientStatisticsadded;SinkHttpClientResponsesgains a field and a constructor, existing constructors unchangedclose()inAbstractRequestSubmitter; whichever merges second needs a trivial rebase (the two blocks are independent, verified by stacking both on main).Was generative AI tooling used to co-author this PR?
Generated-by: Cursor (auto mode) for the original draft; Claude Code (Claude Fable 5.1) for the port onto main