Skip to content

Instantly share code, notes, and snippets.

@tedsuo
Created November 24, 2020 17:44
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save tedsuo/32b467b33f981e361a12a6f9becc3679 to your computer and use it in GitHub Desktop.
Python add data to current span
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