Skip to content

Commit ce2ccb4

Browse files
committed
wip
1 parent cfcf3cc commit ce2ccb4

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

ddtrace/_trace/trace_handlers.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def _start_span(ctx: core.ExecutionContext, call_trace: bool = True, **kwargs) -
140140

141141
if config._inferred_proxy_services_enabled:
142142
# dispatch event for checking headers and possibly making an inferred proxy span
143-
core.dispatch("inferred_proxy.start", (ctx, tracer, span_kwargs, call_trace, integration_config))
143+
core.dispatch("inferred_proxy.start", (ctx, tracer, span_kwargs, call_trace))
144144
# re-get span_kwargs in case an inferred span was created and we have a new span_kwargs.child_of field
145145
span_kwargs = ctx.get_item("span_kwargs", span_kwargs)
146146

@@ -246,14 +246,15 @@ def _set_inferred_proxy_tags(span, status_code):
246246
inferred_span.set_tag(ERROR_STACK, span.get_tag(ERROR_STACK))
247247

248248

249-
def _on_inferred_proxy_start(ctx, tracer, span_kwargs, call_trace, integration_config):
249+
def _on_inferred_proxy_start(ctx, tracer, span_kwargs, call_trace):
250250
# Skip creating another inferred span if one has already been created for this request
251251
if ctx.get_item("inferred_proxy_span"):
252252
return
253253

254254
# some integrations like Flask / WSGI store headers from environ in 'distributed_headers'
255255
# and normalized headers in 'headers'
256256
headers = ctx.get_item("headers", ctx.get_item("distributed_headers", None))
257+
integration_config = ctx.get_item("integration_config")
257258

258259
# Inferred Proxy Spans
259260
if integration_config and headers is not None:
@@ -995,14 +996,15 @@ def _set_client_ip_tags(scope: Mapping[str, Any], span: Span):
995996
log.debug("Could not validate client IP address for websocket send message: %s", str(e))
996997

997998

998-
def _on_asgi_websocket_receive_message(ctx, scope, message, integration_config):
999+
def _on_asgi_websocket_receive_message(ctx, scope, message):
9991000
"""
10001001
Handle websocket receive message events.
10011002
10021003
This handler is called when a websocket receive message event is dispatched.
10031004
It sets up the span with appropriate tags, metrics, and links.
10041005
"""
10051006
span = ctx.span
1007+
integration_config = ctx.get_item("integration_config")
10061008

10071009
span.set_tag_str(COMPONENT, integration_config.integration_name)
10081010
span.set_tag_str(SPAN_KIND, SpanKind.CONSUMER)
@@ -1025,14 +1027,15 @@ def _on_asgi_websocket_receive_message(ctx, scope, message, integration_config):
10251027
_copy_trace_level_tags(span, ctx.parent.span)
10261028

10271029

1028-
def _on_asgi_websocket_send_message(ctx, scope, message, integration_config):
1030+
def _on_asgi_websocket_send_message(ctx, scope, message):
10291031
"""
10301032
Handle websocket send message events.
10311033
10321034
This handler is called when a websocket send message event is dispatched.
10331035
It sets up the span with appropriate tags, metrics, and links.
10341036
"""
10351037
span = ctx.span
1038+
integration_config = ctx.get_item("integration_config")
10361039

10371040
span.set_tag_str(COMPONENT, integration_config.integration_name)
10381041
span.set_tag_str(SPAN_KIND, SpanKind.PRODUCER)
@@ -1049,14 +1052,15 @@ def _on_asgi_websocket_send_message(ctx, scope, message, integration_config):
10491052
)
10501053

10511054

1052-
def _on_asgi_websocket_close_message(ctx, scope, message, integration_config):
1055+
def _on_asgi_websocket_close_message(ctx, scope, message):
10531056
"""
10541057
Handle websocket close message events.
10551058
10561059
This handler is called when a websocket close message event is dispatched.
10571060
It sets up the span with appropriate tags, metrics, and links.
10581061
"""
10591062
span = ctx.span
1063+
integration_config = ctx.get_item("integration_config")
10601064

10611065
span.set_tag_str(COMPONENT, integration_config.integration_name)
10621066
span.set_tag_str(SPAN_KIND, SpanKind.PRODUCER)
@@ -1077,14 +1081,15 @@ def _on_asgi_websocket_close_message(ctx, scope, message, integration_config):
10771081
_copy_trace_level_tags(span, ctx.parent.span)
10781082

10791083

1080-
def _on_asgi_websocket_disconnect_message(ctx, scope, message, integration_config):
1084+
def _on_asgi_websocket_disconnect_message(ctx, scope, message):
10811085
"""
10821086
Handle websocket disconnect message events.
10831087
10841088
This handler is called when a websocket disconnect message event is dispatched.
10851089
It sets up the span with appropriate tags, metrics, and links.
10861090
"""
10871091
span = ctx.span
1092+
integration_config = ctx.get_item("integration_config")
10881093

10891094
span.set_tag_str(COMPONENT, integration_config.integration_name)
10901095
span.set_tag_str(SPAN_KIND, SpanKind.CONSUMER)

ddtrace/contrib/internal/asgi/middleware.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ def _handle_websocket_send_message(self, scope: Mapping[str, Any], message: Mapp
494494
activate=True,
495495
tags={COMPONENT: self.integration_config.integration_name, SPAN_KIND: SpanKind.PRODUCER},
496496
) as ctx: # noqa: F841
497-
core.dispatch("asgi.websocket.send.message", (ctx, scope, message, self.integration_config))
497+
core.dispatch("asgi.websocket.send.message", (ctx, scope, message))
498498

499499
def _handle_websocket_close_message(self, scope: Mapping[str, Any], message: Mapping[str, Any], request_span: Span):
500500
current_receive_span = scope.get("datadog", {}).get("current_receive_span")
@@ -517,7 +517,7 @@ def _handle_websocket_close_message(self, scope: Mapping[str, Any], message: Map
517517
activate=True,
518518
tags={COMPONENT: self.integration_config.integration_name, SPAN_KIND: SpanKind.PRODUCER},
519519
) as ctx: # noqa: F841
520-
core.dispatch("asgi.websocket.close.message", (ctx, scope, message, self.integration_config))
520+
core.dispatch("asgi.websocket.close.message", (ctx, scope, message))
521521

522522
_cleanup_previous_receive(scope)
523523

@@ -553,7 +553,7 @@ def _handle_websocket_receive_message(
553553
request_span: Span,
554554
):
555555
_cleanup_previous_receive(scope)
556-
core.dispatch("asgi.websocket.receive.message", (ctx, scope, message, self.integration_config))
556+
core.dispatch("asgi.websocket.receive.message", (ctx, scope, message))
557557

558558
scope["datadog"]["current_receive_span"] = recv_span
559559

@@ -576,7 +576,7 @@ def _handle_websocket_disconnect_message(
576576
activate=True,
577577
tags={COMPONENT: self.integration_config.integration_name, SPAN_KIND: SpanKind.CONSUMER},
578578
) as ctx:
579-
core.dispatch("asgi.websocket.disconnect.message", (ctx, scope, message, self.integration_config))
579+
core.dispatch("asgi.websocket.disconnect.message", (ctx, scope, message))
580580

581581
if request_span and request_span.error == 0:
582582
request_span.finish()

0 commit comments

Comments
 (0)