diff --git a/src/Interpreters/ClientInfo.cpp b/src/Interpreters/ClientInfo.cpp index 347ec115abae..7e8aefad9ac6 100644 --- a/src/Interpreters/ClientInfo.cpp +++ b/src/Interpreters/ClientInfo.cpp @@ -258,4 +258,19 @@ String toString(ClientInfo::Interface interface) return std::format("Unknown {}!\n", static_cast(interface)); } +String toString(ClientInfo::HTTPMethod method) +{ + switch (method) + { + case ClientInfo::HTTPMethod::UNKNOWN: + return "UNKNOWN"; + case ClientInfo::HTTPMethod::GET: + return "GET"; + case ClientInfo::HTTPMethod::POST: + return "POST"; + case ClientInfo::HTTPMethod::OPTIONS: + return "OPTIONS"; + } +} + } diff --git a/src/Interpreters/ClientInfo.h b/src/Interpreters/ClientInfo.h index 705243330475..5a2c5aef9043 100644 --- a/src/Interpreters/ClientInfo.h +++ b/src/Interpreters/ClientInfo.h @@ -145,5 +145,5 @@ class ClientInfo }; String toString(ClientInfo::Interface interface); - +String toString(ClientInfo::HTTPMethod method); } diff --git a/src/Server/GRPCServer.cpp b/src/Server/GRPCServer.cpp index 7c5323126128..d925389c4dfe 100644 --- a/src/Server/GRPCServer.cpp +++ b/src/Server/GRPCServer.cpp @@ -855,6 +855,9 @@ namespace query_context->getSettingsRef(), query_context->getOpenTelemetrySpanLog()); thread_trace_context->root_span.kind = OpenTelemetry::SERVER; + thread_trace_context->root_span.addAttribute("http.referer", query_context->getClientInfo().http_referer); + thread_trace_context->root_span.addAttribute("http.user.agent", query_context->getClientInfo().http_user_agent); + thread_trace_context->root_span.addAttribute("http.method", toString(query_context->getClientInfo().http_method)); /// Prepare for sending exceptions and logs. const Settings & settings = query_context->getSettingsRef(); diff --git a/src/Server/HTTPHandler.cpp b/src/Server/HTTPHandler.cpp index 72e7c5552f85..f4f5d0a784e9 100644 --- a/src/Server/HTTPHandler.cpp +++ b/src/Server/HTTPHandler.cpp @@ -1060,6 +1060,9 @@ void HTTPHandler::handleRequest(HTTPServerRequest & request, HTTPServerResponse context->getOpenTelemetrySpanLog()); thread_trace_context->root_span.kind = OpenTelemetry::SERVER; thread_trace_context->root_span.addAttribute("clickhouse.uri", request.getURI()); + thread_trace_context->root_span.addAttribute("http.referer", session->getClientInfo().http_referer); + thread_trace_context->root_span.addAttribute("http.user.agent", session->getClientInfo().http_user_agent); + thread_trace_context->root_span.addAttribute("http.method", toString(session->getClientInfo().http_method)); response.setContentType("text/plain; charset=UTF-8"); response.set("X-ClickHouse-Server-Display-Name", server_display_name); diff --git a/src/Server/TCPHandler.cpp b/src/Server/TCPHandler.cpp index e1086ac5833a..1da84b06fa45 100644 --- a/src/Server/TCPHandler.cpp +++ b/src/Server/TCPHandler.cpp @@ -386,6 +386,9 @@ void TCPHandler::runImpl() query_context->getSettingsRef(), query_context->getOpenTelemetrySpanLog()); thread_trace_context->root_span.kind = OpenTelemetry::SERVER; + thread_trace_context->root_span.addAttribute("http.referer", query_context->getClientInfo().http_referer); + thread_trace_context->root_span.addAttribute("http.user.agent", query_context->getClientInfo().http_user_agent); + thread_trace_context->root_span.addAttribute("http.method", toString(query_context->getClientInfo().http_method)); query_scope.emplace(query_context, /* fatal_error_callback */ [this] {