mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-08 20:07:55 -04:00
new implementation for ocurl backend, using ezcurl and queues
This commit is contained in:
parent
b5c0ef7b20
commit
832113fe02
5 changed files with 380 additions and 636 deletions
24
src/client-ocurl/batch.ml
Normal file
24
src/client-ocurl/batch.ml
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
type 'a t = {
|
||||||
|
mutable len: int;
|
||||||
|
mutable l: 'a list list;
|
||||||
|
mutable started: Mtime.t;
|
||||||
|
}
|
||||||
|
|
||||||
|
let create () = { len = 0; l = []; started = Mtime_clock.now () }
|
||||||
|
|
||||||
|
let push self l =
|
||||||
|
if l != [] then (
|
||||||
|
if self.l == [] then self.started <- Mtime_clock.now ();
|
||||||
|
self.l <- l :: self.l;
|
||||||
|
self.len <- self.len + List.length l
|
||||||
|
)
|
||||||
|
|
||||||
|
let len self = self.len
|
||||||
|
|
||||||
|
let time_started self = self.started
|
||||||
|
|
||||||
|
let pop_all self =
|
||||||
|
let l = self.l in
|
||||||
|
self.l <- [];
|
||||||
|
self.len <- 0;
|
||||||
|
l
|
||||||
14
src/client-ocurl/batch.mli
Normal file
14
src/client-ocurl/batch.mli
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
(** List of lists with length *)
|
||||||
|
|
||||||
|
type 'a t
|
||||||
|
|
||||||
|
val create : unit -> 'a t
|
||||||
|
|
||||||
|
val push : 'a t -> 'a list -> unit
|
||||||
|
|
||||||
|
val len : _ t -> int
|
||||||
|
|
||||||
|
val time_started : _ t -> Mtime.t
|
||||||
|
(** Time at which the batch most recently became non-empty *)
|
||||||
|
|
||||||
|
val pop_all : 'a t -> 'a list list
|
||||||
|
|
@ -18,10 +18,6 @@ let pp out self =
|
||||||
debug url ppheaders headers batch_timeout_ms bg_threads
|
debug url ppheaders headers batch_timeout_ms bg_threads
|
||||||
|
|
||||||
let make ?(debug = !debug_) ?(url = get_url ()) ?(headers = get_headers ())
|
let make ?(debug = !debug_) ?(url = get_url ()) ?(headers = get_headers ())
|
||||||
?(batch_timeout_ms = 500) ?bg_threads () : t =
|
?(batch_timeout_ms = 500) ?(bg_threads = 4) () : t =
|
||||||
let bg_threads =
|
let bg_threads = max 2 (min bg_threads 32) in
|
||||||
match bg_threads with
|
|
||||||
| Some n -> max n 2
|
|
||||||
| None -> 4
|
|
||||||
in
|
|
||||||
{ debug; url; headers; batch_timeout_ms; bg_threads }
|
{ debug; url; headers; batch_timeout_ms; bg_threads }
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
(** Configuration for the ocurl backend *)
|
||||||
|
|
||||||
type t = private {
|
type t = private {
|
||||||
debug: bool;
|
debug: bool;
|
||||||
url: string;
|
url: string;
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue