diff --git a/src/schema_registry/telemetry/tracer.py b/src/schema_registry/telemetry/tracer.py index b2c19e583..dd4f19988 100644 --- a/src/schema_registry/telemetry/tracer.py +++ b/src/schema_registry/telemetry/tracer.py @@ -80,12 +80,16 @@ def add_span_attribute(span: Span, key: str, value: str | int) -> None: span.set_attribute(key, value) @staticmethod - def update_span_with_request(request: Request, span: Span) -> None: + def update_span_with_request( + request: Request, + span: Span, + config: Config = Provide[KarapaceContainer.config], + ) -> None: if span.is_recording(): span.set_attribute(C.CLIENT_ADDRESS, request.client.host or "" if request.client else "") span.set_attribute(C.CLIENT_PORT, request.client.port or "" if request.client else "") - span.set_attribute(S.SERVER_ADDRESS, request.url.hostname or "") - span.set_attribute(S.SERVER_PORT, request.url.port or "") + span.set_attribute(S.SERVER_ADDRESS, config.host) + span.set_attribute(S.SERVER_PORT, config.port) span.set_attribute(U.URL_SCHEME, request.url.scheme) span.set_attribute(U.URL_PATH, request.url.path) span.set_attribute(H.HTTP_REQUEST_METHOD, request.method) diff --git a/tests/unit/schema_registry/telemetry/test_tracer.py b/tests/unit/schema_registry/telemetry/test_tracer.py index 6e307f8d2..4610e213a 100644 --- a/tests/unit/schema_registry/telemetry/test_tracer.py +++ b/tests/unit/schema_registry/telemetry/test_tracer.py @@ -137,7 +137,7 @@ def test_update_span_with_request(): [ call("client.address", "client"), call("client.port", 8080), - call("server.address", "server"), + call("server.address", "127.0.0.1"), call("server.port", 8081), call("url.scheme", "http"), call("url.path", "/test"),