@@ -395,31 +395,35 @@ def _start_response(status, response_headers, *args, **kwargs):
395
395
return start_response (status , response_headers , * args , ** kwargs )
396
396
397
397
result = wsgi_app (wrapped_app_environ , _start_response )
398
- duration_s = default_timer () - start
399
- if duration_histogram_old :
400
- duration_attrs_old = otel_wsgi ._parse_duration_attrs (
401
- attributes , _StabilityMode .DEFAULT
402
- )
398
+ if flask .request and (
399
+ excluded_urls is None
400
+ or not excluded_urls .url_disabled (flask .request .url )
401
+ ):
402
+ duration_s = default_timer () - start
403
+ if duration_histogram_old :
404
+ duration_attrs_old = otel_wsgi ._parse_duration_attrs (
405
+ attributes , _StabilityMode .DEFAULT
406
+ )
403
407
404
- if request_route :
405
- # http.target to be included in old semantic conventions
406
- duration_attrs_old [HTTP_TARGET ] = str (request_route )
408
+ if request_route :
409
+ # http.target to be included in old semantic conventions
410
+ duration_attrs_old [HTTP_TARGET ] = str (request_route )
407
411
408
- duration_histogram_old .record (
409
- max (round (duration_s * 1000 ), 0 ), duration_attrs_old
410
- )
411
- if duration_histogram_new :
412
- duration_attrs_new = otel_wsgi ._parse_duration_attrs (
413
- attributes , _StabilityMode .HTTP
414
- )
412
+ duration_histogram_old .record (
413
+ max (round (duration_s * 1000 ), 0 ), duration_attrs_old
414
+ )
415
+ if duration_histogram_new :
416
+ duration_attrs_new = otel_wsgi ._parse_duration_attrs (
417
+ attributes , _StabilityMode .HTTP
418
+ )
415
419
416
- if request_route :
417
- duration_attrs_new [HTTP_ROUTE ] = str (request_route )
420
+ if request_route :
421
+ duration_attrs_new [HTTP_ROUTE ] = str (request_route )
418
422
419
- duration_histogram_new .record (
420
- max (duration_s , 0 ), duration_attrs_new
421
- )
422
- active_requests_counter .add (- 1 , active_requests_count_attrs )
423
+ duration_histogram_new .record (
424
+ max (duration_s , 0 ), duration_attrs_new
425
+ )
426
+ active_requests_counter .add (- 1 , active_requests_count_attrs )
423
427
return result
424
428
425
429
return _wrapped_app
0 commit comments