You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Nevertheless, the specification also takes into consideration that this default behavior can be changed to allow the user strict error handling to reveal bugs.
I suggest that we use the warnings module instead of getLogger(...).exception. In this way, OpenTelemetry can be run in a way that makes the warnings turn into exceptions allowing the user to find bugs more easily while being specification compliant still.
Here are few examples that illustrate how this can work:
#logging_warning.pyfromloggingimportgetLogger_logger=getLogger(__name__)
try:
1/0exceptZeroDivisionError:
_logger.exception("A division by zero happened")
print("execution complete")
python logging_warning.py
A division by zero happened
Traceback (most recent call last):
File "logging_warning.py", line 6, in <module>
1 / 0
ZeroDivisionError: division by zero
execution complete
# raising_warning.pyfromwarningsimportwarntry:
1/0exceptZeroDivisionError:
warn("A division by zero happened")
print("execution complete")
python raising_warning.py
raising_warning.py:7: UserWarning: A division by zero happened
warn("A division by zero happened")
execution complete
python -W error raising_warning.py
Traceback (most recent call last):
File "raising_warning.py", line 5, in <module>
1 / 0
ZeroDivisionError: division by zero
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "raising_warning.py", line 7, in <module>
warn("A division by zero happened")
UserWarning: A division by zero happened
The text was updated successfully, but these errors were encountered:
* refactor: use a single eslintrc for all examples folders
furthermore, override the strict rule that ships with airbnb
* fix: turn off no-use-before-define
* fix: install eslint in ci container
Co-Authored-By: Daniel Dyla <[email protected]>
* fix: ignore uninstalled packages lint errors
We will not want to install all examples in CI
Co-authored-by: Daniel Dyla <[email protected]>
Co-authored-by: Mayur Kale <[email protected]>
So far we have been catching exceptions we don't want raised and logging a message instead. This definitely accomplishes its purpose and follows these basic error handling principles.
Nevertheless, the specification also takes into consideration that this default behavior can be changed to allow the user strict error handling to reveal bugs.
I suggest that we use the
warnings
module instead ofgetLogger(...).exception
. In this way, OpenTelemetry can be run in a way that makes the warnings turn into exceptions allowing the user to find bugs more easily while being specification compliant still.Here are few examples that illustrate how this can work:
The text was updated successfully, but these errors were encountered: