@@ -266,11 +266,11 @@ def response_hook(span: Span, status: str, response_headers: List):
266
266
)
267
267
from opentelemetry .instrumentation .utils import _start_internal_or_server_span
268
268
from opentelemetry .metrics import get_meter
269
+ from opentelemetry .semconv .attributes .http_attributes import HTTP_ROUTE
269
270
from opentelemetry .semconv .metrics import MetricInstruments
270
271
from opentelemetry .semconv .metrics .http_metrics import (
271
272
HTTP_SERVER_REQUEST_DURATION ,
272
273
)
273
- from opentelemetry .semconv .trace import SpanAttributes
274
274
from opentelemetry .util .http import (
275
275
get_excluded_urls ,
276
276
parse_excluded_urls ,
@@ -284,7 +284,7 @@ def response_hook(span: Span, status: str, response_headers: List):
284
284
_ENVIRON_ACTIVATION_KEY = "opentelemetry-flask.activation_key"
285
285
_ENVIRON_REQCTX_REF_KEY = "opentelemetry-flask.reqctx_ref_key"
286
286
_ENVIRON_TOKEN = "opentelemetry-flask.token"
287
- _ENVIRON_REQUEST_ROUTE_KEY = "request-route_key"
287
+ _ENVIRON_REQUEST_ROUTE_KEY = "opentelemetry-flask. request-route_key"
288
288
289
289
_excluded_urls_from_env = get_excluded_urls ("FLASK" )
290
290
@@ -396,8 +396,8 @@ def _start_response(status, response_headers, *args, **kwargs):
396
396
)
397
397
398
398
if wrapped_app_environ .get (_ENVIRON_REQUEST_ROUTE_KEY , None ):
399
- duration_attrs_old [SpanAttributes . HTTP_ROUTE ] = (
400
- wrapped_app_environ . get ( _ENVIRON_REQUEST_ROUTE_KEY )
399
+ duration_attrs_old [HTTP_ROUTE ] = wrapped_app_environ . get (
400
+ _ENVIRON_REQUEST_ROUTE_KEY
401
401
)
402
402
403
403
duration_histogram_old .record (
@@ -409,8 +409,8 @@ def _start_response(status, response_headers, *args, **kwargs):
409
409
)
410
410
411
411
if wrapped_app_environ .get (_ENVIRON_REQUEST_ROUTE_KEY , None ):
412
- duration_attrs_new [SpanAttributes . HTTP_ROUTE ] = (
413
- wrapped_app_environ . get ( _ENVIRON_REQUEST_ROUTE_KEY )
412
+ duration_attrs_new [HTTP_ROUTE ] = wrapped_app_environ . get (
413
+ _ENVIRON_REQUEST_ROUTE_KEY
414
414
)
415
415
416
416
duration_histogram_new .record (
@@ -443,7 +443,7 @@ def _before_request():
443
443
if flask .request .url_rule :
444
444
# For 404 that result from no route found, etc, we
445
445
# don't have a url_rule.
446
- attributes [SpanAttributes . HTTP_ROUTE ] = flask .request .url_rule .rule
446
+ attributes [HTTP_ROUTE ] = flask .request .url_rule .rule
447
447
span , token = _start_internal_or_server_span (
448
448
tracer = tracer ,
449
449
span_name = span_name ,
0 commit comments