Skip to content

feat: add Workflow Insight plugin - #661

Draft
wangyb-A wants to merge 2 commits into
mainfrom
workflow-insight-plugin
Draft

feat: add Workflow Insight plugin#661
wangyb-A wants to merge 2 commits into
mainfrom
workflow-insight-plugin

Conversation

@wangyb-A

Copy link
Copy Markdown
Contributor

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

N/A. Workflow Insight conformance requirements are being reviewed in aws/aws-durable-execution-conformance-tests#73.

Description

Adds the preview Workflow Insight plugin as a new insight-plugin Maven module.

The plugin emits schema-versioned execution records from the existing Java plugin hooks and matches the JavaScript Workflow Insight contract. It includes:

  • deterministic per-execution sampling and on-complete, on-failure, and on-change emission modes
  • execution input/output transforms, operation filtering, error controls, and result opt-in transforms
  • top-level and full-tree operation detail
  • operations-array and operationsByName record shapes
  • per-exporter record-size truncation
  • Lambda log, Amazon S3, and CloudWatch Logs exporters
  • exporter failure isolation and flushing

The implementation uses the invocation operation snapshots, execution payloads, errors, attempts, and serialized operation results already exposed by the Java plugin API. No core hook changes are required.

Demo/Screenshots

No UI change. insight-plugin/README.md contains a usage example. The draft conformance PR linked above contains Java handlers for all 18 Workflow Insight requirements.

Checklist

  • I have filled out every section of the PR template
  • I have thoroughly tested this change

Testing

Unit Tests

Yes. The module adds 35 tests covering record construction, sampling, emission modes, replay/suspension state, operation filtering, result transforms, aggregation, truncation, exporter requests, failure isolation, and flush behavior.

mvn -q -pl insight-plugin -am test
mvn -q -pl insight-plugin -am clean verify

Both pass.

The full repository reactor also passes:

mvn -q clean verify

Integration Tests

Yes. WorkflowInsightPluginTest exercises the plugin through LocalDurableTestRunner.

The draft Workflow Insight conformance suite was also run against deployed Java 21 Lambda functions in us-west-2:

  • S3 operations-array leg: 18 passed, 0 failed
  • CloudWatch operationsByName leg: 18 passed, 0 failed

Sink-specific assertions were capability-gated and exercised by the complementary leg.

Examples

The module README includes configuration and exporter usage. Customer-facing conformance handlers are in aws/aws-durable-execution-conformance-tests#73 rather than this repository, following the repository's conformance-test ownership rule.

@wangyb-A
wangyb-A force-pushed the workflow-insight-plugin branch from 5d83fc9 to 9cb8201 Compare August 28, 2026 18:06
@wangyb-A
wangyb-A marked this pull request as ready for review August 28, 2026 18:38
@wangyb-A
wangyb-A requested a review from a team August 28, 2026 18:38
@wangyb-A
wangyb-A deployed to ai-pr-review-runtime August 28, 2026 18:38 — with GitHub Actions Active
@wangyb-A
wangyb-A had a problem deploying to ai-pr-review-runtime August 28, 2026 18:40 — with GitHub Actions Failure
@wangyb-A
wangyb-A deployed to ai-pr-review-runtime August 28, 2026 18:40 — with GitHub Actions Active
Comment thread pom.xml
<module>sdk-testing</module>
<module>sdk-integration-tests</module>
<module>otel-plugin</module>
<module>insight-plugin</module>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex AI review · Finding arf_v1_v6wv3rjugx56mymsuekqwwjamc

[P1] Publish the new plugin artifact

Adding this module to the reactor builds it, but the release pipeline explicitly deploys and uploads only sdk, sdk-testing, and otel-plugin. Releases will therefore omit aws-durable-execution-sdk-java-plugin-insight, making the documented dependency unavailable from Maven Central. Add insight-plugin to .github/scripts/maven_publish.sh and the GitHub release artifact list, with a release-workflow check.

