feat(insight): add HttpExporter - #702
Draft
wangyb-A wants to merge 2 commits into
Draft
Conversation
added 2 commits
September 9, 2026 23:39
Port the JS workflow-insight HttpExporter to Java: POST/PUT each record to any HTTP(S) endpoint or webhook as application/json. - Builder config mirrors the JS contract: url (required, validated absolute http/https), method (POST default / PUT), custom headers, timeoutMs (default 10000), operationsFormat (ARRAY/BY_NAME/BOTH), optional maxRecordSizeBytes (no default). - Transport uses the JDK's own java.net.http.HttpClient, so no new dependency is added. An injectable HttpSender seam (default JdkHttpSender) makes the exporter mockable; render()/export() share one shaping path per the InsightExporter size-limiter contract. - Non-2xx responses throw and are contained by the plugin's existing per-exporter isolation, so a bad endpoint never disrupts execution. - Deterministic unit tests cover the mock seam and a real in-process com.sun.net.httpserver server; README documents the exporter. No changes to sdk core or the WorkflowInsight plugin wiring.
Merge request headers case-insensitively so a caller-supplied Content-Type of any casing overrides the default application/json and yields exactly one header with no duplicate on the wire. Add default JDK-sender transport-failure coverage: a connection refusal (reserved-then-released loopback port, bounded timeout) and thread interruption, both proving IllegalStateException; the interruption test also asserts the interrupt flag is preserved. Align HttpExporter Javadoc and README wording: Content-Type is a default a caller may override. No response-body logging added.
Contributor
Author
|
Intent: Add an |
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.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Issue Link, if available
Related: #679
Description
This adds
HttpExporterto the Workflow Insight plugin. It sends one insight record to an HTTP endpoint as one request. It mirrors the JSHttpExporterso the two SDKs behave the same.What it does:
POSTorPUT.POSTis the default.Content-Type: application/json. A caller may pass their own headers, including their ownContent-Type. The caller's value wins. Header names are matched without caring about upper or lower case, so a lowercasecontent-typereplaces the default instead of adding a second one. The endpoint receives exactly oneContent-Typeheader.timeoutMsfor the endpoint. The default is 10000 ms. A non-2xx reply throws.operationsFormat:ARRAY(the default) writes theoperationsarray,BY_NAMEwrites theoperationsByNamemap,BOTHwrites both.render()builds the shape andexport()sends it, sharing one path.How it talks HTTP:
java.net.http.HttpClient. This adds no new dependency. The client sits behind a small package-visibleHttpSenderseam so tests can inject a fake, the same wayS3ExporterandCloudWatchLogsExporterallow a.client(...).No change to the SDK core or the Workflow Insight plugin wiring.
Demo/Screenshots
N/A. This is a backend Java change with no user-visible UI, so there is nothing to screenshot.
Checklist
Testing
Unit Tests
Yes.
HttpExporterTest(17 tests) covers, with a mock sender: defaultPOST+Content-Type+ array body + 10s timeout;PUTwith a mergedAuthorizationheader; non-2xx throws;BY_NAMEmap;BOTHarray + map; a configured timeout is applied; the caller'sContent-Typeoverrides the default case-insensitively with no duplicate; and builder rejects a missing url, a non-http scheme, a non-absolute url, and a non-positive timeout.Integration Tests
Transport-level tests run the real default JDK sender end to end against an in-process
com.sun.net.httpserver.HttpServer: aPOSTreturns 200 and the handler asserts method,Content-Type, and body; a 500 throws; aPUTwith a customAuthorizationheader is received; the wire carries exactly oneContent-Typewhen the caller overrides its casing; a connection to a dead loopback port throwsIllegalStateException; and an interrupted export throws while restoring the thread's interrupt flag.Examples
N/A. No new example is needed for a new exporter class; the plugin README's HttpExporter section documents customer usage.