improved logging for ocurl exporter

This commit is contained in:
Simon Cruanes 2022-07-06 19:49:12 -04:00
parent d3b366f04b
commit 16667a3fcf
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4

View file

@ -93,7 +93,8 @@ end = struct
let { curl; buf_res } = self in let { curl; buf_res } = self in
Curl.reset curl; Curl.reset curl;
if !debug_ then Curl.set_verbose curl true; if !debug_ then Curl.set_verbose curl true;
Curl.set_url curl (!url ^ path); let full_url = !url ^ path in
Curl.set_url curl full_url;
Curl.set_httppost curl []; Curl.set_httppost curl [];
let to_http_header (k, v) = Printf.sprintf "%s: %s" k v in let to_http_header (k, v) = Printf.sprintf "%s: %s" k v in
let http_headers = List.map to_http_header !headers in let http_headers = List.map to_http_header !headers in
@ -146,11 +147,11 @@ end = struct
Error Error
(`Failure (`Failure
(spf (spf
"decoding of status (code=%d) failed with:\n\ "httpc: decoding of status (url=%S, code=%d) failed with:\n\
%s\n\ %s\n\
status: %S\n\ status: %S\n\
%s" %s"
code (Printexc.to_string e) str bt)) full_url code (Printexc.to_string e) str bt))
) )
| exception Sys.Break -> Error `Sysbreak | exception Sys.Break -> Error `Sysbreak
| exception Curl.CurlException (_, code, msg) -> | exception Curl.CurlException (_, code, msg) ->
@ -165,11 +166,11 @@ end = struct
| e -> | e ->
let bt = Printexc.get_backtrace () in let bt = Printexc.get_backtrace () in
Error Error
(`Failure (spf "httpc: failed with:\n%s\n%s" (Printexc.to_string e) bt)) (`Failure
(spf "httpc: post on url=%S failed with:\n%s\n%s" full_url
(Printexc.to_string e) bt))
end end
module type BATCH = sig end
(** Batch of resources to be pushed later. (** Batch of resources to be pushed later.
This type is thread-safe. *) This type is thread-safe. *)