Skip to content

Commit

Permalink
Apply review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
adamantike committed Apr 6, 2021
1 parent 6bdc9e6 commit 5c42432
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 @@ -146,8 +146,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 @@ -205,7 +204,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 @@ -217,7 +216,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 @@ -113,25 +113,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": {
"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": {
"http.method": "GET",
Expand Down Expand Up @@ -287,12 +287,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 5c42432

Please sign in to comment.