@@ -122,10 +122,11 @@ app = Flask(__name__)
122122@app.route(" /hello" )
123123def hello ():
124124 choices = [" there" , " world" , " folks" , " hello" ]
125+ # create a span for the choice of the name, this may be a costly call in your real world application
125126 with tracer.start_as_current_span(" choice" ) as span:
126- choice = random.choice(choices)
127- span.set_attribute(" choice.value" , choice)
128- return f" Hello {choice}!"
127+ choice = random.choice(choices)
128+ span.set_attribute(" choice.value" , choice)
129+ return f" Hello {choice}!"
129130```
130131
131132And then we can run this application with the following command:
@@ -156,11 +157,12 @@ app = Flask(__name__)
156157@app.route("/hello")
157158def hello():
158159 choices = ["there", "world", "folks", "hello"]
160+ # create a span for the choice of the name, this may be a costly call in your real world application
159161 with tracer.start_as_current_span("choice") as span:
160- choice = random.choice(choices)
161- span.set_attribute("choice.value", choice)
162- hello_counter.add(1, {"choice.value": choice})
163- return f"Hello {choice}!"
162+ choice = random.choice(choices)
163+ span.set_attribute("choice.value", choice)
164+ hello_counter.add(1, {"choice.value": choice})
165+ return f"Hello {choice}!"
164166```
165167
166168<!-- ✅ What success looks like -->
0 commit comments