@@ -183,7 +183,7 @@ module Http (IO : IO_TYPE) (Curl_IO : CURL with type 'a t = 'a IO.t) : HTTP with
183183 let with_curl_cache f = bracket (return @@ CurlCache. get () ) (fun h -> CurlCache. release h; return_unit) f
184184
185185 let get_curl_data h =
186- [
186+ let data = [
187187 " http.response.status_code" , `Int (Curl. get_httpcode h);
188188 " http.response.body.size" , `Int (int_of_float (Curl. get_sizedownload h));
189189 " http.request.body.size" , `Int (int_of_float (Curl. get_sizeupload h));
@@ -195,7 +195,9 @@ module Http (IO : IO_TYPE) (Curl_IO : CURL with type 'a t = 'a IO.t) : HTTP with
195195 | HTTP_VERSION_2 | HTTP_VERSION_2TLS | HTTP_VERSION_2_PRIOR_KNOWLEDGE -> "2"
196196 | HTTP_VERSION_3 -> "3" | HTTP_VERSION_NONE -> "?");
197197 *)
198- ]
198+ ] in
199+ let ct = Curl. get_contenttype h in
200+ if ct <> " " then (" http.response.header.content-type" , `String ct) :: data else data
199201
200202 let update_timer h timer =
201203 match timer with
@@ -271,8 +273,9 @@ module Http (IO : IO_TYPE) (Curl_IO : CURL with type 'a t = 'a IO.t) : HTTP with
271273 let http_request' ?ua ?timeout ?(verbose =false ) ?(setup =ignore) ?timer ?max_size ?(http_1_0 =false ) ?headers ?body (action :http_action ) url =
272274 let open Curl in
273275 let action_name = string_of_http_action action in
274- let ch_query_id = ref None in
275- let ch_summary = ref None in
276+ let ch_query_id = ref None in
277+ let ch_summary = ref None in
278+ let resp_content_encoding = ref None in
276279
277280 let setup ~headers set_body_and_headers h =
278281 begin match body with
@@ -301,7 +304,8 @@ module Http (IO : IO_TYPE) (Curl_IO : CURL with type 'a t = 'a IO.t) : HTTP with
301304 (let k, v = Stre. dividec s ':' in
302305 match String. lowercase_ascii k with
303306 | "x-clickhouse-query-id" -> ch_query_id := Some (String. trim v)
304- | "x-clickhouse-summary" -> ch_summary := Some (String. trim v)
307+ | "x-clickhouse-summary" -> ch_summary := Some (String. trim v)
308+ | "content-encoding" -> resp_content_encoding := Some (String. trim v)
305309 | _ -> () );
306310 String. length s
307311 );
@@ -356,6 +360,8 @@ module Http (IO : IO_TYPE) (Curl_IO : CURL with type 'a t = 'a IO.t) : HTTP with
356360 | Some v -> (" http.response.header.x-clickhouse-query-id" , `String v) :: data in
357361 let data = match ! ch_summary with None -> data
358362 | Some v -> (" http.response.header.x-clickhouse-summary" , `String v) :: data in
363+ let data = match ! resp_content_encoding with None -> data
364+ | Some v -> (" http.response.header.content-encoding" , `String v) :: data in
359365 Trace_core. add_data_to_manual_span explicit_span data
360366 );
361367 Trace_core. exit_manual_span explicit_span;
0 commit comments