Skip to content

Commit fc74620

Browse files
Fix asgi custom attributes
1 parent 1b39798 commit fc74620

File tree

1 file changed

+7
-1
lines changed
  • instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,10 @@ async def user_profile(user_id):
253253
from asgiref.compatibility import guarantee_single_callable
254254

255255
from opentelemetry import context, trace
256-
from opentelemetry.instrumentation._labeler import enhance_metric_attributes
256+
from opentelemetry.instrumentation._labeler import (
257+
enhance_metric_attributes,
258+
get_labeler,
259+
)
257260
from opentelemetry.instrumentation._semconv import (
258261
HTTP_DURATION_HISTOGRAM_BUCKETS_NEW,
259262
_filter_semconv_active_request_count_attr,
@@ -735,6 +738,9 @@ async def __call__(
735738
receive: An awaitable callable yielding dictionaries
736739
send: An awaitable callable taking a single dictionary as argument.
737740
"""
741+
# Required to create new instance for custom attributes in async context
742+
_ = get_labeler()
743+
738744
start = default_timer()
739745
if scope["type"] not in ("http", "websocket"):
740746
return await self.app(scope, receive, send)

0 commit comments

Comments
 (0)