mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-08 03:47:59 -04:00
better semantic conventions for self tracing; bounded_queue.high_watermark
This commit is contained in:
parent
ed69b89bf1
commit
a6bf8171bb
4 changed files with 17 additions and 7 deletions
|
|
@ -23,6 +23,7 @@ module Common = struct
|
|||
num_discarded: unit -> int; (** How many items were discarded? *)
|
||||
size: unit -> int;
|
||||
(** Snapshot of how many items are currently in the queue *)
|
||||
high_watermark: unit -> int; (** Maximum size of the queue *)
|
||||
}
|
||||
|
||||
let[@inline] num_discarded self = self.num_discarded ()
|
||||
|
|
@ -30,6 +31,8 @@ module Common = struct
|
|||
let[@inline] closed (self : t) : bool = self.closed ()
|
||||
|
||||
let[@inline] size (self : t) : int = self.size ()
|
||||
|
||||
let[@inline] high_watermark self = self.high_watermark ()
|
||||
end
|
||||
|
||||
(** Receiving side *)
|
||||
|
|
@ -52,6 +55,8 @@ module Recv = struct
|
|||
|
||||
let[@inline] size self = self.common.size ()
|
||||
|
||||
let[@inline] high_watermark self = self.common.high_watermark ()
|
||||
|
||||
let map (type a b) (f : a -> b) (self : a t) : b t =
|
||||
{
|
||||
self with
|
||||
|
|
@ -86,6 +91,8 @@ module Send = struct
|
|||
|
||||
let[@inline] size self = self.common.size ()
|
||||
|
||||
let[@inline] high_watermark self = self.common.high_watermark ()
|
||||
|
||||
let map (type a b) (f : a list -> b list) (self : b t) : a t =
|
||||
{
|
||||
self with
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ end = struct
|
|||
a value of type [bool] which OCaml's memory model should guarantee. *)
|
||||
let[@inline] closed self = self.closed
|
||||
|
||||
(* NOTE: race condition here is also benign in absoence of tearing. *)
|
||||
(* NOTE: race condition here is also benign in absence of tearing. *)
|
||||
let[@inline] size self = Queue.length self.q
|
||||
|
||||
let close (self : _ t) =
|
||||
|
|
@ -115,12 +115,13 @@ let to_bounded_queue (self : 'a state) : 'a BQ.t =
|
|||
let on_non_empty = Cb_set.register self.on_non_empty in
|
||||
let try_pop () = try_pop self in
|
||||
let size () = Q.size self.q in
|
||||
let high_watermark () = self.high_watermark in
|
||||
let close () =
|
||||
Q.close self.q;
|
||||
(* waiters will want to know *)
|
||||
Cb_set.trigger self.on_non_empty
|
||||
in
|
||||
let common = { BQ.Common.closed; num_discarded; size } in
|
||||
let common = { BQ.Common.closed; num_discarded; size; high_watermark } in
|
||||
{
|
||||
BQ.send = { push; close; common };
|
||||
recv = { try_pop; on_non_empty; common };
|
||||
|
|
|
|||
|
|
@ -50,15 +50,17 @@ let create ~(q : OTEL.Any_signal_l.t Bounded_queue.t)
|
|||
let self_metrics () : _ list =
|
||||
let now = OTEL.Timestamp_ns.now_unix_ns () in
|
||||
let m_size =
|
||||
OTEL.Metrics.gauge ~name:"otel_ocaml.exporter_queue.size"
|
||||
OTEL.Metrics.gauge ~name:"otel.sdk.exporter.queue.size"
|
||||
[ OTEL.Metrics.int ~now (Bounded_queue.Recv.size q.recv) ]
|
||||
in
|
||||
let m_discarded =
|
||||
and m_cap =
|
||||
OTEL.Metrics.gauge ~name:"otel.sdk.exporter.queue.capacity"
|
||||
[ OTEL.Metrics.int ~now (Bounded_queue.Recv.high_watermark q.recv) ]
|
||||
and m_discarded =
|
||||
OTEL.Metrics.sum ~is_monotonic:true
|
||||
~name:"otel_ocaml.exporter_queue.discarded"
|
||||
[ OTEL.Metrics.int ~now (Bounded_queue.Recv.num_discarded q.recv) ]
|
||||
in
|
||||
m_size :: m_discarded :: Consumer.self_metrics consumer
|
||||
m_size :: m_cap :: m_discarded :: Consumer.self_metrics consumer
|
||||
in
|
||||
|
||||
let shutdown () =
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ end = struct
|
|||
let now = OTEL.Timestamp_ns.now_unix_ns () in
|
||||
let attrs = [ "otel.component.name", `String "otel_ocaml" ] in
|
||||
[
|
||||
sum ~name:"otel.sd.exporter.errors" ~is_monotonic:true
|
||||
sum ~name:"otel.sdk.exporter.errors" ~is_monotonic:true
|
||||
[ int ~now (Atomic.get n_errors) ~attrs ];
|
||||
sum ~name:"otel.sdk.exporter.span.exported" ~is_monotonic:true
|
||||
[ int ~now (Atomic.get self.m_spans) ~attrs ];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue