-
Notifications
You must be signed in to change notification settings - Fork 711
Make record_exception more robust handling them outside the except scope #3778
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
ocelotl
merged 6 commits into
open-telemetry:main
from
xrmx:better-exception-handling-3762
Mar 21, 2024
Merged
Make record_exception more robust handling them outside the except scope #3778
ocelotl
merged 6 commits into
open-telemetry:main
from
xrmx:better-exception-handling-3762
Mar 21, 2024
Conversation
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
1bd39ca
to
2d004dc
Compare
aabmass
approved these changes
Mar 14, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few comments but approving in advance, thanks for the PR
b980f88
to
6b3548e
Compare
aabmass
approved these changes
Mar 15, 2024
Yeah, realized It too late. I am away from keyboard until Monday, will fix
then if anyone does not beat me to it.
Il ven 15 mar 2024, 04:25 Aaron Abbott ***@***.***> ha
scritto:
… ***@***.**** approved this pull request.
------------------------------
In opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py
<#3778 (comment)>
:
> @@ -987,13 +987,12 @@ def record_exception(
escaped: bool = False,
) -> None:
"""Records an exception as a span event."""
- try:
- stacktrace = traceback.format_exc()
- except Exception: # pylint: disable=broad-except
- # workaround for python 3.4, format_exc can raise
- # an AttributeError if the __context__ on
- # an exception is None
- stacktrace = "Exception occurred on stacktrace formatting"
+ # TODO: drop first argument after baseline is 3.10
I think it's actually the opposite, after 3.10 we can just do
trace.format_exception(exception) based on this
<https://docs.python.org/3.11/library/traceback.html#traceback.print_exception:~:text=Since%20Python%203.10%2C%20instead%20of%20passing%20value%20and%20tb%2C%20an%20exception%20object%20can%20be%20passed%20as%20the%20first%20argument.>
correctly
—
Reply to this email directly, view it on GitHub
<#3778 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAADFBCAXRV6RPDYBZUOSVTYYJS25AVCNFSM6AAAAABEUNKA4CVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTSMZYGA2DKMRXHE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
c42a977
to
f6cf3d8
Compare
Fixed comment |
…he except scope Make the stacktrace formatting not rely on being inside the except scope. Fixes open-telemetry#3762 Suggested-by: Alex Hall <[email protected]>
f6cf3d8
to
bb454b7
Compare
ocelotl
approved these changes
Mar 19, 2024
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.
Description
Make the stacktrace formatting not rely on being inside the except scope.
Suggested-by: Alex Hall [email protected]
Fixes #3762
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Does This PR Require a Contrib Repo Change?
Answer the following question based on these examples of changes that would require a Contrib Repo Change:
The OTel specification has changed which prompted this PR to update the method interfaces of
opentelemetry-api/
oropentelemetry-sdk/
The method interfaces of
test/util
have changedScripts in
scripts/
that were copied over to the Contrib repo have changedConfiguration files that were copied over to the Contrib repo have changed (when consistency between repositories is applicable) such as in
pyproject.toml
isort.cfg
.flake8
When a new
.github/CODEOWNER
is addedMajor changes to project information, such as in:
README.md
CONTRIBUTING.md
Yes. - Link to PR:
No.
Checklist: