Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 3789a4f

Browse files
committed
Swap getClientAddress().host call for the UNIXAddress compatible replacment, allowing tracing to correctly tag spans.
1 parent 517654f commit 3789a4f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

synapse/logging/opentracing.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ def trace_servlet(
10701070
tags.SPAN_KIND: tags.SPAN_KIND_RPC_SERVER,
10711071
tags.HTTP_METHOD: request.get_method(),
10721072
tags.HTTP_URL: request.get_redacted_uri(),
1073-
tags.PEER_HOST_IPV6: request.getClientAddress().host,
1073+
tags.PEER_HOST_IPV6: request.get_client_ip_if_available(),
10741074
}
10751075

10761076
request_name = request.request_metrics.name
@@ -1091,9 +1091,11 @@ def trace_servlet(
10911091
# with JsonResource).
10921092
scope.span.set_operation_name(request.request_metrics.name)
10931093

1094+
# Mypy seems to think that start_context.tag below can be Optional[str], but
1095+
# that doesn't appear to be correct and works in practice.
10941096
request_tags[
10951097
SynapseTags.REQUEST_TAG
1096-
] = request.request_metrics.start_context.tag
1098+
] = request.request_metrics.start_context.tag # type: ignore[assignment]
10971099

10981100
# set the tags *after* the servlet completes, in case it decided to
10991101
# prioritise the span (tags will get dropped on unprioritised spans)

0 commit comments

Comments
 (0)