Skip to content

Commit

Permalink
Change http.route to SpanAttributes.HTTP_ROUTE
Browse files Browse the repository at this point in the history
  • Loading branch information
GonzaloGuasch committed Jul 18, 2024
1 parent 547c99c commit 93daa35
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ def response_hook(span: Span, status: str, response_headers: List):
)
from opentelemetry.instrumentation.utils import _start_internal_or_server_span
from opentelemetry.metrics import get_meter
from opentelemetry.semconv.attributes.http_attributes import HTTP_ROUTE
from opentelemetry.semconv.metrics import MetricInstruments
from opentelemetry.semconv.metrics.http_metrics import (
HTTP_SERVER_REQUEST_DURATION,
Expand Down Expand Up @@ -409,8 +408,8 @@ def _start_response(status, response_headers, *args, **kwargs):
)

if wrapped_app_environ.get(_ENVIRON_REQUEST_ROUTE_KEY, None):
duration_attrs_new[HTTP_ROUTE] = wrapped_app_environ.get(
_ENVIRON_REQUEST_ROUTE_KEY
duration_attrs_new[SpanAttributes.HTTP_ROUTE] = (
wrapped_app_environ.get(_ENVIRON_REQUEST_ROUTE_KEY)
)

duration_histogram_new.record(
Expand Down Expand Up @@ -443,7 +442,7 @@ def _before_request():
if flask.request.url_rule:
# For 404 that result from no route found, etc, we
# don't have a url_rule.
attributes[HTTP_ROUTE] = flask.request.url_rule.rule
attributes[SpanAttributes.HTTP_ROUTE] = flask.request.url_rule.rule
span, token = _start_internal_or_server_span(
tracer=tracer,
span_name=span_name,
Expand Down

0 comments on commit 93daa35

Please sign in to comment.