Skip to content

fix(otel): preserve original exception types and remove parent duplicates - #846

Draft
zhongkechen wants to merge 1 commit into
aws:mainfrom
zhongkechen:fix/otel-exception-attribution
Draft

zhongkechen wants to merge 1 commit into
aws:mainfrom
zhongkechen:fix/otel-exception-attribution

Conversation

@zhongkechen

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

Reported OTel exception-attribution failures in child contexts, wait-for-condition, wait-for-callback, and chained invoke.

Description

Failed operation spans currently report DurableOperationException instead of the original stored error type, and Workflow/Invocation spans record additional exception events for the propagated failure. Both trace views now use ErrorObject.errorType for operation exception events, so a Java failure remains java.lang.RuntimeException and a callback rejection remains RejectedError. Workflow and Invocation retain their error status and description without exception events; attempt events remain intact.

Demo/Screenshots

Local regression tests reproduce all four operation scenarios and direct handler failures in both views. No cloud screenshots were captured.

Design

  • Design note: not needed; this is a plugin-local bug fix with no public API change.
  • Root cause: operation hooks intentionally expose stored failures through a DurableOperationException; recording that wrapper directly loses the stored type. Both plugins also record the propagated execution error on Workflow and Invocation.
  • Simpler options considered: changing or reconstructing the SDK exception would affect caller/plugin contracts and cannot represent arbitrary remote-language types. A shared attribute override corrects telemetry at recording time while retaining native exception rendering and the existing timestamp policy.
  • Net production source change: -1 line; public API members: unchanged. Four parent-span recordException calls are removed.

Assumptions

  • Native OpenTelemetry exception recording honors additional exception attributes: verified against the real OpenTelemetry 1.67.0 provider in OperationExceptionEventTest.
  • Checkpointed operation errors preserve their original type: verified through the real SDK and LocalDurableTestRunner for child contexts, conditions, callbacks, and invokes. Callback/invoke completions are supplied by the local backend.
  • Live AWS/X-Ray validation of the updated SDK is unverified; the deployed conformance scenarios were not rerun.

Decisions not covered by the issue or the design note

  • Keep the Java exception type when the stored type is absent, and preserve explicitly supplied empty types, consistent with existing error-detail handling.
  • Keep exception messages, stack rendering, timestamps, caller exceptions, and checkpoint contents unchanged.
  • Updated InvocationOtelPluginTest.failedInvocation_setsErrorOnBothWorkflowAndInvocationSpans: its old assertion required the extra Workflow exception event reported as a bug; it now checks that both parent spans have no events.
  • Updated BackendOperationTimingTest.publicHandlerUsesBackendEndAndCompletedReplaySkipsHooks: its old assertion required the wrapper type; it now requires the stored type while retaining the timing and replay checks.
  • No new conformance requirements or handlers were added. Event-type and parent-event assertions would be useful additions to the shared conformance suite.

Checklist

  • I have filled out every section of the PR template
  • I have thoroughly tested this change locally
  • Every new branch has a test that fails without it
  • Regression evidence: before the fix, 19 of 30 focused tests failed on wrapper types or parent-span events; after the fix, all 149 focused tests passed
  • Every edited test expectation is listed above with the reason

Testing

Unit Tests

OperationExceptionEventTest covers Java and remote error types, absent/empty types, native timestamps, the epoch sentinel, and backend timestamps. Existing timing, metadata, virtual-context, and invocation tests pass.

Integration Tests

ExceptionAttributionIntegrationTest covers child-context, condition, callback, invoke, and direct-handler failures in both trace views, including preserved error status, original operation/attempt exception types, failure replay, and skipped completed user code.

Validation on JDK 21:

  • mvn test: all modules passed; 3,689 tests reported, 34 skipped, zero failures/errors (including all 961 OTel tests).
  • mvn -pl otel-plugin spotless:apply spotless:check: passed.
  • git diff --check: passed.

The standard local suite leaves cloud tests disabled; live cloud conformance was not run.

Examples

Not applicable; no public usage change.

@zhongkechen
zhongkechen deleted the fix/otel-exception-attribution branch October 29, 2026 23:23
@zhongkechen
zhongkechen restored the fix/otel-exception-attribution branch October 29, 2026 23:33
@zhongkechen zhongkechen reopened this Oct 29, 2026

This branch has not been deployed

No deployments
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