mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-08 20:07:55 -04:00
Fix Signal encoder name choice
Don't know why I didn't opt for this clearer name originally.
This commit is contained in:
parent
d3235a1864
commit
39920ed109
4 changed files with 11 additions and 15 deletions
|
|
@ -190,7 +190,6 @@ end
|
||||||
let mk_emitter ~stop ~(config : Config.t) () : (module EMITTER) =
|
let mk_emitter ~stop ~(config : Config.t) () : (module EMITTER) =
|
||||||
let open Proto in
|
let open Proto in
|
||||||
let open Lwt.Syntax in
|
let open Lwt.Syntax in
|
||||||
let module Conv = Signal.Converter in
|
|
||||||
(* local helpers *)
|
(* local helpers *)
|
||||||
let open struct
|
let open struct
|
||||||
let timeout =
|
let timeout =
|
||||||
|
|
@ -228,13 +227,13 @@ let mk_emitter ~stop ~(config : Config.t) () : (module EMITTER) =
|
||||||
Lwt_unix.sleep 3.
|
Lwt_unix.sleep 3.
|
||||||
|
|
||||||
let send_metrics_http client (l : Metrics.resource_metrics list) =
|
let send_metrics_http client (l : Metrics.resource_metrics list) =
|
||||||
Conv.metrics l |> send_http_ client ~url:config.url_metrics
|
Signal.Encode.metrics l |> send_http_ client ~url:config.url_metrics
|
||||||
|
|
||||||
let send_traces_http client (l : Trace.resource_spans list) =
|
let send_traces_http client (l : Trace.resource_spans list) =
|
||||||
Conv.traces l |> send_http_ client ~url:config.url_traces
|
Signal.Encode.traces l |> send_http_ client ~url:config.url_traces
|
||||||
|
|
||||||
let send_logs_http client (l : Logs.resource_logs list) =
|
let send_logs_http client (l : Logs.resource_logs list) =
|
||||||
Conv.logs l |> send_http_ client ~url:config.url_logs
|
Signal.Encode.logs l |> send_http_ client ~url:config.url_logs
|
||||||
|
|
||||||
(* emit metrics, if the batch is full or timeout lapsed *)
|
(* emit metrics, if the batch is full or timeout lapsed *)
|
||||||
let emit_metrics_maybe ~now ?force httpc : bool Lwt.t =
|
let emit_metrics_maybe ~now ?force httpc : bool Lwt.t =
|
||||||
|
|
|
||||||
|
|
@ -201,20 +201,19 @@ end = struct
|
||||||
in
|
in
|
||||||
conv l |> send_http_ ~stop ~config ~url client
|
conv l |> send_http_ ~stop ~config ~url client
|
||||||
in
|
in
|
||||||
let module Conv = Signal.Converter in
|
|
||||||
try
|
try
|
||||||
while not (Atomic.get stop) do
|
while not (Atomic.get stop) do
|
||||||
let msg = B_queue.pop self.send_q in
|
let msg = B_queue.pop self.send_q in
|
||||||
match msg with
|
match msg with
|
||||||
| To_send.Send_trace tr ->
|
| To_send.Send_trace tr ->
|
||||||
send ~name:"send-traces" ~conv:Conv.traces
|
send ~name:"send-traces" ~conv:Signal.Encode.traces
|
||||||
~url:config.common.url_traces tr
|
~url:config.common.url_traces tr
|
||||||
| To_send.Send_metric ms ->
|
| To_send.Send_metric ms ->
|
||||||
send ~name:"send-metrics" ~conv:Conv.metrics
|
send ~name:"send-metrics" ~conv:Signal.Encode.metrics
|
||||||
~url:config.common.url_metrics ms
|
~url:config.common.url_metrics ms
|
||||||
| To_send.Send_logs logs ->
|
| To_send.Send_logs logs ->
|
||||||
send ~name:"send-logs" ~conv:Conv.logs ~url:config.common.url_logs
|
send ~name:"send-logs" ~conv:Signal.Encode.logs
|
||||||
logs
|
~url:config.common.url_logs logs
|
||||||
done
|
done
|
||||||
with B_queue.Closed -> ()
|
with B_queue.Closed -> ()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ module Span = Opentelemetry.Span
|
||||||
|
|
||||||
let ( let@ ) = ( @@ )
|
let ( let@ ) = ( @@ )
|
||||||
|
|
||||||
module Converter = struct
|
module Encode = struct
|
||||||
let resource_to_string ~encoder ~ctor ~enc resource =
|
let resource_to_string ~encoder ~ctor ~enc resource =
|
||||||
let encoder =
|
let encoder =
|
||||||
match encoder with
|
match encoder with
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,9 @@
|
||||||
(** Constructing and managing OTel
|
(** Constructing and managing OTel
|
||||||
{{:https://opentelemetry.io/docs/concepts/signals/} signals} *)
|
{{:https://opentelemetry.io/docs/concepts/signals/} signals} *)
|
||||||
|
|
||||||
(** Convert signals to protobuf encoded strings, ready to be sent over the wire
|
(** Encode signals to protobuf encoded strings, ready to be sent over the wire
|
||||||
|
*)
|
||||||
NOTE: The converters share an underlying stateful encoder, so each domain or
|
module Encode : sig
|
||||||
system thread should have its own [Converter] instance *)
|
|
||||||
module Converter : sig
|
|
||||||
val logs :
|
val logs :
|
||||||
?encoder:Pbrt.Encoder.t ->
|
?encoder:Pbrt.Encoder.t ->
|
||||||
Opentelemetry_proto.Logs.resource_logs list ->
|
Opentelemetry_proto.Logs.resource_logs list ->
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue