| 842 | |
| 843 | |
| 844 | void Connection::sendQuery( |
| 845 | const ConnectionTimeouts & timeouts, |
| 846 | const String & query, |
| 847 | const NameToNameMap & query_parameters, |
| 848 | const String & query_id_, |
| 849 | UInt64 stage, |
| 850 | const Settings * settings, |
| 851 | const ClientInfo * client_info, |
| 852 | bool with_pending_data, |
| 853 | const std::vector<String> & external_roles, |
| 854 | std::function<void(const Progress &)>) |
| 855 | { |
| 856 | OpenTelemetry::SpanHolder span("Connection::sendQuery()", OpenTelemetry::SpanKind::CLIENT); |
| 857 | span.addAttribute("clickhouse.query_id", query_id_); |
| 858 | span.addAttribute("clickhouse.query", query); |
| 859 | span.addAttribute("target", [this] () { return this->getHost() + ":" + std::to_string(this->getPort()); }); |
| 860 | |
| 861 | ClientInfo new_client_info; |
| 862 | const auto ¤t_trace_context = OpenTelemetry::CurrentContext(); |
| 863 | if (client_info && current_trace_context.isTraceEnabled()) |
| 864 | { |
| 865 | // use current span as the parent of remote span |
| 866 | new_client_info = *client_info; |
| 867 | new_client_info.client_trace_context = current_trace_context; |
| 868 | |
| 869 | client_info = &new_client_info; |
| 870 | } |
| 871 | |
| 872 | #if USE_JWT_CPP && USE_SSL |
| 873 | if (jwt_provider && !jwt.empty()) |
| 874 | { |
| 875 | if (JWTProvider::getJwtExpiry(jwt) < (Poco::Timestamp() + Poco::Timespan(30, 0))) |
| 876 | { |
| 877 | String new_jwt = jwt_provider->getJWT(); |
| 878 | if (!new_jwt.empty()) |
| 879 | { |
| 880 | jwt = new_jwt; |
| 881 | // We have a new token, so we need to reconnect. |
| 882 | // The current connection is still using the old token. |
| 883 | disconnect(); |
| 884 | } |
| 885 | } |
| 886 | } |
| 887 | #endif |
| 888 | |
| 889 | if (!connected) |
| 890 | connect(timeouts); |
| 891 | |
| 892 | /// Query is not executed within sendQuery() function. |
| 893 | /// |
| 894 | /// And what this means that temporary timeout (via TimeoutSetter) is not |
| 895 | /// enough, since next query can use timeout from the previous query in this case. |
| 896 | socket->setReceiveTimeout(timeouts.receive_timeout); |
| 897 | socket->setSendTimeout(timeouts.send_timeout); |
| 898 | |
| 899 | if (settings) |
| 900 | { |
| 901 | std::optional<int> level; |
no test coverage detected