Created
November 24, 2020 17:51
-
-
Save tedsuo/d7f21918c29679c429c35e82f3354b37 to your computer and use it in GitHub Desktop.
Python recording errors
This file contains 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
from opentelemetry.trace.status import StatusCode | |
@app.route("/hello") | |
def hello(): | |
span = trace.propagation.get_current_span() | |
try: | |
1 / 0 | |
except ZeroDivisionError as error: | |
# record an exception | |
span.record_exception(error) | |
# fail the operation | |
span.set_status(StatusCode.ERROR) | |
print("caught zero division error") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment