Add common type for signals

This commit is contained in:
Shon Feder 2025-06-23 22:14:36 -04:00
parent b6448b330d
commit a44e0cd3b5
No known key found for this signature in database
2 changed files with 17 additions and 2 deletions

View file

@ -5,6 +5,13 @@ module Span = Opentelemetry.Span
let ( let@ ) = ( @@ ) let ( let@ ) = ( @@ )
module Proto = Opentelemetry.Proto
type t =
| Traces of Proto.Trace.resource_spans list
| Metrics of Proto.Metrics.resource_metrics list
| Logs of Proto.Logs.resource_logs list
module Encode = struct module Encode = struct
let resource_to_string ~encoder ~ctor ~enc resource = let resource_to_string ~encoder ~ctor ~enc resource =
let encoder = let encoder =
@ -63,8 +70,6 @@ module Decode = struct
end end
module Pp = struct module Pp = struct
module Proto = Opentelemetry.Proto
let logs = Format.pp_print_list Proto.Logs.pp_resource_logs let logs = Format.pp_print_list Proto.Logs.pp_resource_logs
let metrics = Format.pp_print_list Proto.Metrics.pp_resource_metrics let metrics = Format.pp_print_list Proto.Metrics.pp_resource_metrics

View file

@ -1,6 +1,16 @@
(** Constructing and managing OTel (** Constructing and managing OTel
{{:https://opentelemetry.io/docs/concepts/signals/} signals} *) {{:https://opentelemetry.io/docs/concepts/signals/} signals} *)
(** The type of signals
This is not the principle type of signals from the perspective of what gets
encoded and sent via protocl buffers, but it is the principle type that
collector clients needs to reason about. *)
type t =
| Traces of Opentelemetry_proto.Trace.resource_spans list
| Metrics of Opentelemetry_proto.Metrics.resource_metrics list
| Logs of Opentelemetry_proto.Logs.resource_logs list
(** Encode 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
*) *)
module Encode : sig module Encode : sig