Skip to content

Commit

Permalink
Apply review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
adamantike committed May 6, 2021
1 parent 2d35496 commit 99cc9b5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ def get_default_span_details(scope: dict) -> Tuple[str, dict]:
Returns:
a tuple of the span name, and any attributes to attach to the span.
"""
method_or_path = scope.get("method") or scope.get("path")
span_name = "HTTP {}".format(method_or_path.strip())
span_name = scope.get("path") or "HTTP {}".format(scope.get("method", "").strip())

return span_name, {}

Expand Down Expand Up @@ -216,7 +215,7 @@ async def __call__(self, scope, receive, send):
@wraps(receive)
async def wrapped_receive():
with self.tracer.start_as_current_span(
span_name + " asgi." + scope["type"] + ".receive"
span_name + " " + scope["type"] + ".receive"
) as receive_span:
message = await receive()
if receive_span.is_recording():
Expand All @@ -228,7 +227,7 @@ async def wrapped_receive():
@wraps(send)
async def wrapped_send(message):
with self.tracer.start_as_current_span(
span_name + " asgi." + scope["type"] + ".send"
span_name + " " + scope["type"] + ".send"
) as send_span:
if send_span.is_recording():
if message["type"] == "http.response.start":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,25 +116,25 @@ def validate_outputs(self, outputs, error=None, modifiers=None):
self.assertEqual(len(span_list), 4)
expected = [
{
"name": "HTTP GET asgi.http.receive",
"name": "/ http.receive",
"kind": trace_api.SpanKind.INTERNAL,
"attributes": {"type": "http.request"},
},
{
"name": "HTTP GET asgi.http.send",
"name": "/ http.send",
"kind": trace_api.SpanKind.INTERNAL,
"attributes": {
SpanAttributes.HTTP_STATUS_CODE: 200,
"type": "http.response.start",
},
},
{
"name": "HTTP GET asgi.http.send",
"name": "/ http.send",
"kind": trace_api.SpanKind.INTERNAL,
"attributes": {"type": "http.response.body"},
},
{
"name": "HTTP GET",
"name": "/",
"kind": trace_api.SpanKind.SERVER,
"attributes": {
SpanAttributes.HTTP_METHOD: "GET",
Expand Down Expand Up @@ -306,12 +306,12 @@ def test_websocket(self):
span_list = self.memory_exporter.get_finished_spans()
self.assertEqual(len(span_list), 6)
expected = [
"HTTP / asgi.websocket.receive",
"HTTP / asgi.websocket.send",
"HTTP / asgi.websocket.receive",
"HTTP / asgi.websocket.send",
"HTTP / asgi.websocket.receive",
"HTTP /",
"/ websocket.receive",
"/ websocket.send",
"/ websocket.receive",
"/ websocket.send",
"/ websocket.receive",
"/",
]
actual = [span.name for span in span_list]
self.assertListEqual(actual, expected)
Expand Down

0 comments on commit 99cc9b5

Please sign in to comment.