*/
@Deprecated
public final class Json {
static final ObjectMapper MAPPER = new ObjectMapper();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex AI review · Finding arf_v1_blkdgaotf7rzua2ga3uyouqm5e

[P1] Support the SDK's default payload types when exporting

This bare mapper cannot serialize Java-time values such as Instant, although the default JacksonSerDes supports them. If an included input or output contains one, size calculation fails and final serialization throws; emit catches that exception, silently losing every insight record. Configure the mapper with JavaTimeModule and ISO-8601 date serialization, declare the module dependency directly, and test an input/output containing an Instant.

Comment on lines +181 to +182
exporter.export(shaped);
exporter.flush();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex AI review · Finding arf_v1_xryomwjxrzqt3z55wozggpsrsl

[P2] Keep remote exports off the checkpoint callback

emit is called synchronously from onOperationChange, which the SDK invokes before checkpoint futures and pollers are completed. Synchronous S3/CloudWatch calls and immediate flushing can therefore stall durable checkpoint coordination on every ON_CHANGE event, potentially causing invocation timeouts despite exception isolation. Queue these records on non-terminal hooks and perform/await serial export and flushing from onInvocationEnd; add a delayed-exporter test proving operation-change hooks return promptly.

if (operations == null) {
return out;
}
for (OperationChangeItemInfo item : operations.values()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex AI review · Finding arf_v1_ig2yofnonmfn7zknekoxwd6xmg

[P2] Establish a deterministic chronological operation order

The hook contract supplies a map with no iteration-order guarantee, and the core snapshot originates from a concurrent map. Iterating values() produces unstable operation arrays; moreover, OperationsIndex treats the last encountered repeated name as the latest status/type, so an older occurrence may overwrite the actual latest one. Sort by startTimestamp with a stable ID tie-breaker before constructing records, and test unordered repeated-name snapshots with differing statuses.

Comment on lines +328 to +329
private static ErrorInfo toErrorInfo(Throwable t) {
return new ErrorInfo(t.getClass().getSimpleName(), t.getMessage());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex AI review · Finding arf_v1_lndcqjp4vnrm6vjmmfzrqrfdin

[P2] Preserve the checkpointed operation error type

Operation snapshot errors are exposed as DurableOperationException wrappers by PluginInfoConverter, so this emits the generic wrapper name instead of the original checkpointed exception type. Insight records consequently lose the actionable failure identity. When the throwable is a DurableOperationException, derive the name and message from its ErrorObject, then fall back to the throwable fields; assert the exact original type and message in the failure test.

Comment on lines +315 to +316
if (!include || value == null) {
return null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex AI review · Finding arf_v1_oirdg3rnpdnwvpldafyiqrnncz

[P2] Distinguish included JSON null from an omitted field

This conflates an enabled value that is actually null with content excluded by configuration, and the wire map subsequently omits both. A successful handler returning null therefore has no output field even though output inclusion defaults to true. Track field presence separately or use an explicit JSON-null sentinel, emitting null for included terminal values while omitting only unavailable or disabled content; add null input/output tests.

Comment on lines +43 to +44
public List<OperationRecord> operations() {
return operations;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex AI review · Finding arf_v1_rzwdoyquezpr2qgby63imtmxcn

[P2] Prevent one exporter from mutating later exporters' records

This exposes the live operations list, whose elements are also mutable. Because truncation returns the original record when it is already within the limit, all exporters then receive the same mutable object; a custom exporter that clears or redacts operations can corrupt every subsequent export. Make records immutable or provide each exporter a deep copy, and return an immutable snapshot here. Add an isolation test with a mutating first exporter.

return false;
}
long unsigned = fnv1a32(executionArn) & 0xffffffffL;
return (double) unsigned / 0xffffffffL < rate;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex AI review · Finding arf_v1_47kz274xvx4sow4mmbm7gzor7a

[P3] Normalize the hash into the promised half-open interval

Dividing by the maximum unsigned 32-bit value maps 0xffffffff to exactly 1.0, producing [0,1] rather than the documented [0,1) and potentially differing from cross-SDK deterministic sampling decisions. Divide by 2^32 and add a fixed-vector compatibility test.

Suggested change
return (double) unsigned / 0xffffffffL < rate;
return (double) unsigned / 0x1_0000_0000L < rate;

@github-actions

Copy link
Copy Markdown
Contributor

Codex AI review

Found eight actionable issues, including release publication and record-loss blockers. Static review only; tests were not executed per request.

Reviewed commit 9cb8201925cb2f7037febfc689f7203018703bd4. Workflow run

@zhongkechen

Copy link
Copy Markdown
Contributor

Use /ai review command to trigger AI review workflows for draft PRs

@wangyb-A
wangyb-A marked this pull request as draft August 28, 2026 19:22
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.

2 participants