From 1880d5282c30dcab49fb55bfdd643ec05234dcdc Mon Sep 17 00:00:00 2001 From: Michael Manganiello Date: Mon, 24 May 2021 22:23:52 -0300 Subject: [PATCH] Replace dots with spaces to separate destination and operation names --- .../instrumentation/asgi/__init__.py | 4 ++-- .../tests/test_asgi_middleware.py | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py b/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py index 6e0f31b9b2..49f4178589 100644 --- a/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py @@ -217,7 +217,7 @@ async def __call__(self, scope, receive, send): @wraps(receive) async def wrapped_receive(): with self.tracer.start_as_current_span( - span_name + " " + scope["type"] + ".receive" + " ".join((span_name, scope["type"], "receive")) ) as receive_span: message = await receive() if receive_span.is_recording(): @@ -229,7 +229,7 @@ async def wrapped_receive(): @wraps(send) async def wrapped_send(message): with self.tracer.start_as_current_span( - span_name + " " + scope["type"] + ".send" + " ".join((span_name, scope["type"], "send")) ) as send_span: if send_span.is_recording(): if message["type"] == "http.response.start": diff --git a/instrumentation/opentelemetry-instrumentation-asgi/tests/test_asgi_middleware.py b/instrumentation/opentelemetry-instrumentation-asgi/tests/test_asgi_middleware.py index 148fee7006..5d42c255a0 100644 --- a/instrumentation/opentelemetry-instrumentation-asgi/tests/test_asgi_middleware.py +++ b/instrumentation/opentelemetry-instrumentation-asgi/tests/test_asgi_middleware.py @@ -116,12 +116,12 @@ def validate_outputs(self, outputs, error=None, modifiers=None): self.assertEqual(len(span_list), 4) expected = [ { - "name": "/ http.receive", + "name": "/ http receive", "kind": trace_api.SpanKind.INTERNAL, "attributes": {"type": "http.request"}, }, { - "name": "/ http.send", + "name": "/ http send", "kind": trace_api.SpanKind.INTERNAL, "attributes": { SpanAttributes.HTTP_STATUS_CODE: 200, @@ -129,7 +129,7 @@ def validate_outputs(self, outputs, error=None, modifiers=None): }, }, { - "name": "/ http.send", + "name": "/ http send", "kind": trace_api.SpanKind.INTERNAL, "attributes": {"type": "http.response.body"}, }, @@ -204,7 +204,7 @@ def update_expected_span_name(expected): entry["name"] = span_name else: entry["name"] = " ".join( - [span_name] + entry["name"].split(" ")[-1:] + [span_name] + entry["name"].split(" ")[1:] ) return expected @@ -306,11 +306,11 @@ def test_websocket(self): span_list = self.memory_exporter.get_finished_spans() self.assertEqual(len(span_list), 6) expected = [ - "/ websocket.receive", - "/ websocket.send", - "/ websocket.receive", - "/ websocket.send", - "/ websocket.receive", + "/ websocket receive", + "/ websocket send", + "/ websocket receive", + "/ websocket send", + "/ websocket receive", "/", ] actual = [span.name for span in span_list]