Repository navigation
fix: OTel operation and attempt events lose the original exception.type #812
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
be97d83
fix: OTel operation and attempt events lose the original exception.type
8285790
Merge branch 'main' into oss-harness/issue-804
zhongkechen bc69f01
Merge branch 'main' into oss-harness/issue-804
zhongkechen 4f3c61d
fix: avoid reconstructing telemetry exceptions
nandanadileep dcbe198
Merge branch 'main' into oss-harness/issue-804
zhongkechen 723a6f0
test: cover OTel fallback error message
cursoragent e86ce94
Merge branch 'main' into oss-harness/issue-804
zhongkechen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
...e-execution-sdk-python-otel/src/aws_durable_execution_sdk_python_otel/exception_events.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| """Record serialized errors without reconstructing application exceptions. | ||
|
|
||
| Use a plain exception as the event carrier and explicitly supply the original | ||
| checkpointed type, message, and stack trace. Resolving the original class is | ||
| unnecessary and could run application imports or constructors during replay. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing import Any | ||
|
|
||
| from aws_durable_execution_sdk_python.lambda_service import ErrorObject | ||
|
|
||
|
|
||
| _DEFAULT_MESSAGE = "Unknown error" | ||
|
|
||
|
|
||
| def exception_from_error_object(error: ErrorObject) -> Exception: | ||
| """Create a plain event carrier; attributes preserve the original details.""" | ||
| message: str = error.message if error.message is not None else "" | ||
| if not error.type: | ||
| message = message or _DEFAULT_MESSAGE | ||
| return Exception(message) | ||
|
|
||
|
|
||
| def error_object_exception_attributes(error: ErrorObject) -> dict[str, Any]: | ||
| """Return explicit event attributes for a checkpointed error. | ||
|
|
||
| OTel derives exception attributes from the supplied exception. The plain | ||
| carrier has neither the original runtime type nor its traceback, so the | ||
| checkpointed values are supplied explicitly. | ||
| """ | ||
| attributes: dict[str, Any] = {} | ||
| if error.type is not None: | ||
| attributes["exception.type"] = error.type | ||
| if error.message is not None: | ||
| attributes["exception.message"] = error.message | ||
| if error.stack_trace: | ||
| attributes["exception.stacktrace"] = "\n".join(error.stack_trace) | ||
| return attributes | ||
|
|
||
|
|
||
| def record_error_object_exception(span: Any, error: ErrorObject | None) -> None: | ||
| """Record a span exception that preserves the SDK's original error type. | ||
|
|
||
| ``error`` may be ``None`` for a failed outcome that carried no metadata; a | ||
| generic exception is recorded in that case. | ||
| """ | ||
| if error is None: | ||
| span.record_exception(Exception(_DEFAULT_MESSAGE)) | ||
| return | ||
| span.record_exception( | ||
| exception_from_error_object(error), | ||
| attributes=error_object_exception_attributes(error), | ||
| ) | ||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.