Created
November 24, 2020 17:44
-
-
Save tedsuo/32b467b33f981e361a12a6f9becc3679 to your computer and use it in GitHub Desktop.
Python add data to current span
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 import trace | |
@app.route("/hello") | |
def hello(): | |
# get the current span, created by flask | |
span = trace.get_current_span() | |
# add more attributes to the server span | |
span.set_attribute("http.route", "some_route") | |
# add events (AKA structured logging) | |
span.add_event("event message", | |
{"event_attributes": 1}) | |
sleep(20 / 1000) | |
return "hello" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment