Skip to content

Commit a16821a

Browse files
Fixes
1 parent 930685e commit a16821a

File tree

2 files changed

+11
-9
lines changed
  • instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask
  • opentelemetry-instrumentation/src/opentelemetry/instrumentation/_labeler

2 files changed

+11
-9
lines changed

instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,6 @@ def _wrapped_app(wrapped_app_environ, start_response):
374374
attributes = otel_wsgi.collect_request_attributes(
375375
wrapped_app_environ, sem_conv_opt_in_mode
376376
)
377-
# Enhance attributes with custom labeler attributes
378-
attributes = enhance_metric_attributes(
379-
attributes, wrapped_app_environ, "request"
380-
)
381377
active_requests_count_attrs = (
382378
otel_wsgi._parse_active_request_count_attrs(
383379
attributes,
@@ -445,6 +441,11 @@ def _start_response(status, response_headers, *args, **kwargs):
445441
request_route
446442
)
447443

444+
# Enhance attributes with any custom labeler attributes
445+
duration_attrs_old = enhance_metric_attributes(
446+
duration_attrs_old
447+
)
448+
448449
duration_histogram_old.record(
449450
max(round(duration_s * 1000), 0), duration_attrs_old
450451
)
@@ -456,6 +457,11 @@ def _start_response(status, response_headers, *args, **kwargs):
456457
if request_route:
457458
duration_attrs_new[HTTP_ROUTE] = str(request_route)
458459

460+
# Enhance attributes with any custom labeler attributes
461+
duration_attrs_new = enhance_metric_attributes(
462+
duration_attrs_new
463+
)
464+
459465
duration_histogram_new.record(
460466
max(duration_s, 0), duration_attrs_new
461467
)
@@ -485,7 +491,7 @@ def _before_request():
485491
)
486492
# Enhance attributes with custom labeler attributes
487493
attributes = enhance_metric_attributes(
488-
attributes, flask_request_environ, "request"
494+
attributes
489495
)
490496
if flask.request.url_rule:
491497
# For 404 that result from no route found, etc, we

opentelemetry-instrumentation/src/opentelemetry/instrumentation/_labeler/example.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,3 @@ def user_profile(user_id):
5050
})
5151

5252
return f"Got user profile for {user_id}"
53-
54-
55-
if __name__ == "__main__":
56-
app.run(debug=True, port=5000, host='0.0.0.0')

0 commit comments

Comments
 (0)