From b826f859774ba6598953ebdadf4951350599a68d Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Tue, 7 Nov 2023 15:33:05 -0500 Subject: [PATCH 1/9] move protobuf code to opentelemetry.proto --- src/common_pb.ml | 224 ------ src/common_pb.mli | 37 - src/common_pp.ml | 39 - src/common_pp.mli | 19 - src/common_types.ml | 65 -- src/common_types.mli | 68 -- src/core/dune | 7 + src/{ => core}/lock.ml | 0 src/{ => core}/lock.mli | 0 src/{ => core}/opentelemetry.ml | 0 src/{ => core}/rand_bytes.ml | 0 src/{ => core}/rand_bytes.mli | 0 src/dune | 125 --- src/logs_pb.ml | 348 --------- src/logs_pb.mli | 43 -- src/logs_pp.ml | 71 -- src/logs_pp.mli | 22 - src/logs_service_pb.ml | 112 --- src/logs_service_pb.mli | 25 - src/logs_service_pp.ml | 20 - src/logs_service_pp.mli | 13 - src/logs_service_types.ml | 35 - src/logs_service_types.mli | 40 - src/logs_types.ml | 116 --- src/logs_types.mli | 111 --- src/metrics_pb.ml | 1282 ------------------------------- src/metrics_pb.mli | 133 ---- src/metrics_pp.ml | 177 ----- src/metrics_pp.mli | 67 -- src/metrics_service_pb.ml | 112 --- src/metrics_service_pb.mli | 25 - src/metrics_service_pp.ml | 20 - src/metrics_service_pp.mli | 13 - src/metrics_service_types.ml | 35 - src/metrics_service_types.mli | 40 - src/metrics_types.ml | 349 --------- src/metrics_types.mli | 309 -------- src/resource_pb.ml | 46 -- src/resource_pb.mli | 13 - src/resource_pp.ml | 8 - src/resource_pp.mli | 7 - src/resource_types.ml | 15 - src/resource_types.mli | 20 - src/status.proto | 10 - src/status_pb.ml | 56 -- src/status_pb.mli | 13 - src/status_pp.ml | 9 - src/status_pp.mli | 7 - src/status_types.ml | 18 - src/status_types.mli | 22 - src/trace_pb.ml | 547 ------------- src/trace_pb.mli | 61 -- src/trace_pp.ml | 84 -- src/trace_pp.mli | 31 - src/trace_service_pb.ml | 112 --- src/trace_service_pb.mli | 25 - src/trace_service_pp.ml | 20 - src/trace_service_pp.mli | 13 - src/trace_service_types.ml | 35 - src/trace_service_types.mli | 40 - src/trace_types.ml | 167 ---- src/trace_types.mli | 149 ---- 62 files changed, 7 insertions(+), 5623 deletions(-) delete mode 100644 src/common_pb.ml delete mode 100644 src/common_pb.mli delete mode 100644 src/common_pp.ml delete mode 100644 src/common_pp.mli delete mode 100644 src/common_types.ml delete mode 100644 src/common_types.mli create mode 100644 src/core/dune rename src/{ => core}/lock.ml (100%) rename src/{ => core}/lock.mli (100%) rename src/{ => core}/opentelemetry.ml (100%) rename src/{ => core}/rand_bytes.ml (100%) rename src/{ => core}/rand_bytes.mli (100%) delete mode 100644 src/dune delete mode 100644 src/logs_pb.ml delete mode 100644 src/logs_pb.mli delete mode 100644 src/logs_pp.ml delete mode 100644 src/logs_pp.mli delete mode 100644 src/logs_service_pb.ml delete mode 100644 src/logs_service_pb.mli delete mode 100644 src/logs_service_pp.ml delete mode 100644 src/logs_service_pp.mli delete mode 100644 src/logs_service_types.ml delete mode 100644 src/logs_service_types.mli delete mode 100644 src/logs_types.ml delete mode 100644 src/logs_types.mli delete mode 100644 src/metrics_pb.ml delete mode 100644 src/metrics_pb.mli delete mode 100644 src/metrics_pp.ml delete mode 100644 src/metrics_pp.mli delete mode 100644 src/metrics_service_pb.ml delete mode 100644 src/metrics_service_pb.mli delete mode 100644 src/metrics_service_pp.ml delete mode 100644 src/metrics_service_pp.mli delete mode 100644 src/metrics_service_types.ml delete mode 100644 src/metrics_service_types.mli delete mode 100644 src/metrics_types.ml delete mode 100644 src/metrics_types.mli delete mode 100644 src/resource_pb.ml delete mode 100644 src/resource_pb.mli delete mode 100644 src/resource_pp.ml delete mode 100644 src/resource_pp.mli delete mode 100644 src/resource_types.ml delete mode 100644 src/resource_types.mli delete mode 100644 src/status.proto delete mode 100644 src/status_pb.ml delete mode 100644 src/status_pb.mli delete mode 100644 src/status_pp.ml delete mode 100644 src/status_pp.mli delete mode 100644 src/status_types.ml delete mode 100644 src/status_types.mli delete mode 100644 src/trace_pb.ml delete mode 100644 src/trace_pb.mli delete mode 100644 src/trace_pp.ml delete mode 100644 src/trace_pp.mli delete mode 100644 src/trace_service_pb.ml delete mode 100644 src/trace_service_pb.mli delete mode 100644 src/trace_service_pp.ml delete mode 100644 src/trace_service_pp.mli delete mode 100644 src/trace_service_types.ml delete mode 100644 src/trace_service_types.mli delete mode 100644 src/trace_types.ml delete mode 100644 src/trace_types.mli diff --git a/src/common_pb.ml b/src/common_pb.ml deleted file mode 100644 index 07425f0f..00000000 --- a/src/common_pb.ml +++ /dev/null @@ -1,224 +0,0 @@ -[@@@ocaml.warning "-27-30-39"] - -type array_value_mutable = { - mutable values : Common_types.any_value list; -} - -let default_array_value_mutable () : array_value_mutable = { - values = []; -} - -type key_value_list_mutable = { - mutable values : Common_types.key_value list; -} - -let default_key_value_list_mutable () : key_value_list_mutable = { - values = []; -} - -type key_value_mutable = { - mutable key : string; - mutable value : Common_types.any_value option; -} - -let default_key_value_mutable () : key_value_mutable = { - key = ""; - value = None; -} - -type instrumentation_scope_mutable = { - mutable name : string; - mutable version : string; - mutable attributes : Common_types.key_value list; - mutable dropped_attributes_count : int32; -} - -let default_instrumentation_scope_mutable () : instrumentation_scope_mutable = { - name = ""; - version = ""; - attributes = []; - dropped_attributes_count = 0l; -} - - -let rec decode_any_value d = - let rec loop () = - let ret:Common_types.any_value = match Pbrt.Decoder.key d with - | None -> Pbrt.Decoder.malformed_variant "any_value" - | Some (1, _) -> (Common_types.String_value (Pbrt.Decoder.string d) : Common_types.any_value) - | Some (2, _) -> (Common_types.Bool_value (Pbrt.Decoder.bool d) : Common_types.any_value) - | Some (3, _) -> (Common_types.Int_value (Pbrt.Decoder.int64_as_varint d) : Common_types.any_value) - | Some (4, _) -> (Common_types.Double_value (Pbrt.Decoder.float_as_bits64 d) : Common_types.any_value) - | Some (5, _) -> (Common_types.Array_value (decode_array_value (Pbrt.Decoder.nested d)) : Common_types.any_value) - | Some (6, _) -> (Common_types.Kvlist_value (decode_key_value_list (Pbrt.Decoder.nested d)) : Common_types.any_value) - | Some (7, _) -> (Common_types.Bytes_value (Pbrt.Decoder.bytes d) : Common_types.any_value) - | Some (n, payload_kind) -> ( - Pbrt.Decoder.skip d payload_kind; - loop () - ) - in - ret - in - loop () - -and decode_array_value d = - let v = default_array_value_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.values <- List.rev v.values; - ); continue__ := false - | Some (1, Pbrt.Bytes) -> begin - v.values <- (decode_any_value (Pbrt.Decoder.nested d)) :: v.values; - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(array_value), field(1)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Common_types.values = v.values; - } : Common_types.array_value) - -and decode_key_value_list d = - let v = default_key_value_list_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.values <- List.rev v.values; - ); continue__ := false - | Some (1, Pbrt.Bytes) -> begin - v.values <- (decode_key_value (Pbrt.Decoder.nested d)) :: v.values; - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(key_value_list), field(1)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Common_types.values = v.values; - } : Common_types.key_value_list) - -and decode_key_value d = - let v = default_key_value_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - ); continue__ := false - | Some (1, Pbrt.Bytes) -> begin - v.key <- Pbrt.Decoder.string d; - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(key_value), field(1)" pk - | Some (2, Pbrt.Bytes) -> begin - v.value <- Some (decode_any_value (Pbrt.Decoder.nested d)); - end - | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(key_value), field(2)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Common_types.key = v.key; - Common_types.value = v.value; - } : Common_types.key_value) - -let rec decode_instrumentation_scope d = - let v = default_instrumentation_scope_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.attributes <- List.rev v.attributes; - ); continue__ := false - | Some (1, Pbrt.Bytes) -> begin - v.name <- Pbrt.Decoder.string d; - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(instrumentation_scope), field(1)" pk - | Some (2, Pbrt.Bytes) -> begin - v.version <- Pbrt.Decoder.string d; - end - | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(instrumentation_scope), field(2)" pk - | Some (3, Pbrt.Bytes) -> begin - v.attributes <- (decode_key_value (Pbrt.Decoder.nested d)) :: v.attributes; - end - | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(instrumentation_scope), field(3)" pk - | Some (4, Pbrt.Varint) -> begin - v.dropped_attributes_count <- Pbrt.Decoder.int32_as_varint d; - end - | Some (4, pk) -> - Pbrt.Decoder.unexpected_payload "Message(instrumentation_scope), field(4)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Common_types.name = v.name; - Common_types.version = v.version; - Common_types.attributes = v.attributes; - Common_types.dropped_attributes_count = v.dropped_attributes_count; - } : Common_types.instrumentation_scope) - -let rec encode_any_value (v:Common_types.any_value) encoder = - begin match v with - | Common_types.String_value x -> - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.string x encoder; - | Common_types.Bool_value x -> - Pbrt.Encoder.key (2, Pbrt.Varint) encoder; - Pbrt.Encoder.bool x encoder; - | Common_types.Int_value x -> - Pbrt.Encoder.key (3, Pbrt.Varint) encoder; - Pbrt.Encoder.int64_as_varint x encoder; - | Common_types.Double_value x -> - Pbrt.Encoder.key (4, Pbrt.Bits64) encoder; - Pbrt.Encoder.float_as_bits64 x encoder; - | Common_types.Array_value x -> - Pbrt.Encoder.key (5, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_array_value x) encoder; - | Common_types.Kvlist_value x -> - Pbrt.Encoder.key (6, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_key_value_list x) encoder; - | Common_types.Bytes_value x -> - Pbrt.Encoder.key (7, Pbrt.Bytes) encoder; - Pbrt.Encoder.bytes x encoder; - end - -and encode_array_value (v:Common_types.array_value) encoder = - List.iter (fun x -> - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_any_value x) encoder; - ) v.Common_types.values; - () - -and encode_key_value_list (v:Common_types.key_value_list) encoder = - List.iter (fun x -> - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_key_value x) encoder; - ) v.Common_types.values; - () - -and encode_key_value (v:Common_types.key_value) encoder = - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.string v.Common_types.key encoder; - begin match v.Common_types.value with - | Some x -> - Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_any_value x) encoder; - | None -> (); - end; - () - -let rec encode_instrumentation_scope (v:Common_types.instrumentation_scope) encoder = - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.string v.Common_types.name encoder; - Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; - Pbrt.Encoder.string v.Common_types.version encoder; - List.iter (fun x -> - Pbrt.Encoder.key (3, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_key_value x) encoder; - ) v.Common_types.attributes; - Pbrt.Encoder.key (4, Pbrt.Varint) encoder; - Pbrt.Encoder.int32_as_varint v.Common_types.dropped_attributes_count encoder; - () diff --git a/src/common_pb.mli b/src/common_pb.mli deleted file mode 100644 index 7ece8615..00000000 --- a/src/common_pb.mli +++ /dev/null @@ -1,37 +0,0 @@ -(** common.proto Binary Encoding *) - - -(** {2 Protobuf Encoding} *) - -val encode_any_value : Common_types.any_value -> Pbrt.Encoder.t -> unit -(** [encode_any_value v encoder] encodes [v] with the given [encoder] *) - -val encode_array_value : Common_types.array_value -> Pbrt.Encoder.t -> unit -(** [encode_array_value v encoder] encodes [v] with the given [encoder] *) - -val encode_key_value_list : Common_types.key_value_list -> Pbrt.Encoder.t -> unit -(** [encode_key_value_list v encoder] encodes [v] with the given [encoder] *) - -val encode_key_value : Common_types.key_value -> Pbrt.Encoder.t -> unit -(** [encode_key_value v encoder] encodes [v] with the given [encoder] *) - -val encode_instrumentation_scope : Common_types.instrumentation_scope -> Pbrt.Encoder.t -> unit -(** [encode_instrumentation_scope v encoder] encodes [v] with the given [encoder] *) - - -(** {2 Protobuf Decoding} *) - -val decode_any_value : Pbrt.Decoder.t -> Common_types.any_value -(** [decode_any_value decoder] decodes a [any_value] value from [decoder] *) - -val decode_array_value : Pbrt.Decoder.t -> Common_types.array_value -(** [decode_array_value decoder] decodes a [array_value] value from [decoder] *) - -val decode_key_value_list : Pbrt.Decoder.t -> Common_types.key_value_list -(** [decode_key_value_list decoder] decodes a [key_value_list] value from [decoder] *) - -val decode_key_value : Pbrt.Decoder.t -> Common_types.key_value -(** [decode_key_value decoder] decodes a [key_value] value from [decoder] *) - -val decode_instrumentation_scope : Pbrt.Decoder.t -> Common_types.instrumentation_scope -(** [decode_instrumentation_scope decoder] decodes a [instrumentation_scope] value from [decoder] *) diff --git a/src/common_pp.ml b/src/common_pp.ml deleted file mode 100644 index e809bafc..00000000 --- a/src/common_pp.ml +++ /dev/null @@ -1,39 +0,0 @@ -[@@@ocaml.warning "-27-30-39"] - -let rec pp_any_value fmt (v:Common_types.any_value) = - match v with - | Common_types.String_value x -> Format.fprintf fmt "@[String_value(@,%a)@]" Pbrt.Pp.pp_string x - | Common_types.Bool_value x -> Format.fprintf fmt "@[Bool_value(@,%a)@]" Pbrt.Pp.pp_bool x - | Common_types.Int_value x -> Format.fprintf fmt "@[Int_value(@,%a)@]" Pbrt.Pp.pp_int64 x - | Common_types.Double_value x -> Format.fprintf fmt "@[Double_value(@,%a)@]" Pbrt.Pp.pp_float x - | Common_types.Array_value x -> Format.fprintf fmt "@[Array_value(@,%a)@]" pp_array_value x - | Common_types.Kvlist_value x -> Format.fprintf fmt "@[Kvlist_value(@,%a)@]" pp_key_value_list x - | Common_types.Bytes_value x -> Format.fprintf fmt "@[Bytes_value(@,%a)@]" Pbrt.Pp.pp_bytes x - -and pp_array_value fmt (v:Common_types.array_value) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "values" (Pbrt.Pp.pp_list pp_any_value) fmt v.Common_types.values; - in - Pbrt.Pp.pp_brk pp_i fmt () - -and pp_key_value_list fmt (v:Common_types.key_value_list) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "values" (Pbrt.Pp.pp_list pp_key_value) fmt v.Common_types.values; - in - Pbrt.Pp.pp_brk pp_i fmt () - -and pp_key_value fmt (v:Common_types.key_value) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "key" Pbrt.Pp.pp_string fmt v.Common_types.key; - Pbrt.Pp.pp_record_field ~first:false "value" (Pbrt.Pp.pp_option pp_any_value) fmt v.Common_types.value; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_instrumentation_scope fmt (v:Common_types.instrumentation_scope) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "name" Pbrt.Pp.pp_string fmt v.Common_types.name; - Pbrt.Pp.pp_record_field ~first:false "version" Pbrt.Pp.pp_string fmt v.Common_types.version; - Pbrt.Pp.pp_record_field ~first:false "attributes" (Pbrt.Pp.pp_list pp_key_value) fmt v.Common_types.attributes; - Pbrt.Pp.pp_record_field ~first:false "dropped_attributes_count" Pbrt.Pp.pp_int32 fmt v.Common_types.dropped_attributes_count; - in - Pbrt.Pp.pp_brk pp_i fmt () diff --git a/src/common_pp.mli b/src/common_pp.mli deleted file mode 100644 index 4c2fc14d..00000000 --- a/src/common_pp.mli +++ /dev/null @@ -1,19 +0,0 @@ -(** common.proto Pretty Printing *) - - -(** {2 Formatters} *) - -val pp_any_value : Format.formatter -> Common_types.any_value -> unit -(** [pp_any_value v] formats v *) - -val pp_array_value : Format.formatter -> Common_types.array_value -> unit -(** [pp_array_value v] formats v *) - -val pp_key_value_list : Format.formatter -> Common_types.key_value_list -> unit -(** [pp_key_value_list v] formats v *) - -val pp_key_value : Format.formatter -> Common_types.key_value -> unit -(** [pp_key_value v] formats v *) - -val pp_instrumentation_scope : Format.formatter -> Common_types.instrumentation_scope -> unit -(** [pp_instrumentation_scope v] formats v *) diff --git a/src/common_types.ml b/src/common_types.ml deleted file mode 100644 index bddc9354..00000000 --- a/src/common_types.ml +++ /dev/null @@ -1,65 +0,0 @@ -[@@@ocaml.warning "-27-30-39"] - - -type any_value = - | String_value of string - | Bool_value of bool - | Int_value of int64 - | Double_value of float - | Array_value of array_value - | Kvlist_value of key_value_list - | Bytes_value of bytes - -and array_value = { - values : any_value list; -} - -and key_value_list = { - values : key_value list; -} - -and key_value = { - key : string; - value : any_value option; -} - -type instrumentation_scope = { - name : string; - version : string; - attributes : key_value list; - dropped_attributes_count : int32; -} - -let rec default_any_value () : any_value = String_value ("") - -and default_array_value - ?values:((values:any_value list) = []) - () : array_value = { - values; -} - -and default_key_value_list - ?values:((values:key_value list) = []) - () : key_value_list = { - values; -} - -and default_key_value - ?key:((key:string) = "") - ?value:((value:any_value option) = None) - () : key_value = { - key; - value; -} - -let rec default_instrumentation_scope - ?name:((name:string) = "") - ?version:((version:string) = "") - ?attributes:((attributes:key_value list) = []) - ?dropped_attributes_count:((dropped_attributes_count:int32) = 0l) - () : instrumentation_scope = { - name; - version; - attributes; - dropped_attributes_count; -} diff --git a/src/common_types.mli b/src/common_types.mli deleted file mode 100644 index 8427638a..00000000 --- a/src/common_types.mli +++ /dev/null @@ -1,68 +0,0 @@ -(** common.proto Types *) - - - -(** {2 Types} *) - -type any_value = - | String_value of string - | Bool_value of bool - | Int_value of int64 - | Double_value of float - | Array_value of array_value - | Kvlist_value of key_value_list - | Bytes_value of bytes - -and array_value = { - values : any_value list; -} - -and key_value_list = { - values : key_value list; -} - -and key_value = { - key : string; - value : any_value option; -} - -type instrumentation_scope = { - name : string; - version : string; - attributes : key_value list; - dropped_attributes_count : int32; -} - - -(** {2 Default values} *) - -val default_any_value : unit -> any_value -(** [default_any_value ()] is the default value for type [any_value] *) - -val default_array_value : - ?values:any_value list -> - unit -> - array_value -(** [default_array_value ()] is the default value for type [array_value] *) - -val default_key_value_list : - ?values:key_value list -> - unit -> - key_value_list -(** [default_key_value_list ()] is the default value for type [key_value_list] *) - -val default_key_value : - ?key:string -> - ?value:any_value option -> - unit -> - key_value -(** [default_key_value ()] is the default value for type [key_value] *) - -val default_instrumentation_scope : - ?name:string -> - ?version:string -> - ?attributes:key_value list -> - ?dropped_attributes_count:int32 -> - unit -> - instrumentation_scope -(** [default_instrumentation_scope ()] is the default value for type [instrumentation_scope] *) diff --git a/src/core/dune b/src/core/dune new file mode 100644 index 00000000..f3dcfa4e --- /dev/null +++ b/src/core/dune @@ -0,0 +1,7 @@ +(library + (name opentelemetry) + (synopsis "API for opentelemetry instrumentation") + (flags :standard -warn-error -a+8 -open Opentelemetry_proto) + (libraries opentelemetry.proto ambient-context ptime ptime.clock.os pbrt threads + opentelemetry.atomic) + (public_name opentelemetry)) diff --git a/src/lock.ml b/src/core/lock.ml similarity index 100% rename from src/lock.ml rename to src/core/lock.ml diff --git a/src/lock.mli b/src/core/lock.mli similarity index 100% rename from src/lock.mli rename to src/core/lock.mli diff --git a/src/opentelemetry.ml b/src/core/opentelemetry.ml similarity index 100% rename from src/opentelemetry.ml rename to src/core/opentelemetry.ml diff --git a/src/rand_bytes.ml b/src/core/rand_bytes.ml similarity index 100% rename from src/rand_bytes.ml rename to src/core/rand_bytes.ml diff --git a/src/rand_bytes.mli b/src/core/rand_bytes.mli similarity index 100% rename from src/rand_bytes.mli rename to src/core/rand_bytes.mli diff --git a/src/dune b/src/dune deleted file mode 100644 index f91ee2aa..00000000 --- a/src/dune +++ /dev/null @@ -1,125 +0,0 @@ -(library - (name opentelemetry) - (synopsis "API for opentelemetry instrumentation") - (flags :standard -warn-error -a+8) - (libraries ambient-context ptime ptime.clock.os pbrt threads - opentelemetry.atomic) - (public_name opentelemetry)) - -; ### protobuf rules ### - -(rule - (alias lint) - (mode promote) - (targets status_types.ml status_types.mli status_pb.ml status_pb.mli - status_pp.ml status_pp.mli) - (deps - (:file status.proto) - (source_tree %{project_root}/vendor/opentelemetry-proto/)) - (action - (run ocaml-protoc %{file} -ml_out . -pp -binary))) - -(rule - (alias lint) - (mode promote) - (targets common_types.ml common_types.mli common_pb.ml common_pb.mli - common_pp.ml common_pp.mli) - (deps - (:file - %{project_root}/vendor/opentelemetry-proto/opentelemetry/proto/common/v1/common.proto) - (source_tree %{project_root}/vendor/opentelemetry-proto/)) - (action - (run ocaml-protoc %{file} -I %{project_root}/vendor/opentelemetry-proto/ - -ml_out . -pp -binary))) - -(rule - (alias lint) - (mode promote) - (targets resource_types.ml resource_types.mli resource_pb.ml resource_pb.mli - resource_pp.ml resource_pp.mli) - (deps - (:file - %{project_root}/vendor/opentelemetry-proto/opentelemetry/proto/resource/v1/resource.proto) - (source_tree %{project_root}/vendor/opentelemetry-proto/)) - (action - (run ocaml-protoc %{file} -I %{project_root}/vendor/opentelemetry-proto/ - -ml_out . -pp -binary))) - -(rule - (alias lint) - (mode promote) - (targets trace_types.ml trace_types.mli trace_pb.ml trace_pb.mli trace_pp.ml - trace_pp.mli) - (deps - (:file - %{project_root}/vendor/opentelemetry-proto/opentelemetry/proto/trace/v1/trace.proto) - (source_tree %{project_root}/vendor/opentelemetry-proto/)) - (action - (run ocaml-protoc %{file} -I %{project_root}/vendor/opentelemetry-proto/ - -ml_out . -pp -binary))) - -(rule - (alias lint) - (mode promote) - (targets metrics_types.ml metrics_types.mli metrics_pb.ml metrics_pb.mli - metrics_pp.ml metrics_pp.mli) - (deps - (:file - %{project_root}/vendor/opentelemetry-proto/opentelemetry/proto/metrics/v1/metrics.proto) - (source_tree %{project_root}/vendor/opentelemetry-proto/)) - (action - (run ocaml-protoc %{file} -I %{project_root}/vendor/opentelemetry-proto/ - -ml_out . -pp -binary))) - -(rule - (alias lint) - (mode promote) - (targets logs_types.ml logs_types.mli logs_pb.ml logs_pb.mli logs_pp.ml - logs_pp.mli) - (deps - (:file - %{project_root}/vendor/opentelemetry-proto/opentelemetry/proto/logs/v1/logs.proto) - (source_tree %{project_root}/vendor/opentelemetry-proto/)) - (action - (run ocaml-protoc %{file} -I %{project_root}/vendor/opentelemetry-proto/ - -ml_out . -pp -binary))) - -(rule - (alias lint) - (mode promote) - (targets metrics_service_types.ml metrics_service_types.mli - metrics_service_pp.ml metrics_service_pp.mli metrics_service_pb.ml - metrics_service_pb.mli) - (deps - (:file - %{project_root}/vendor/opentelemetry-proto/opentelemetry/proto/collector/metrics/v1/metrics_service.proto) - (source_tree %{project_root}/vendor/opentelemetry-proto/)) - (action - (run ocaml-protoc %{file} -I %{project_root}/vendor/opentelemetry-proto/ - -ml_out . -pp -binary))) - -(rule - (alias lint) - (mode promote) - (targets trace_service_types.ml trace_service_types.mli trace_service_pp.ml - trace_service_pp.mli trace_service_pb.ml trace_service_pb.mli) - (deps - (:file - %{project_root}/vendor/opentelemetry-proto/opentelemetry/proto/collector/trace/v1/trace_service.proto) - (source_tree %{project_root}/vendor/opentelemetry-proto/)) - (action - (run ocaml-protoc %{file} -I %{project_root}/vendor/opentelemetry-proto/ - -ml_out . -pp -binary))) - -(rule - (alias lint) - (mode promote) - (targets logs_service_types.ml logs_service_types.mli logs_service_pp.ml - logs_service_pp.mli logs_service_pb.ml logs_service_pb.mli) - (deps - (:file - %{project_root}/vendor/opentelemetry-proto/opentelemetry/proto/collector/logs/v1/logs_service.proto) - (source_tree %{project_root}/vendor/opentelemetry-proto/)) - (action - (run ocaml-protoc %{file} -I %{project_root}/vendor/opentelemetry-proto/ - -ml_out . -pp -binary))) diff --git a/src/logs_pb.ml b/src/logs_pb.ml deleted file mode 100644 index 2ad391c5..00000000 --- a/src/logs_pb.ml +++ /dev/null @@ -1,348 +0,0 @@ -[@@@ocaml.warning "-27-30-39"] - -type log_record_mutable = { - mutable time_unix_nano : int64; - mutable observed_time_unix_nano : int64; - mutable severity_number : Logs_types.severity_number; - mutable severity_text : string; - mutable body : Common_types.any_value option; - mutable attributes : Common_types.key_value list; - mutable dropped_attributes_count : int32; - mutable flags : int32; - mutable trace_id : bytes; - mutable span_id : bytes; -} - -let default_log_record_mutable () : log_record_mutable = { - time_unix_nano = 0L; - observed_time_unix_nano = 0L; - severity_number = Logs_types.default_severity_number (); - severity_text = ""; - body = None; - attributes = []; - dropped_attributes_count = 0l; - flags = 0l; - trace_id = Bytes.create 0; - span_id = Bytes.create 0; -} - -type scope_logs_mutable = { - mutable scope : Common_types.instrumentation_scope option; - mutable log_records : Logs_types.log_record list; - mutable schema_url : string; -} - -let default_scope_logs_mutable () : scope_logs_mutable = { - scope = None; - log_records = []; - schema_url = ""; -} - -type resource_logs_mutable = { - mutable resource : Resource_types.resource option; - mutable scope_logs : Logs_types.scope_logs list; - mutable schema_url : string; -} - -let default_resource_logs_mutable () : resource_logs_mutable = { - resource = None; - scope_logs = []; - schema_url = ""; -} - -type logs_data_mutable = { - mutable resource_logs : Logs_types.resource_logs list; -} - -let default_logs_data_mutable () : logs_data_mutable = { - resource_logs = []; -} - - -let rec decode_severity_number d = - match Pbrt.Decoder.int_as_varint d with - | 0 -> (Logs_types.Severity_number_unspecified:Logs_types.severity_number) - | 1 -> (Logs_types.Severity_number_trace:Logs_types.severity_number) - | 2 -> (Logs_types.Severity_number_trace2:Logs_types.severity_number) - | 3 -> (Logs_types.Severity_number_trace3:Logs_types.severity_number) - | 4 -> (Logs_types.Severity_number_trace4:Logs_types.severity_number) - | 5 -> (Logs_types.Severity_number_debug:Logs_types.severity_number) - | 6 -> (Logs_types.Severity_number_debug2:Logs_types.severity_number) - | 7 -> (Logs_types.Severity_number_debug3:Logs_types.severity_number) - | 8 -> (Logs_types.Severity_number_debug4:Logs_types.severity_number) - | 9 -> (Logs_types.Severity_number_info:Logs_types.severity_number) - | 10 -> (Logs_types.Severity_number_info2:Logs_types.severity_number) - | 11 -> (Logs_types.Severity_number_info3:Logs_types.severity_number) - | 12 -> (Logs_types.Severity_number_info4:Logs_types.severity_number) - | 13 -> (Logs_types.Severity_number_warn:Logs_types.severity_number) - | 14 -> (Logs_types.Severity_number_warn2:Logs_types.severity_number) - | 15 -> (Logs_types.Severity_number_warn3:Logs_types.severity_number) - | 16 -> (Logs_types.Severity_number_warn4:Logs_types.severity_number) - | 17 -> (Logs_types.Severity_number_error:Logs_types.severity_number) - | 18 -> (Logs_types.Severity_number_error2:Logs_types.severity_number) - | 19 -> (Logs_types.Severity_number_error3:Logs_types.severity_number) - | 20 -> (Logs_types.Severity_number_error4:Logs_types.severity_number) - | 21 -> (Logs_types.Severity_number_fatal:Logs_types.severity_number) - | 22 -> (Logs_types.Severity_number_fatal2:Logs_types.severity_number) - | 23 -> (Logs_types.Severity_number_fatal3:Logs_types.severity_number) - | 24 -> (Logs_types.Severity_number_fatal4:Logs_types.severity_number) - | _ -> Pbrt.Decoder.malformed_variant "severity_number" - -let rec decode_log_record d = - let v = default_log_record_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.attributes <- List.rev v.attributes; - ); continue__ := false - | Some (1, Pbrt.Bits64) -> begin - v.time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(log_record), field(1)" pk - | Some (11, Pbrt.Bits64) -> begin - v.observed_time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; - end - | Some (11, pk) -> - Pbrt.Decoder.unexpected_payload "Message(log_record), field(11)" pk - | Some (2, Pbrt.Varint) -> begin - v.severity_number <- decode_severity_number d; - end - | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(log_record), field(2)" pk - | Some (3, Pbrt.Bytes) -> begin - v.severity_text <- Pbrt.Decoder.string d; - end - | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(log_record), field(3)" pk - | Some (5, Pbrt.Bytes) -> begin - v.body <- Some (Common_pb.decode_any_value (Pbrt.Decoder.nested d)); - end - | Some (5, pk) -> - Pbrt.Decoder.unexpected_payload "Message(log_record), field(5)" pk - | Some (6, Pbrt.Bytes) -> begin - v.attributes <- (Common_pb.decode_key_value (Pbrt.Decoder.nested d)) :: v.attributes; - end - | Some (6, pk) -> - Pbrt.Decoder.unexpected_payload "Message(log_record), field(6)" pk - | Some (7, Pbrt.Varint) -> begin - v.dropped_attributes_count <- Pbrt.Decoder.int32_as_varint d; - end - | Some (7, pk) -> - Pbrt.Decoder.unexpected_payload "Message(log_record), field(7)" pk - | Some (8, Pbrt.Bits32) -> begin - v.flags <- Pbrt.Decoder.int32_as_bits32 d; - end - | Some (8, pk) -> - Pbrt.Decoder.unexpected_payload "Message(log_record), field(8)" pk - | Some (9, Pbrt.Bytes) -> begin - v.trace_id <- Pbrt.Decoder.bytes d; - end - | Some (9, pk) -> - Pbrt.Decoder.unexpected_payload "Message(log_record), field(9)" pk - | Some (10, Pbrt.Bytes) -> begin - v.span_id <- Pbrt.Decoder.bytes d; - end - | Some (10, pk) -> - Pbrt.Decoder.unexpected_payload "Message(log_record), field(10)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Logs_types.time_unix_nano = v.time_unix_nano; - Logs_types.observed_time_unix_nano = v.observed_time_unix_nano; - Logs_types.severity_number = v.severity_number; - Logs_types.severity_text = v.severity_text; - Logs_types.body = v.body; - Logs_types.attributes = v.attributes; - Logs_types.dropped_attributes_count = v.dropped_attributes_count; - Logs_types.flags = v.flags; - Logs_types.trace_id = v.trace_id; - Logs_types.span_id = v.span_id; - } : Logs_types.log_record) - -let rec decode_scope_logs d = - let v = default_scope_logs_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.log_records <- List.rev v.log_records; - ); continue__ := false - | Some (1, Pbrt.Bytes) -> begin - v.scope <- Some (Common_pb.decode_instrumentation_scope (Pbrt.Decoder.nested d)); - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(scope_logs), field(1)" pk - | Some (2, Pbrt.Bytes) -> begin - v.log_records <- (decode_log_record (Pbrt.Decoder.nested d)) :: v.log_records; - end - | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(scope_logs), field(2)" pk - | Some (3, Pbrt.Bytes) -> begin - v.schema_url <- Pbrt.Decoder.string d; - end - | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(scope_logs), field(3)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Logs_types.scope = v.scope; - Logs_types.log_records = v.log_records; - Logs_types.schema_url = v.schema_url; - } : Logs_types.scope_logs) - -let rec decode_resource_logs d = - let v = default_resource_logs_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.scope_logs <- List.rev v.scope_logs; - ); continue__ := false - | Some (1, Pbrt.Bytes) -> begin - v.resource <- Some (Resource_pb.decode_resource (Pbrt.Decoder.nested d)); - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(resource_logs), field(1)" pk - | Some (2, Pbrt.Bytes) -> begin - v.scope_logs <- (decode_scope_logs (Pbrt.Decoder.nested d)) :: v.scope_logs; - end - | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(resource_logs), field(2)" pk - | Some (3, Pbrt.Bytes) -> begin - v.schema_url <- Pbrt.Decoder.string d; - end - | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(resource_logs), field(3)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Logs_types.resource = v.resource; - Logs_types.scope_logs = v.scope_logs; - Logs_types.schema_url = v.schema_url; - } : Logs_types.resource_logs) - -let rec decode_logs_data d = - let v = default_logs_data_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.resource_logs <- List.rev v.resource_logs; - ); continue__ := false - | Some (1, Pbrt.Bytes) -> begin - v.resource_logs <- (decode_resource_logs (Pbrt.Decoder.nested d)) :: v.resource_logs; - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(logs_data), field(1)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Logs_types.resource_logs = v.resource_logs; - } : Logs_types.logs_data) - -let rec decode_log_record_flags d = - match Pbrt.Decoder.int_as_varint d with - | 0 -> (Logs_types.Log_record_flags_do_not_use:Logs_types.log_record_flags) - | 255 -> (Logs_types.Log_record_flags_trace_flags_mask:Logs_types.log_record_flags) - | _ -> Pbrt.Decoder.malformed_variant "log_record_flags" - -let rec encode_severity_number (v:Logs_types.severity_number) encoder = - match v with - | Logs_types.Severity_number_unspecified -> Pbrt.Encoder.int_as_varint (0) encoder - | Logs_types.Severity_number_trace -> Pbrt.Encoder.int_as_varint 1 encoder - | Logs_types.Severity_number_trace2 -> Pbrt.Encoder.int_as_varint 2 encoder - | Logs_types.Severity_number_trace3 -> Pbrt.Encoder.int_as_varint 3 encoder - | Logs_types.Severity_number_trace4 -> Pbrt.Encoder.int_as_varint 4 encoder - | Logs_types.Severity_number_debug -> Pbrt.Encoder.int_as_varint 5 encoder - | Logs_types.Severity_number_debug2 -> Pbrt.Encoder.int_as_varint 6 encoder - | Logs_types.Severity_number_debug3 -> Pbrt.Encoder.int_as_varint 7 encoder - | Logs_types.Severity_number_debug4 -> Pbrt.Encoder.int_as_varint 8 encoder - | Logs_types.Severity_number_info -> Pbrt.Encoder.int_as_varint 9 encoder - | Logs_types.Severity_number_info2 -> Pbrt.Encoder.int_as_varint 10 encoder - | Logs_types.Severity_number_info3 -> Pbrt.Encoder.int_as_varint 11 encoder - | Logs_types.Severity_number_info4 -> Pbrt.Encoder.int_as_varint 12 encoder - | Logs_types.Severity_number_warn -> Pbrt.Encoder.int_as_varint 13 encoder - | Logs_types.Severity_number_warn2 -> Pbrt.Encoder.int_as_varint 14 encoder - | Logs_types.Severity_number_warn3 -> Pbrt.Encoder.int_as_varint 15 encoder - | Logs_types.Severity_number_warn4 -> Pbrt.Encoder.int_as_varint 16 encoder - | Logs_types.Severity_number_error -> Pbrt.Encoder.int_as_varint 17 encoder - | Logs_types.Severity_number_error2 -> Pbrt.Encoder.int_as_varint 18 encoder - | Logs_types.Severity_number_error3 -> Pbrt.Encoder.int_as_varint 19 encoder - | Logs_types.Severity_number_error4 -> Pbrt.Encoder.int_as_varint 20 encoder - | Logs_types.Severity_number_fatal -> Pbrt.Encoder.int_as_varint 21 encoder - | Logs_types.Severity_number_fatal2 -> Pbrt.Encoder.int_as_varint 22 encoder - | Logs_types.Severity_number_fatal3 -> Pbrt.Encoder.int_as_varint 23 encoder - | Logs_types.Severity_number_fatal4 -> Pbrt.Encoder.int_as_varint 24 encoder - -let rec encode_log_record (v:Logs_types.log_record) encoder = - Pbrt.Encoder.key (1, Pbrt.Bits64) encoder; - Pbrt.Encoder.int64_as_bits64 v.Logs_types.time_unix_nano encoder; - Pbrt.Encoder.key (11, Pbrt.Bits64) encoder; - Pbrt.Encoder.int64_as_bits64 v.Logs_types.observed_time_unix_nano encoder; - Pbrt.Encoder.key (2, Pbrt.Varint) encoder; - encode_severity_number v.Logs_types.severity_number encoder; - Pbrt.Encoder.key (3, Pbrt.Bytes) encoder; - Pbrt.Encoder.string v.Logs_types.severity_text encoder; - begin match v.Logs_types.body with - | Some x -> - Pbrt.Encoder.key (5, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (Common_pb.encode_any_value x) encoder; - | None -> (); - end; - List.iter (fun x -> - Pbrt.Encoder.key (6, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (Common_pb.encode_key_value x) encoder; - ) v.Logs_types.attributes; - Pbrt.Encoder.key (7, Pbrt.Varint) encoder; - Pbrt.Encoder.int32_as_varint v.Logs_types.dropped_attributes_count encoder; - Pbrt.Encoder.key (8, Pbrt.Bits32) encoder; - Pbrt.Encoder.int32_as_bits32 v.Logs_types.flags encoder; - Pbrt.Encoder.key (9, Pbrt.Bytes) encoder; - Pbrt.Encoder.bytes v.Logs_types.trace_id encoder; - Pbrt.Encoder.key (10, Pbrt.Bytes) encoder; - Pbrt.Encoder.bytes v.Logs_types.span_id encoder; - () - -let rec encode_scope_logs (v:Logs_types.scope_logs) encoder = - begin match v.Logs_types.scope with - | Some x -> - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (Common_pb.encode_instrumentation_scope x) encoder; - | None -> (); - end; - List.iter (fun x -> - Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_log_record x) encoder; - ) v.Logs_types.log_records; - Pbrt.Encoder.key (3, Pbrt.Bytes) encoder; - Pbrt.Encoder.string v.Logs_types.schema_url encoder; - () - -let rec encode_resource_logs (v:Logs_types.resource_logs) encoder = - begin match v.Logs_types.resource with - | Some x -> - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (Resource_pb.encode_resource x) encoder; - | None -> (); - end; - List.iter (fun x -> - Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_scope_logs x) encoder; - ) v.Logs_types.scope_logs; - Pbrt.Encoder.key (3, Pbrt.Bytes) encoder; - Pbrt.Encoder.string v.Logs_types.schema_url encoder; - () - -let rec encode_logs_data (v:Logs_types.logs_data) encoder = - List.iter (fun x -> - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_resource_logs x) encoder; - ) v.Logs_types.resource_logs; - () - -let rec encode_log_record_flags (v:Logs_types.log_record_flags) encoder = - match v with - | Logs_types.Log_record_flags_do_not_use -> Pbrt.Encoder.int_as_varint (0) encoder - | Logs_types.Log_record_flags_trace_flags_mask -> Pbrt.Encoder.int_as_varint 255 encoder diff --git a/src/logs_pb.mli b/src/logs_pb.mli deleted file mode 100644 index 93e6d369..00000000 --- a/src/logs_pb.mli +++ /dev/null @@ -1,43 +0,0 @@ -(** logs.proto Binary Encoding *) - - -(** {2 Protobuf Encoding} *) - -val encode_severity_number : Logs_types.severity_number -> Pbrt.Encoder.t -> unit -(** [encode_severity_number v encoder] encodes [v] with the given [encoder] *) - -val encode_log_record : Logs_types.log_record -> Pbrt.Encoder.t -> unit -(** [encode_log_record v encoder] encodes [v] with the given [encoder] *) - -val encode_scope_logs : Logs_types.scope_logs -> Pbrt.Encoder.t -> unit -(** [encode_scope_logs v encoder] encodes [v] with the given [encoder] *) - -val encode_resource_logs : Logs_types.resource_logs -> Pbrt.Encoder.t -> unit -(** [encode_resource_logs v encoder] encodes [v] with the given [encoder] *) - -val encode_logs_data : Logs_types.logs_data -> Pbrt.Encoder.t -> unit -(** [encode_logs_data v encoder] encodes [v] with the given [encoder] *) - -val encode_log_record_flags : Logs_types.log_record_flags -> Pbrt.Encoder.t -> unit -(** [encode_log_record_flags v encoder] encodes [v] with the given [encoder] *) - - -(** {2 Protobuf Decoding} *) - -val decode_severity_number : Pbrt.Decoder.t -> Logs_types.severity_number -(** [decode_severity_number decoder] decodes a [severity_number] value from [decoder] *) - -val decode_log_record : Pbrt.Decoder.t -> Logs_types.log_record -(** [decode_log_record decoder] decodes a [log_record] value from [decoder] *) - -val decode_scope_logs : Pbrt.Decoder.t -> Logs_types.scope_logs -(** [decode_scope_logs decoder] decodes a [scope_logs] value from [decoder] *) - -val decode_resource_logs : Pbrt.Decoder.t -> Logs_types.resource_logs -(** [decode_resource_logs decoder] decodes a [resource_logs] value from [decoder] *) - -val decode_logs_data : Pbrt.Decoder.t -> Logs_types.logs_data -(** [decode_logs_data decoder] decodes a [logs_data] value from [decoder] *) - -val decode_log_record_flags : Pbrt.Decoder.t -> Logs_types.log_record_flags -(** [decode_log_record_flags decoder] decodes a [log_record_flags] value from [decoder] *) diff --git a/src/logs_pp.ml b/src/logs_pp.ml deleted file mode 100644 index 408f01d9..00000000 --- a/src/logs_pp.ml +++ /dev/null @@ -1,71 +0,0 @@ -[@@@ocaml.warning "-27-30-39"] - -let rec pp_severity_number fmt (v:Logs_types.severity_number) = - match v with - | Logs_types.Severity_number_unspecified -> Format.fprintf fmt "Severity_number_unspecified" - | Logs_types.Severity_number_trace -> Format.fprintf fmt "Severity_number_trace" - | Logs_types.Severity_number_trace2 -> Format.fprintf fmt "Severity_number_trace2" - | Logs_types.Severity_number_trace3 -> Format.fprintf fmt "Severity_number_trace3" - | Logs_types.Severity_number_trace4 -> Format.fprintf fmt "Severity_number_trace4" - | Logs_types.Severity_number_debug -> Format.fprintf fmt "Severity_number_debug" - | Logs_types.Severity_number_debug2 -> Format.fprintf fmt "Severity_number_debug2" - | Logs_types.Severity_number_debug3 -> Format.fprintf fmt "Severity_number_debug3" - | Logs_types.Severity_number_debug4 -> Format.fprintf fmt "Severity_number_debug4" - | Logs_types.Severity_number_info -> Format.fprintf fmt "Severity_number_info" - | Logs_types.Severity_number_info2 -> Format.fprintf fmt "Severity_number_info2" - | Logs_types.Severity_number_info3 -> Format.fprintf fmt "Severity_number_info3" - | Logs_types.Severity_number_info4 -> Format.fprintf fmt "Severity_number_info4" - | Logs_types.Severity_number_warn -> Format.fprintf fmt "Severity_number_warn" - | Logs_types.Severity_number_warn2 -> Format.fprintf fmt "Severity_number_warn2" - | Logs_types.Severity_number_warn3 -> Format.fprintf fmt "Severity_number_warn3" - | Logs_types.Severity_number_warn4 -> Format.fprintf fmt "Severity_number_warn4" - | Logs_types.Severity_number_error -> Format.fprintf fmt "Severity_number_error" - | Logs_types.Severity_number_error2 -> Format.fprintf fmt "Severity_number_error2" - | Logs_types.Severity_number_error3 -> Format.fprintf fmt "Severity_number_error3" - | Logs_types.Severity_number_error4 -> Format.fprintf fmt "Severity_number_error4" - | Logs_types.Severity_number_fatal -> Format.fprintf fmt "Severity_number_fatal" - | Logs_types.Severity_number_fatal2 -> Format.fprintf fmt "Severity_number_fatal2" - | Logs_types.Severity_number_fatal3 -> Format.fprintf fmt "Severity_number_fatal3" - | Logs_types.Severity_number_fatal4 -> Format.fprintf fmt "Severity_number_fatal4" - -let rec pp_log_record fmt (v:Logs_types.log_record) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Logs_types.time_unix_nano; - Pbrt.Pp.pp_record_field ~first:false "observed_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Logs_types.observed_time_unix_nano; - Pbrt.Pp.pp_record_field ~first:false "severity_number" pp_severity_number fmt v.Logs_types.severity_number; - Pbrt.Pp.pp_record_field ~first:false "severity_text" Pbrt.Pp.pp_string fmt v.Logs_types.severity_text; - Pbrt.Pp.pp_record_field ~first:false "body" (Pbrt.Pp.pp_option Common_pp.pp_any_value) fmt v.Logs_types.body; - Pbrt.Pp.pp_record_field ~first:false "attributes" (Pbrt.Pp.pp_list Common_pp.pp_key_value) fmt v.Logs_types.attributes; - Pbrt.Pp.pp_record_field ~first:false "dropped_attributes_count" Pbrt.Pp.pp_int32 fmt v.Logs_types.dropped_attributes_count; - Pbrt.Pp.pp_record_field ~first:false "flags" Pbrt.Pp.pp_int32 fmt v.Logs_types.flags; - Pbrt.Pp.pp_record_field ~first:false "trace_id" Pbrt.Pp.pp_bytes fmt v.Logs_types.trace_id; - Pbrt.Pp.pp_record_field ~first:false "span_id" Pbrt.Pp.pp_bytes fmt v.Logs_types.span_id; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_scope_logs fmt (v:Logs_types.scope_logs) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "scope" (Pbrt.Pp.pp_option Common_pp.pp_instrumentation_scope) fmt v.Logs_types.scope; - Pbrt.Pp.pp_record_field ~first:false "log_records" (Pbrt.Pp.pp_list pp_log_record) fmt v.Logs_types.log_records; - Pbrt.Pp.pp_record_field ~first:false "schema_url" Pbrt.Pp.pp_string fmt v.Logs_types.schema_url; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_resource_logs fmt (v:Logs_types.resource_logs) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "resource" (Pbrt.Pp.pp_option Resource_pp.pp_resource) fmt v.Logs_types.resource; - Pbrt.Pp.pp_record_field ~first:false "scope_logs" (Pbrt.Pp.pp_list pp_scope_logs) fmt v.Logs_types.scope_logs; - Pbrt.Pp.pp_record_field ~first:false "schema_url" Pbrt.Pp.pp_string fmt v.Logs_types.schema_url; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_logs_data fmt (v:Logs_types.logs_data) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "resource_logs" (Pbrt.Pp.pp_list pp_resource_logs) fmt v.Logs_types.resource_logs; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_log_record_flags fmt (v:Logs_types.log_record_flags) = - match v with - | Logs_types.Log_record_flags_do_not_use -> Format.fprintf fmt "Log_record_flags_do_not_use" - | Logs_types.Log_record_flags_trace_flags_mask -> Format.fprintf fmt "Log_record_flags_trace_flags_mask" diff --git a/src/logs_pp.mli b/src/logs_pp.mli deleted file mode 100644 index fd952524..00000000 --- a/src/logs_pp.mli +++ /dev/null @@ -1,22 +0,0 @@ -(** logs.proto Pretty Printing *) - - -(** {2 Formatters} *) - -val pp_severity_number : Format.formatter -> Logs_types.severity_number -> unit -(** [pp_severity_number v] formats v *) - -val pp_log_record : Format.formatter -> Logs_types.log_record -> unit -(** [pp_log_record v] formats v *) - -val pp_scope_logs : Format.formatter -> Logs_types.scope_logs -> unit -(** [pp_scope_logs v] formats v *) - -val pp_resource_logs : Format.formatter -> Logs_types.resource_logs -> unit -(** [pp_resource_logs v] formats v *) - -val pp_logs_data : Format.formatter -> Logs_types.logs_data -> unit -(** [pp_logs_data v] formats v *) - -val pp_log_record_flags : Format.formatter -> Logs_types.log_record_flags -> unit -(** [pp_log_record_flags v] formats v *) diff --git a/src/logs_service_pb.ml b/src/logs_service_pb.ml deleted file mode 100644 index 64fde20f..00000000 --- a/src/logs_service_pb.ml +++ /dev/null @@ -1,112 +0,0 @@ -[@@@ocaml.warning "-27-30-39"] - -type export_logs_service_request_mutable = { - mutable resource_logs : Logs_types.resource_logs list; -} - -let default_export_logs_service_request_mutable () : export_logs_service_request_mutable = { - resource_logs = []; -} - -type export_logs_partial_success_mutable = { - mutable rejected_log_records : int64; - mutable error_message : string; -} - -let default_export_logs_partial_success_mutable () : export_logs_partial_success_mutable = { - rejected_log_records = 0L; - error_message = ""; -} - -type export_logs_service_response_mutable = { - mutable partial_success : Logs_service_types.export_logs_partial_success option; -} - -let default_export_logs_service_response_mutable () : export_logs_service_response_mutable = { - partial_success = None; -} - - -let rec decode_export_logs_service_request d = - let v = default_export_logs_service_request_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.resource_logs <- List.rev v.resource_logs; - ); continue__ := false - | Some (1, Pbrt.Bytes) -> begin - v.resource_logs <- (Logs_pb.decode_resource_logs (Pbrt.Decoder.nested d)) :: v.resource_logs; - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(export_logs_service_request), field(1)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Logs_service_types.resource_logs = v.resource_logs; - } : Logs_service_types.export_logs_service_request) - -let rec decode_export_logs_partial_success d = - let v = default_export_logs_partial_success_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - ); continue__ := false - | Some (1, Pbrt.Varint) -> begin - v.rejected_log_records <- Pbrt.Decoder.int64_as_varint d; - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(export_logs_partial_success), field(1)" pk - | Some (2, Pbrt.Bytes) -> begin - v.error_message <- Pbrt.Decoder.string d; - end - | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(export_logs_partial_success), field(2)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Logs_service_types.rejected_log_records = v.rejected_log_records; - Logs_service_types.error_message = v.error_message; - } : Logs_service_types.export_logs_partial_success) - -let rec decode_export_logs_service_response d = - let v = default_export_logs_service_response_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - ); continue__ := false - | Some (1, Pbrt.Bytes) -> begin - v.partial_success <- Some (decode_export_logs_partial_success (Pbrt.Decoder.nested d)); - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(export_logs_service_response), field(1)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Logs_service_types.partial_success = v.partial_success; - } : Logs_service_types.export_logs_service_response) - -let rec encode_export_logs_service_request (v:Logs_service_types.export_logs_service_request) encoder = - List.iter (fun x -> - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (Logs_pb.encode_resource_logs x) encoder; - ) v.Logs_service_types.resource_logs; - () - -let rec encode_export_logs_partial_success (v:Logs_service_types.export_logs_partial_success) encoder = - Pbrt.Encoder.key (1, Pbrt.Varint) encoder; - Pbrt.Encoder.int64_as_varint v.Logs_service_types.rejected_log_records encoder; - Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; - Pbrt.Encoder.string v.Logs_service_types.error_message encoder; - () - -let rec encode_export_logs_service_response (v:Logs_service_types.export_logs_service_response) encoder = - begin match v.Logs_service_types.partial_success with - | Some x -> - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_export_logs_partial_success x) encoder; - | None -> (); - end; - () diff --git a/src/logs_service_pb.mli b/src/logs_service_pb.mli deleted file mode 100644 index db4d8c89..00000000 --- a/src/logs_service_pb.mli +++ /dev/null @@ -1,25 +0,0 @@ -(** logs_service.proto Binary Encoding *) - - -(** {2 Protobuf Encoding} *) - -val encode_export_logs_service_request : Logs_service_types.export_logs_service_request -> Pbrt.Encoder.t -> unit -(** [encode_export_logs_service_request v encoder] encodes [v] with the given [encoder] *) - -val encode_export_logs_partial_success : Logs_service_types.export_logs_partial_success -> Pbrt.Encoder.t -> unit -(** [encode_export_logs_partial_success v encoder] encodes [v] with the given [encoder] *) - -val encode_export_logs_service_response : Logs_service_types.export_logs_service_response -> Pbrt.Encoder.t -> unit -(** [encode_export_logs_service_response v encoder] encodes [v] with the given [encoder] *) - - -(** {2 Protobuf Decoding} *) - -val decode_export_logs_service_request : Pbrt.Decoder.t -> Logs_service_types.export_logs_service_request -(** [decode_export_logs_service_request decoder] decodes a [export_logs_service_request] value from [decoder] *) - -val decode_export_logs_partial_success : Pbrt.Decoder.t -> Logs_service_types.export_logs_partial_success -(** [decode_export_logs_partial_success decoder] decodes a [export_logs_partial_success] value from [decoder] *) - -val decode_export_logs_service_response : Pbrt.Decoder.t -> Logs_service_types.export_logs_service_response -(** [decode_export_logs_service_response decoder] decodes a [export_logs_service_response] value from [decoder] *) diff --git a/src/logs_service_pp.ml b/src/logs_service_pp.ml deleted file mode 100644 index 19830e4c..00000000 --- a/src/logs_service_pp.ml +++ /dev/null @@ -1,20 +0,0 @@ -[@@@ocaml.warning "-27-30-39"] - -let rec pp_export_logs_service_request fmt (v:Logs_service_types.export_logs_service_request) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "resource_logs" (Pbrt.Pp.pp_list Logs_pp.pp_resource_logs) fmt v.Logs_service_types.resource_logs; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_export_logs_partial_success fmt (v:Logs_service_types.export_logs_partial_success) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "rejected_log_records" Pbrt.Pp.pp_int64 fmt v.Logs_service_types.rejected_log_records; - Pbrt.Pp.pp_record_field ~first:false "error_message" Pbrt.Pp.pp_string fmt v.Logs_service_types.error_message; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_export_logs_service_response fmt (v:Logs_service_types.export_logs_service_response) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "partial_success" (Pbrt.Pp.pp_option pp_export_logs_partial_success) fmt v.Logs_service_types.partial_success; - in - Pbrt.Pp.pp_brk pp_i fmt () diff --git a/src/logs_service_pp.mli b/src/logs_service_pp.mli deleted file mode 100644 index 6aa6319f..00000000 --- a/src/logs_service_pp.mli +++ /dev/null @@ -1,13 +0,0 @@ -(** logs_service.proto Pretty Printing *) - - -(** {2 Formatters} *) - -val pp_export_logs_service_request : Format.formatter -> Logs_service_types.export_logs_service_request -> unit -(** [pp_export_logs_service_request v] formats v *) - -val pp_export_logs_partial_success : Format.formatter -> Logs_service_types.export_logs_partial_success -> unit -(** [pp_export_logs_partial_success v] formats v *) - -val pp_export_logs_service_response : Format.formatter -> Logs_service_types.export_logs_service_response -> unit -(** [pp_export_logs_service_response v] formats v *) diff --git a/src/logs_service_types.ml b/src/logs_service_types.ml deleted file mode 100644 index 9bf19974..00000000 --- a/src/logs_service_types.ml +++ /dev/null @@ -1,35 +0,0 @@ -[@@@ocaml.warning "-27-30-39"] - - -type export_logs_service_request = { - resource_logs : Logs_types.resource_logs list; -} - -type export_logs_partial_success = { - rejected_log_records : int64; - error_message : string; -} - -type export_logs_service_response = { - partial_success : export_logs_partial_success option; -} - -let rec default_export_logs_service_request - ?resource_logs:((resource_logs:Logs_types.resource_logs list) = []) - () : export_logs_service_request = { - resource_logs; -} - -let rec default_export_logs_partial_success - ?rejected_log_records:((rejected_log_records:int64) = 0L) - ?error_message:((error_message:string) = "") - () : export_logs_partial_success = { - rejected_log_records; - error_message; -} - -let rec default_export_logs_service_response - ?partial_success:((partial_success:export_logs_partial_success option) = None) - () : export_logs_service_response = { - partial_success; -} diff --git a/src/logs_service_types.mli b/src/logs_service_types.mli deleted file mode 100644 index beef4fd3..00000000 --- a/src/logs_service_types.mli +++ /dev/null @@ -1,40 +0,0 @@ -(** logs_service.proto Types *) - - - -(** {2 Types} *) - -type export_logs_service_request = { - resource_logs : Logs_types.resource_logs list; -} - -type export_logs_partial_success = { - rejected_log_records : int64; - error_message : string; -} - -type export_logs_service_response = { - partial_success : export_logs_partial_success option; -} - - -(** {2 Default values} *) - -val default_export_logs_service_request : - ?resource_logs:Logs_types.resource_logs list -> - unit -> - export_logs_service_request -(** [default_export_logs_service_request ()] is the default value for type [export_logs_service_request] *) - -val default_export_logs_partial_success : - ?rejected_log_records:int64 -> - ?error_message:string -> - unit -> - export_logs_partial_success -(** [default_export_logs_partial_success ()] is the default value for type [export_logs_partial_success] *) - -val default_export_logs_service_response : - ?partial_success:export_logs_partial_success option -> - unit -> - export_logs_service_response -(** [default_export_logs_service_response ()] is the default value for type [export_logs_service_response] *) diff --git a/src/logs_types.ml b/src/logs_types.ml deleted file mode 100644 index 4a383ff7..00000000 --- a/src/logs_types.ml +++ /dev/null @@ -1,116 +0,0 @@ -[@@@ocaml.warning "-27-30-39"] - - -type severity_number = - | Severity_number_unspecified - | Severity_number_trace - | Severity_number_trace2 - | Severity_number_trace3 - | Severity_number_trace4 - | Severity_number_debug - | Severity_number_debug2 - | Severity_number_debug3 - | Severity_number_debug4 - | Severity_number_info - | Severity_number_info2 - | Severity_number_info3 - | Severity_number_info4 - | Severity_number_warn - | Severity_number_warn2 - | Severity_number_warn3 - | Severity_number_warn4 - | Severity_number_error - | Severity_number_error2 - | Severity_number_error3 - | Severity_number_error4 - | Severity_number_fatal - | Severity_number_fatal2 - | Severity_number_fatal3 - | Severity_number_fatal4 - -type log_record = { - time_unix_nano : int64; - observed_time_unix_nano : int64; - severity_number : severity_number; - severity_text : string; - body : Common_types.any_value option; - attributes : Common_types.key_value list; - dropped_attributes_count : int32; - flags : int32; - trace_id : bytes; - span_id : bytes; -} - -type scope_logs = { - scope : Common_types.instrumentation_scope option; - log_records : log_record list; - schema_url : string; -} - -type resource_logs = { - resource : Resource_types.resource option; - scope_logs : scope_logs list; - schema_url : string; -} - -type logs_data = { - resource_logs : resource_logs list; -} - -type log_record_flags = - | Log_record_flags_do_not_use - | Log_record_flags_trace_flags_mask - -let rec default_severity_number () = (Severity_number_unspecified:severity_number) - -let rec default_log_record - ?time_unix_nano:((time_unix_nano:int64) = 0L) - ?observed_time_unix_nano:((observed_time_unix_nano:int64) = 0L) - ?severity_number:((severity_number:severity_number) = default_severity_number ()) - ?severity_text:((severity_text:string) = "") - ?body:((body:Common_types.any_value option) = None) - ?attributes:((attributes:Common_types.key_value list) = []) - ?dropped_attributes_count:((dropped_attributes_count:int32) = 0l) - ?flags:((flags:int32) = 0l) - ?trace_id:((trace_id:bytes) = Bytes.create 0) - ?span_id:((span_id:bytes) = Bytes.create 0) - () : log_record = { - time_unix_nano; - observed_time_unix_nano; - severity_number; - severity_text; - body; - attributes; - dropped_attributes_count; - flags; - trace_id; - span_id; -} - -let rec default_scope_logs - ?scope:((scope:Common_types.instrumentation_scope option) = None) - ?log_records:((log_records:log_record list) = []) - ?schema_url:((schema_url:string) = "") - () : scope_logs = { - scope; - log_records; - schema_url; -} - -let rec default_resource_logs - ?resource:((resource:Resource_types.resource option) = None) - ?scope_logs:((scope_logs:scope_logs list) = []) - ?schema_url:((schema_url:string) = "") - () : resource_logs = { - resource; - scope_logs; - schema_url; -} - -let rec default_logs_data - ?resource_logs:((resource_logs:resource_logs list) = []) - () : logs_data = { - resource_logs; -} - -let rec default_log_record_flags () = (Log_record_flags_do_not_use:log_record_flags) diff --git a/src/logs_types.mli b/src/logs_types.mli deleted file mode 100644 index 7a9cc1a3..00000000 --- a/src/logs_types.mli +++ /dev/null @@ -1,111 +0,0 @@ -(** logs.proto Types *) - - - -(** {2 Types} *) - -type severity_number = - | Severity_number_unspecified - | Severity_number_trace - | Severity_number_trace2 - | Severity_number_trace3 - | Severity_number_trace4 - | Severity_number_debug - | Severity_number_debug2 - | Severity_number_debug3 - | Severity_number_debug4 - | Severity_number_info - | Severity_number_info2 - | Severity_number_info3 - | Severity_number_info4 - | Severity_number_warn - | Severity_number_warn2 - | Severity_number_warn3 - | Severity_number_warn4 - | Severity_number_error - | Severity_number_error2 - | Severity_number_error3 - | Severity_number_error4 - | Severity_number_fatal - | Severity_number_fatal2 - | Severity_number_fatal3 - | Severity_number_fatal4 - -type log_record = { - time_unix_nano : int64; - observed_time_unix_nano : int64; - severity_number : severity_number; - severity_text : string; - body : Common_types.any_value option; - attributes : Common_types.key_value list; - dropped_attributes_count : int32; - flags : int32; - trace_id : bytes; - span_id : bytes; -} - -type scope_logs = { - scope : Common_types.instrumentation_scope option; - log_records : log_record list; - schema_url : string; -} - -type resource_logs = { - resource : Resource_types.resource option; - scope_logs : scope_logs list; - schema_url : string; -} - -type logs_data = { - resource_logs : resource_logs list; -} - -type log_record_flags = - | Log_record_flags_do_not_use - | Log_record_flags_trace_flags_mask - - -(** {2 Default values} *) - -val default_severity_number : unit -> severity_number -(** [default_severity_number ()] is the default value for type [severity_number] *) - -val default_log_record : - ?time_unix_nano:int64 -> - ?observed_time_unix_nano:int64 -> - ?severity_number:severity_number -> - ?severity_text:string -> - ?body:Common_types.any_value option -> - ?attributes:Common_types.key_value list -> - ?dropped_attributes_count:int32 -> - ?flags:int32 -> - ?trace_id:bytes -> - ?span_id:bytes -> - unit -> - log_record -(** [default_log_record ()] is the default value for type [log_record] *) - -val default_scope_logs : - ?scope:Common_types.instrumentation_scope option -> - ?log_records:log_record list -> - ?schema_url:string -> - unit -> - scope_logs -(** [default_scope_logs ()] is the default value for type [scope_logs] *) - -val default_resource_logs : - ?resource:Resource_types.resource option -> - ?scope_logs:scope_logs list -> - ?schema_url:string -> - unit -> - resource_logs -(** [default_resource_logs ()] is the default value for type [resource_logs] *) - -val default_logs_data : - ?resource_logs:resource_logs list -> - unit -> - logs_data -(** [default_logs_data ()] is the default value for type [logs_data] *) - -val default_log_record_flags : unit -> log_record_flags -(** [default_log_record_flags ()] is the default value for type [log_record_flags] *) diff --git a/src/metrics_pb.ml b/src/metrics_pb.ml deleted file mode 100644 index d85e1e72..00000000 --- a/src/metrics_pb.ml +++ /dev/null @@ -1,1282 +0,0 @@ -[@@@ocaml.warning "-27-30-39"] - -type exemplar_mutable = { - mutable filtered_attributes : Common_types.key_value list; - mutable time_unix_nano : int64; - mutable value : Metrics_types.exemplar_value; - mutable span_id : bytes; - mutable trace_id : bytes; -} - -let default_exemplar_mutable () : exemplar_mutable = { - filtered_attributes = []; - time_unix_nano = 0L; - value = Metrics_types.As_double (0.); - span_id = Bytes.create 0; - trace_id = Bytes.create 0; -} - -type number_data_point_mutable = { - mutable attributes : Common_types.key_value list; - mutable start_time_unix_nano : int64; - mutable time_unix_nano : int64; - mutable value : Metrics_types.number_data_point_value; - mutable exemplars : Metrics_types.exemplar list; - mutable flags : int32; -} - -let default_number_data_point_mutable () : number_data_point_mutable = { - attributes = []; - start_time_unix_nano = 0L; - time_unix_nano = 0L; - value = Metrics_types.As_double (0.); - exemplars = []; - flags = 0l; -} - -type gauge_mutable = { - mutable data_points : Metrics_types.number_data_point list; -} - -let default_gauge_mutable () : gauge_mutable = { - data_points = []; -} - -type sum_mutable = { - mutable data_points : Metrics_types.number_data_point list; - mutable aggregation_temporality : Metrics_types.aggregation_temporality; - mutable is_monotonic : bool; -} - -let default_sum_mutable () : sum_mutable = { - data_points = []; - aggregation_temporality = Metrics_types.default_aggregation_temporality (); - is_monotonic = false; -} - -type histogram_data_point_mutable = { - mutable attributes : Common_types.key_value list; - mutable start_time_unix_nano : int64; - mutable time_unix_nano : int64; - mutable count : int64; - mutable sum : float option; - mutable bucket_counts : int64 list; - mutable explicit_bounds : float list; - mutable exemplars : Metrics_types.exemplar list; - mutable flags : int32; - mutable min : float option; - mutable max : float option; -} - -let default_histogram_data_point_mutable () : histogram_data_point_mutable = { - attributes = []; - start_time_unix_nano = 0L; - time_unix_nano = 0L; - count = 0L; - sum = None; - bucket_counts = []; - explicit_bounds = []; - exemplars = []; - flags = 0l; - min = None; - max = None; -} - -type histogram_mutable = { - mutable data_points : Metrics_types.histogram_data_point list; - mutable aggregation_temporality : Metrics_types.aggregation_temporality; -} - -let default_histogram_mutable () : histogram_mutable = { - data_points = []; - aggregation_temporality = Metrics_types.default_aggregation_temporality (); -} - -type exponential_histogram_data_point_buckets_mutable = { - mutable offset : int32; - mutable bucket_counts : int64 list; -} - -let default_exponential_histogram_data_point_buckets_mutable () : exponential_histogram_data_point_buckets_mutable = { - offset = 0l; - bucket_counts = []; -} - -type exponential_histogram_data_point_mutable = { - mutable attributes : Common_types.key_value list; - mutable start_time_unix_nano : int64; - mutable time_unix_nano : int64; - mutable count : int64; - mutable sum : float option; - mutable scale : int32; - mutable zero_count : int64; - mutable positive : Metrics_types.exponential_histogram_data_point_buckets option; - mutable negative : Metrics_types.exponential_histogram_data_point_buckets option; - mutable flags : int32; - mutable exemplars : Metrics_types.exemplar list; - mutable min : float option; - mutable max : float option; - mutable zero_threshold : float; -} - -let default_exponential_histogram_data_point_mutable () : exponential_histogram_data_point_mutable = { - attributes = []; - start_time_unix_nano = 0L; - time_unix_nano = 0L; - count = 0L; - sum = None; - scale = 0l; - zero_count = 0L; - positive = None; - negative = None; - flags = 0l; - exemplars = []; - min = None; - max = None; - zero_threshold = 0.; -} - -type exponential_histogram_mutable = { - mutable data_points : Metrics_types.exponential_histogram_data_point list; - mutable aggregation_temporality : Metrics_types.aggregation_temporality; -} - -let default_exponential_histogram_mutable () : exponential_histogram_mutable = { - data_points = []; - aggregation_temporality = Metrics_types.default_aggregation_temporality (); -} - -type summary_data_point_value_at_quantile_mutable = { - mutable quantile : float; - mutable value : float; -} - -let default_summary_data_point_value_at_quantile_mutable () : summary_data_point_value_at_quantile_mutable = { - quantile = 0.; - value = 0.; -} - -type summary_data_point_mutable = { - mutable attributes : Common_types.key_value list; - mutable start_time_unix_nano : int64; - mutable time_unix_nano : int64; - mutable count : int64; - mutable sum : float; - mutable quantile_values : Metrics_types.summary_data_point_value_at_quantile list; - mutable flags : int32; -} - -let default_summary_data_point_mutable () : summary_data_point_mutable = { - attributes = []; - start_time_unix_nano = 0L; - time_unix_nano = 0L; - count = 0L; - sum = 0.; - quantile_values = []; - flags = 0l; -} - -type summary_mutable = { - mutable data_points : Metrics_types.summary_data_point list; -} - -let default_summary_mutable () : summary_mutable = { - data_points = []; -} - -type metric_mutable = { - mutable name : string; - mutable description : string; - mutable unit_ : string; - mutable data : Metrics_types.metric_data; -} - -let default_metric_mutable () : metric_mutable = { - name = ""; - description = ""; - unit_ = ""; - data = Metrics_types.Gauge (Metrics_types.default_gauge ()); -} - -type scope_metrics_mutable = { - mutable scope : Common_types.instrumentation_scope option; - mutable metrics : Metrics_types.metric list; - mutable schema_url : string; -} - -let default_scope_metrics_mutable () : scope_metrics_mutable = { - scope = None; - metrics = []; - schema_url = ""; -} - -type resource_metrics_mutable = { - mutable resource : Resource_types.resource option; - mutable scope_metrics : Metrics_types.scope_metrics list; - mutable schema_url : string; -} - -let default_resource_metrics_mutable () : resource_metrics_mutable = { - resource = None; - scope_metrics = []; - schema_url = ""; -} - -type metrics_data_mutable = { - mutable resource_metrics : Metrics_types.resource_metrics list; -} - -let default_metrics_data_mutable () : metrics_data_mutable = { - resource_metrics = []; -} - - -let rec decode_exemplar_value d = - let rec loop () = - let ret:Metrics_types.exemplar_value = match Pbrt.Decoder.key d with - | None -> Pbrt.Decoder.malformed_variant "exemplar_value" - | Some (3, _) -> (Metrics_types.As_double (Pbrt.Decoder.float_as_bits64 d) : Metrics_types.exemplar_value) - | Some (6, _) -> (Metrics_types.As_int (Pbrt.Decoder.int64_as_bits64 d) : Metrics_types.exemplar_value) - | Some (n, payload_kind) -> ( - Pbrt.Decoder.skip d payload_kind; - loop () - ) - in - ret - in - loop () - -and decode_exemplar d = - let v = default_exemplar_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.filtered_attributes <- List.rev v.filtered_attributes; - ); continue__ := false - | Some (7, Pbrt.Bytes) -> begin - v.filtered_attributes <- (Common_pb.decode_key_value (Pbrt.Decoder.nested d)) :: v.filtered_attributes; - end - | Some (7, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exemplar), field(7)" pk - | Some (2, Pbrt.Bits64) -> begin - v.time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; - end - | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exemplar), field(2)" pk - | Some (3, Pbrt.Bits64) -> begin - v.value <- Metrics_types.As_double (Pbrt.Decoder.float_as_bits64 d); - end - | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exemplar), field(3)" pk - | Some (6, Pbrt.Bits64) -> begin - v.value <- Metrics_types.As_int (Pbrt.Decoder.int64_as_bits64 d); - end - | Some (6, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exemplar), field(6)" pk - | Some (4, Pbrt.Bytes) -> begin - v.span_id <- Pbrt.Decoder.bytes d; - end - | Some (4, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exemplar), field(4)" pk - | Some (5, Pbrt.Bytes) -> begin - v.trace_id <- Pbrt.Decoder.bytes d; - end - | Some (5, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exemplar), field(5)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Metrics_types.filtered_attributes = v.filtered_attributes; - Metrics_types.time_unix_nano = v.time_unix_nano; - Metrics_types.value = v.value; - Metrics_types.span_id = v.span_id; - Metrics_types.trace_id = v.trace_id; - } : Metrics_types.exemplar) - -let rec decode_number_data_point_value d = - let rec loop () = - let ret:Metrics_types.number_data_point_value = match Pbrt.Decoder.key d with - | None -> Pbrt.Decoder.malformed_variant "number_data_point_value" - | Some (4, _) -> (Metrics_types.As_double (Pbrt.Decoder.float_as_bits64 d) : Metrics_types.number_data_point_value) - | Some (6, _) -> (Metrics_types.As_int (Pbrt.Decoder.int64_as_bits64 d) : Metrics_types.number_data_point_value) - | Some (n, payload_kind) -> ( - Pbrt.Decoder.skip d payload_kind; - loop () - ) - in - ret - in - loop () - -and decode_number_data_point d = - let v = default_number_data_point_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.exemplars <- List.rev v.exemplars; - v.attributes <- List.rev v.attributes; - ); continue__ := false - | Some (7, Pbrt.Bytes) -> begin - v.attributes <- (Common_pb.decode_key_value (Pbrt.Decoder.nested d)) :: v.attributes; - end - | Some (7, pk) -> - Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(7)" pk - | Some (2, Pbrt.Bits64) -> begin - v.start_time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; - end - | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(2)" pk - | Some (3, Pbrt.Bits64) -> begin - v.time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; - end - | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(3)" pk - | Some (4, Pbrt.Bits64) -> begin - v.value <- Metrics_types.As_double (Pbrt.Decoder.float_as_bits64 d); - end - | Some (4, pk) -> - Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(4)" pk - | Some (6, Pbrt.Bits64) -> begin - v.value <- Metrics_types.As_int (Pbrt.Decoder.int64_as_bits64 d); - end - | Some (6, pk) -> - Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(6)" pk - | Some (5, Pbrt.Bytes) -> begin - v.exemplars <- (decode_exemplar (Pbrt.Decoder.nested d)) :: v.exemplars; - end - | Some (5, pk) -> - Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(5)" pk - | Some (8, Pbrt.Varint) -> begin - v.flags <- Pbrt.Decoder.int32_as_varint d; - end - | Some (8, pk) -> - Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(8)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Metrics_types.attributes = v.attributes; - Metrics_types.start_time_unix_nano = v.start_time_unix_nano; - Metrics_types.time_unix_nano = v.time_unix_nano; - Metrics_types.value = v.value; - Metrics_types.exemplars = v.exemplars; - Metrics_types.flags = v.flags; - } : Metrics_types.number_data_point) - -let rec decode_gauge d = - let v = default_gauge_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.data_points <- List.rev v.data_points; - ); continue__ := false - | Some (1, Pbrt.Bytes) -> begin - v.data_points <- (decode_number_data_point (Pbrt.Decoder.nested d)) :: v.data_points; - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(gauge), field(1)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Metrics_types.data_points = v.data_points; - } : Metrics_types.gauge) - -let rec decode_aggregation_temporality d = - match Pbrt.Decoder.int_as_varint d with - | 0 -> (Metrics_types.Aggregation_temporality_unspecified:Metrics_types.aggregation_temporality) - | 1 -> (Metrics_types.Aggregation_temporality_delta:Metrics_types.aggregation_temporality) - | 2 -> (Metrics_types.Aggregation_temporality_cumulative:Metrics_types.aggregation_temporality) - | _ -> Pbrt.Decoder.malformed_variant "aggregation_temporality" - -let rec decode_sum d = - let v = default_sum_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.data_points <- List.rev v.data_points; - ); continue__ := false - | Some (1, Pbrt.Bytes) -> begin - v.data_points <- (decode_number_data_point (Pbrt.Decoder.nested d)) :: v.data_points; - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(sum), field(1)" pk - | Some (2, Pbrt.Varint) -> begin - v.aggregation_temporality <- decode_aggregation_temporality d; - end - | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(sum), field(2)" pk - | Some (3, Pbrt.Varint) -> begin - v.is_monotonic <- Pbrt.Decoder.bool d; - end - | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(sum), field(3)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Metrics_types.data_points = v.data_points; - Metrics_types.aggregation_temporality = v.aggregation_temporality; - Metrics_types.is_monotonic = v.is_monotonic; - } : Metrics_types.sum) - -let rec decode_histogram_data_point d = - let v = default_histogram_data_point_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.exemplars <- List.rev v.exemplars; - v.explicit_bounds <- List.rev v.explicit_bounds; - v.bucket_counts <- List.rev v.bucket_counts; - v.attributes <- List.rev v.attributes; - ); continue__ := false - | Some (9, Pbrt.Bytes) -> begin - v.attributes <- (Common_pb.decode_key_value (Pbrt.Decoder.nested d)) :: v.attributes; - end - | Some (9, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(9)" pk - | Some (2, Pbrt.Bits64) -> begin - v.start_time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; - end - | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(2)" pk - | Some (3, Pbrt.Bits64) -> begin - v.time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; - end - | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(3)" pk - | Some (4, Pbrt.Bits64) -> begin - v.count <- Pbrt.Decoder.int64_as_bits64 d; - end - | Some (4, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(4)" pk - | Some (5, Pbrt.Bits64) -> begin - v.sum <- Some (Pbrt.Decoder.float_as_bits64 d); - end - | Some (5, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(5)" pk - | Some (6, Pbrt.Bytes) -> begin - v.bucket_counts <- Pbrt.Decoder.packed_fold (fun l d -> (Pbrt.Decoder.int64_as_bits64 d)::l) [] d; - end - | Some (6, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(6)" pk - | Some (7, Pbrt.Bytes) -> begin - v.explicit_bounds <- Pbrt.Decoder.packed_fold (fun l d -> (Pbrt.Decoder.float_as_bits64 d)::l) [] d; - end - | Some (7, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(7)" pk - | Some (8, Pbrt.Bytes) -> begin - v.exemplars <- (decode_exemplar (Pbrt.Decoder.nested d)) :: v.exemplars; - end - | Some (8, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(8)" pk - | Some (10, Pbrt.Varint) -> begin - v.flags <- Pbrt.Decoder.int32_as_varint d; - end - | Some (10, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(10)" pk - | Some (11, Pbrt.Bits64) -> begin - v.min <- Some (Pbrt.Decoder.float_as_bits64 d); - end - | Some (11, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(11)" pk - | Some (12, Pbrt.Bits64) -> begin - v.max <- Some (Pbrt.Decoder.float_as_bits64 d); - end - | Some (12, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(12)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Metrics_types.attributes = v.attributes; - Metrics_types.start_time_unix_nano = v.start_time_unix_nano; - Metrics_types.time_unix_nano = v.time_unix_nano; - Metrics_types.count = v.count; - Metrics_types.sum = v.sum; - Metrics_types.bucket_counts = v.bucket_counts; - Metrics_types.explicit_bounds = v.explicit_bounds; - Metrics_types.exemplars = v.exemplars; - Metrics_types.flags = v.flags; - Metrics_types.min = v.min; - Metrics_types.max = v.max; - } : Metrics_types.histogram_data_point) - -let rec decode_histogram d = - let v = default_histogram_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.data_points <- List.rev v.data_points; - ); continue__ := false - | Some (1, Pbrt.Bytes) -> begin - v.data_points <- (decode_histogram_data_point (Pbrt.Decoder.nested d)) :: v.data_points; - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram), field(1)" pk - | Some (2, Pbrt.Varint) -> begin - v.aggregation_temporality <- decode_aggregation_temporality d; - end - | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram), field(2)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Metrics_types.data_points = v.data_points; - Metrics_types.aggregation_temporality = v.aggregation_temporality; - } : Metrics_types.histogram) - -let rec decode_exponential_histogram_data_point_buckets d = - let v = default_exponential_histogram_data_point_buckets_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.bucket_counts <- List.rev v.bucket_counts; - ); continue__ := false - | Some (1, Pbrt.Varint) -> begin - v.offset <- Pbrt.Decoder.int32_as_zigzag d; - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point_buckets), field(1)" pk - | Some (2, Pbrt.Bytes) -> begin - v.bucket_counts <- Pbrt.Decoder.packed_fold (fun l d -> (Pbrt.Decoder.int64_as_varint d)::l) [] d; - end - | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point_buckets), field(2)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Metrics_types.offset = v.offset; - Metrics_types.bucket_counts = v.bucket_counts; - } : Metrics_types.exponential_histogram_data_point_buckets) - -let rec decode_exponential_histogram_data_point d = - let v = default_exponential_histogram_data_point_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.exemplars <- List.rev v.exemplars; - v.attributes <- List.rev v.attributes; - ); continue__ := false - | Some (1, Pbrt.Bytes) -> begin - v.attributes <- (Common_pb.decode_key_value (Pbrt.Decoder.nested d)) :: v.attributes; - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(1)" pk - | Some (2, Pbrt.Bits64) -> begin - v.start_time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; - end - | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(2)" pk - | Some (3, Pbrt.Bits64) -> begin - v.time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; - end - | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(3)" pk - | Some (4, Pbrt.Bits64) -> begin - v.count <- Pbrt.Decoder.int64_as_bits64 d; - end - | Some (4, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(4)" pk - | Some (5, Pbrt.Bits64) -> begin - v.sum <- Some (Pbrt.Decoder.float_as_bits64 d); - end - | Some (5, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(5)" pk - | Some (6, Pbrt.Varint) -> begin - v.scale <- Pbrt.Decoder.int32_as_zigzag d; - end - | Some (6, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(6)" pk - | Some (7, Pbrt.Bits64) -> begin - v.zero_count <- Pbrt.Decoder.int64_as_bits64 d; - end - | Some (7, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(7)" pk - | Some (8, Pbrt.Bytes) -> begin - v.positive <- Some (decode_exponential_histogram_data_point_buckets (Pbrt.Decoder.nested d)); - end - | Some (8, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(8)" pk - | Some (9, Pbrt.Bytes) -> begin - v.negative <- Some (decode_exponential_histogram_data_point_buckets (Pbrt.Decoder.nested d)); - end - | Some (9, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(9)" pk - | Some (10, Pbrt.Varint) -> begin - v.flags <- Pbrt.Decoder.int32_as_varint d; - end - | Some (10, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(10)" pk - | Some (11, Pbrt.Bytes) -> begin - v.exemplars <- (decode_exemplar (Pbrt.Decoder.nested d)) :: v.exemplars; - end - | Some (11, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(11)" pk - | Some (12, Pbrt.Bits64) -> begin - v.min <- Some (Pbrt.Decoder.float_as_bits64 d); - end - | Some (12, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(12)" pk - | Some (13, Pbrt.Bits64) -> begin - v.max <- Some (Pbrt.Decoder.float_as_bits64 d); - end - | Some (13, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(13)" pk - | Some (14, Pbrt.Bits64) -> begin - v.zero_threshold <- Pbrt.Decoder.float_as_bits64 d; - end - | Some (14, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(14)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Metrics_types.attributes = v.attributes; - Metrics_types.start_time_unix_nano = v.start_time_unix_nano; - Metrics_types.time_unix_nano = v.time_unix_nano; - Metrics_types.count = v.count; - Metrics_types.sum = v.sum; - Metrics_types.scale = v.scale; - Metrics_types.zero_count = v.zero_count; - Metrics_types.positive = v.positive; - Metrics_types.negative = v.negative; - Metrics_types.flags = v.flags; - Metrics_types.exemplars = v.exemplars; - Metrics_types.min = v.min; - Metrics_types.max = v.max; - Metrics_types.zero_threshold = v.zero_threshold; - } : Metrics_types.exponential_histogram_data_point) - -let rec decode_exponential_histogram d = - let v = default_exponential_histogram_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.data_points <- List.rev v.data_points; - ); continue__ := false - | Some (1, Pbrt.Bytes) -> begin - v.data_points <- (decode_exponential_histogram_data_point (Pbrt.Decoder.nested d)) :: v.data_points; - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exponential_histogram), field(1)" pk - | Some (2, Pbrt.Varint) -> begin - v.aggregation_temporality <- decode_aggregation_temporality d; - end - | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exponential_histogram), field(2)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Metrics_types.data_points = v.data_points; - Metrics_types.aggregation_temporality = v.aggregation_temporality; - } : Metrics_types.exponential_histogram) - -let rec decode_summary_data_point_value_at_quantile d = - let v = default_summary_data_point_value_at_quantile_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - ); continue__ := false - | Some (1, Pbrt.Bits64) -> begin - v.quantile <- Pbrt.Decoder.float_as_bits64 d; - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(summary_data_point_value_at_quantile), field(1)" pk - | Some (2, Pbrt.Bits64) -> begin - v.value <- Pbrt.Decoder.float_as_bits64 d; - end - | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(summary_data_point_value_at_quantile), field(2)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Metrics_types.quantile = v.quantile; - Metrics_types.value = v.value; - } : Metrics_types.summary_data_point_value_at_quantile) - -let rec decode_summary_data_point d = - let v = default_summary_data_point_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.quantile_values <- List.rev v.quantile_values; - v.attributes <- List.rev v.attributes; - ); continue__ := false - | Some (7, Pbrt.Bytes) -> begin - v.attributes <- (Common_pb.decode_key_value (Pbrt.Decoder.nested d)) :: v.attributes; - end - | Some (7, pk) -> - Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(7)" pk - | Some (2, Pbrt.Bits64) -> begin - v.start_time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; - end - | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(2)" pk - | Some (3, Pbrt.Bits64) -> begin - v.time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; - end - | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(3)" pk - | Some (4, Pbrt.Bits64) -> begin - v.count <- Pbrt.Decoder.int64_as_bits64 d; - end - | Some (4, pk) -> - Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(4)" pk - | Some (5, Pbrt.Bits64) -> begin - v.sum <- Pbrt.Decoder.float_as_bits64 d; - end - | Some (5, pk) -> - Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(5)" pk - | Some (6, Pbrt.Bytes) -> begin - v.quantile_values <- (decode_summary_data_point_value_at_quantile (Pbrt.Decoder.nested d)) :: v.quantile_values; - end - | Some (6, pk) -> - Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(6)" pk - | Some (8, Pbrt.Varint) -> begin - v.flags <- Pbrt.Decoder.int32_as_varint d; - end - | Some (8, pk) -> - Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(8)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Metrics_types.attributes = v.attributes; - Metrics_types.start_time_unix_nano = v.start_time_unix_nano; - Metrics_types.time_unix_nano = v.time_unix_nano; - Metrics_types.count = v.count; - Metrics_types.sum = v.sum; - Metrics_types.quantile_values = v.quantile_values; - Metrics_types.flags = v.flags; - } : Metrics_types.summary_data_point) - -let rec decode_summary d = - let v = default_summary_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.data_points <- List.rev v.data_points; - ); continue__ := false - | Some (1, Pbrt.Bytes) -> begin - v.data_points <- (decode_summary_data_point (Pbrt.Decoder.nested d)) :: v.data_points; - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(summary), field(1)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Metrics_types.data_points = v.data_points; - } : Metrics_types.summary) - -let rec decode_metric_data d = - let rec loop () = - let ret:Metrics_types.metric_data = match Pbrt.Decoder.key d with - | None -> Pbrt.Decoder.malformed_variant "metric_data" - | Some (5, _) -> (Metrics_types.Gauge (decode_gauge (Pbrt.Decoder.nested d)) : Metrics_types.metric_data) - | Some (7, _) -> (Metrics_types.Sum (decode_sum (Pbrt.Decoder.nested d)) : Metrics_types.metric_data) - | Some (9, _) -> (Metrics_types.Histogram (decode_histogram (Pbrt.Decoder.nested d)) : Metrics_types.metric_data) - | Some (10, _) -> (Metrics_types.Exponential_histogram (decode_exponential_histogram (Pbrt.Decoder.nested d)) : Metrics_types.metric_data) - | Some (11, _) -> (Metrics_types.Summary (decode_summary (Pbrt.Decoder.nested d)) : Metrics_types.metric_data) - | Some (n, payload_kind) -> ( - Pbrt.Decoder.skip d payload_kind; - loop () - ) - in - ret - in - loop () - -and decode_metric d = - let v = default_metric_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - ); continue__ := false - | Some (1, Pbrt.Bytes) -> begin - v.name <- Pbrt.Decoder.string d; - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(metric), field(1)" pk - | Some (2, Pbrt.Bytes) -> begin - v.description <- Pbrt.Decoder.string d; - end - | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(metric), field(2)" pk - | Some (3, Pbrt.Bytes) -> begin - v.unit_ <- Pbrt.Decoder.string d; - end - | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(metric), field(3)" pk - | Some (5, Pbrt.Bytes) -> begin - v.data <- Metrics_types.Gauge (decode_gauge (Pbrt.Decoder.nested d)); - end - | Some (5, pk) -> - Pbrt.Decoder.unexpected_payload "Message(metric), field(5)" pk - | Some (7, Pbrt.Bytes) -> begin - v.data <- Metrics_types.Sum (decode_sum (Pbrt.Decoder.nested d)); - end - | Some (7, pk) -> - Pbrt.Decoder.unexpected_payload "Message(metric), field(7)" pk - | Some (9, Pbrt.Bytes) -> begin - v.data <- Metrics_types.Histogram (decode_histogram (Pbrt.Decoder.nested d)); - end - | Some (9, pk) -> - Pbrt.Decoder.unexpected_payload "Message(metric), field(9)" pk - | Some (10, Pbrt.Bytes) -> begin - v.data <- Metrics_types.Exponential_histogram (decode_exponential_histogram (Pbrt.Decoder.nested d)); - end - | Some (10, pk) -> - Pbrt.Decoder.unexpected_payload "Message(metric), field(10)" pk - | Some (11, Pbrt.Bytes) -> begin - v.data <- Metrics_types.Summary (decode_summary (Pbrt.Decoder.nested d)); - end - | Some (11, pk) -> - Pbrt.Decoder.unexpected_payload "Message(metric), field(11)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Metrics_types.name = v.name; - Metrics_types.description = v.description; - Metrics_types.unit_ = v.unit_; - Metrics_types.data = v.data; - } : Metrics_types.metric) - -let rec decode_scope_metrics d = - let v = default_scope_metrics_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.metrics <- List.rev v.metrics; - ); continue__ := false - | Some (1, Pbrt.Bytes) -> begin - v.scope <- Some (Common_pb.decode_instrumentation_scope (Pbrt.Decoder.nested d)); - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(scope_metrics), field(1)" pk - | Some (2, Pbrt.Bytes) -> begin - v.metrics <- (decode_metric (Pbrt.Decoder.nested d)) :: v.metrics; - end - | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(scope_metrics), field(2)" pk - | Some (3, Pbrt.Bytes) -> begin - v.schema_url <- Pbrt.Decoder.string d; - end - | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(scope_metrics), field(3)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Metrics_types.scope = v.scope; - Metrics_types.metrics = v.metrics; - Metrics_types.schema_url = v.schema_url; - } : Metrics_types.scope_metrics) - -let rec decode_resource_metrics d = - let v = default_resource_metrics_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.scope_metrics <- List.rev v.scope_metrics; - ); continue__ := false - | Some (1, Pbrt.Bytes) -> begin - v.resource <- Some (Resource_pb.decode_resource (Pbrt.Decoder.nested d)); - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(resource_metrics), field(1)" pk - | Some (2, Pbrt.Bytes) -> begin - v.scope_metrics <- (decode_scope_metrics (Pbrt.Decoder.nested d)) :: v.scope_metrics; - end - | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(resource_metrics), field(2)" pk - | Some (3, Pbrt.Bytes) -> begin - v.schema_url <- Pbrt.Decoder.string d; - end - | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(resource_metrics), field(3)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Metrics_types.resource = v.resource; - Metrics_types.scope_metrics = v.scope_metrics; - Metrics_types.schema_url = v.schema_url; - } : Metrics_types.resource_metrics) - -let rec decode_metrics_data d = - let v = default_metrics_data_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.resource_metrics <- List.rev v.resource_metrics; - ); continue__ := false - | Some (1, Pbrt.Bytes) -> begin - v.resource_metrics <- (decode_resource_metrics (Pbrt.Decoder.nested d)) :: v.resource_metrics; - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(metrics_data), field(1)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Metrics_types.resource_metrics = v.resource_metrics; - } : Metrics_types.metrics_data) - -let rec decode_data_point_flags d = - match Pbrt.Decoder.int_as_varint d with - | 0 -> (Metrics_types.Data_point_flags_do_not_use:Metrics_types.data_point_flags) - | 1 -> (Metrics_types.Data_point_flags_no_recorded_value_mask:Metrics_types.data_point_flags) - | _ -> Pbrt.Decoder.malformed_variant "data_point_flags" - -let rec encode_exemplar_value (v:Metrics_types.exemplar_value) encoder = - begin match v with - | Metrics_types.As_double x -> - Pbrt.Encoder.key (3, Pbrt.Bits64) encoder; - Pbrt.Encoder.float_as_bits64 x encoder; - | Metrics_types.As_int x -> - Pbrt.Encoder.key (6, Pbrt.Bits64) encoder; - Pbrt.Encoder.int64_as_bits64 x encoder; - end - -and encode_exemplar (v:Metrics_types.exemplar) encoder = - List.iter (fun x -> - Pbrt.Encoder.key (7, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (Common_pb.encode_key_value x) encoder; - ) v.Metrics_types.filtered_attributes; - Pbrt.Encoder.key (2, Pbrt.Bits64) encoder; - Pbrt.Encoder.int64_as_bits64 v.Metrics_types.time_unix_nano encoder; - begin match v.Metrics_types.value with - | Metrics_types.As_double x -> - Pbrt.Encoder.key (3, Pbrt.Bits64) encoder; - Pbrt.Encoder.float_as_bits64 x encoder; - | Metrics_types.As_int x -> - Pbrt.Encoder.key (6, Pbrt.Bits64) encoder; - Pbrt.Encoder.int64_as_bits64 x encoder; - end; - Pbrt.Encoder.key (4, Pbrt.Bytes) encoder; - Pbrt.Encoder.bytes v.Metrics_types.span_id encoder; - Pbrt.Encoder.key (5, Pbrt.Bytes) encoder; - Pbrt.Encoder.bytes v.Metrics_types.trace_id encoder; - () - -let rec encode_number_data_point_value (v:Metrics_types.number_data_point_value) encoder = - begin match v with - | Metrics_types.As_double x -> - Pbrt.Encoder.key (4, Pbrt.Bits64) encoder; - Pbrt.Encoder.float_as_bits64 x encoder; - | Metrics_types.As_int x -> - Pbrt.Encoder.key (6, Pbrt.Bits64) encoder; - Pbrt.Encoder.int64_as_bits64 x encoder; - end - -and encode_number_data_point (v:Metrics_types.number_data_point) encoder = - List.iter (fun x -> - Pbrt.Encoder.key (7, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (Common_pb.encode_key_value x) encoder; - ) v.Metrics_types.attributes; - Pbrt.Encoder.key (2, Pbrt.Bits64) encoder; - Pbrt.Encoder.int64_as_bits64 v.Metrics_types.start_time_unix_nano encoder; - Pbrt.Encoder.key (3, Pbrt.Bits64) encoder; - Pbrt.Encoder.int64_as_bits64 v.Metrics_types.time_unix_nano encoder; - begin match v.Metrics_types.value with - | Metrics_types.As_double x -> - Pbrt.Encoder.key (4, Pbrt.Bits64) encoder; - Pbrt.Encoder.float_as_bits64 x encoder; - | Metrics_types.As_int x -> - Pbrt.Encoder.key (6, Pbrt.Bits64) encoder; - Pbrt.Encoder.int64_as_bits64 x encoder; - end; - List.iter (fun x -> - Pbrt.Encoder.key (5, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_exemplar x) encoder; - ) v.Metrics_types.exemplars; - Pbrt.Encoder.key (8, Pbrt.Varint) encoder; - Pbrt.Encoder.int32_as_varint v.Metrics_types.flags encoder; - () - -let rec encode_gauge (v:Metrics_types.gauge) encoder = - List.iter (fun x -> - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_number_data_point x) encoder; - ) v.Metrics_types.data_points; - () - -let rec encode_aggregation_temporality (v:Metrics_types.aggregation_temporality) encoder = - match v with - | Metrics_types.Aggregation_temporality_unspecified -> Pbrt.Encoder.int_as_varint (0) encoder - | Metrics_types.Aggregation_temporality_delta -> Pbrt.Encoder.int_as_varint 1 encoder - | Metrics_types.Aggregation_temporality_cumulative -> Pbrt.Encoder.int_as_varint 2 encoder - -let rec encode_sum (v:Metrics_types.sum) encoder = - List.iter (fun x -> - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_number_data_point x) encoder; - ) v.Metrics_types.data_points; - Pbrt.Encoder.key (2, Pbrt.Varint) encoder; - encode_aggregation_temporality v.Metrics_types.aggregation_temporality encoder; - Pbrt.Encoder.key (3, Pbrt.Varint) encoder; - Pbrt.Encoder.bool v.Metrics_types.is_monotonic encoder; - () - -let rec encode_histogram_data_point (v:Metrics_types.histogram_data_point) encoder = - List.iter (fun x -> - Pbrt.Encoder.key (9, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (Common_pb.encode_key_value x) encoder; - ) v.Metrics_types.attributes; - Pbrt.Encoder.key (2, Pbrt.Bits64) encoder; - Pbrt.Encoder.int64_as_bits64 v.Metrics_types.start_time_unix_nano encoder; - Pbrt.Encoder.key (3, Pbrt.Bits64) encoder; - Pbrt.Encoder.int64_as_bits64 v.Metrics_types.time_unix_nano encoder; - Pbrt.Encoder.key (4, Pbrt.Bits64) encoder; - Pbrt.Encoder.int64_as_bits64 v.Metrics_types.count encoder; - begin match v.Metrics_types.sum with - | Some x -> - Pbrt.Encoder.key (5, Pbrt.Bits64) encoder; - Pbrt.Encoder.float_as_bits64 x encoder; - | None -> (); - end; - Pbrt.Encoder.key (6, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (fun encoder -> - List.iter (fun x -> - Pbrt.Encoder.int64_as_bits64 x encoder; - ) v.Metrics_types.bucket_counts; - ) encoder; - Pbrt.Encoder.key (7, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (fun encoder -> - List.iter (fun x -> - Pbrt.Encoder.float_as_bits64 x encoder; - ) v.Metrics_types.explicit_bounds; - ) encoder; - List.iter (fun x -> - Pbrt.Encoder.key (8, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_exemplar x) encoder; - ) v.Metrics_types.exemplars; - Pbrt.Encoder.key (10, Pbrt.Varint) encoder; - Pbrt.Encoder.int32_as_varint v.Metrics_types.flags encoder; - begin match v.Metrics_types.min with - | Some x -> - Pbrt.Encoder.key (11, Pbrt.Bits64) encoder; - Pbrt.Encoder.float_as_bits64 x encoder; - | None -> (); - end; - begin match v.Metrics_types.max with - | Some x -> - Pbrt.Encoder.key (12, Pbrt.Bits64) encoder; - Pbrt.Encoder.float_as_bits64 x encoder; - | None -> (); - end; - () - -let rec encode_histogram (v:Metrics_types.histogram) encoder = - List.iter (fun x -> - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_histogram_data_point x) encoder; - ) v.Metrics_types.data_points; - Pbrt.Encoder.key (2, Pbrt.Varint) encoder; - encode_aggregation_temporality v.Metrics_types.aggregation_temporality encoder; - () - -let rec encode_exponential_histogram_data_point_buckets (v:Metrics_types.exponential_histogram_data_point_buckets) encoder = - Pbrt.Encoder.key (1, Pbrt.Varint) encoder; - Pbrt.Encoder.int32_as_zigzag v.Metrics_types.offset encoder; - Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (fun encoder -> - List.iter (fun x -> - Pbrt.Encoder.int64_as_varint x encoder; - ) v.Metrics_types.bucket_counts; - ) encoder; - () - -let rec encode_exponential_histogram_data_point (v:Metrics_types.exponential_histogram_data_point) encoder = - List.iter (fun x -> - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (Common_pb.encode_key_value x) encoder; - ) v.Metrics_types.attributes; - Pbrt.Encoder.key (2, Pbrt.Bits64) encoder; - Pbrt.Encoder.int64_as_bits64 v.Metrics_types.start_time_unix_nano encoder; - Pbrt.Encoder.key (3, Pbrt.Bits64) encoder; - Pbrt.Encoder.int64_as_bits64 v.Metrics_types.time_unix_nano encoder; - Pbrt.Encoder.key (4, Pbrt.Bits64) encoder; - Pbrt.Encoder.int64_as_bits64 v.Metrics_types.count encoder; - begin match v.Metrics_types.sum with - | Some x -> - Pbrt.Encoder.key (5, Pbrt.Bits64) encoder; - Pbrt.Encoder.float_as_bits64 x encoder; - | None -> (); - end; - Pbrt.Encoder.key (6, Pbrt.Varint) encoder; - Pbrt.Encoder.int32_as_zigzag v.Metrics_types.scale encoder; - Pbrt.Encoder.key (7, Pbrt.Bits64) encoder; - Pbrt.Encoder.int64_as_bits64 v.Metrics_types.zero_count encoder; - begin match v.Metrics_types.positive with - | Some x -> - Pbrt.Encoder.key (8, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_exponential_histogram_data_point_buckets x) encoder; - | None -> (); - end; - begin match v.Metrics_types.negative with - | Some x -> - Pbrt.Encoder.key (9, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_exponential_histogram_data_point_buckets x) encoder; - | None -> (); - end; - Pbrt.Encoder.key (10, Pbrt.Varint) encoder; - Pbrt.Encoder.int32_as_varint v.Metrics_types.flags encoder; - List.iter (fun x -> - Pbrt.Encoder.key (11, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_exemplar x) encoder; - ) v.Metrics_types.exemplars; - begin match v.Metrics_types.min with - | Some x -> - Pbrt.Encoder.key (12, Pbrt.Bits64) encoder; - Pbrt.Encoder.float_as_bits64 x encoder; - | None -> (); - end; - begin match v.Metrics_types.max with - | Some x -> - Pbrt.Encoder.key (13, Pbrt.Bits64) encoder; - Pbrt.Encoder.float_as_bits64 x encoder; - | None -> (); - end; - Pbrt.Encoder.key (14, Pbrt.Bits64) encoder; - Pbrt.Encoder.float_as_bits64 v.Metrics_types.zero_threshold encoder; - () - -let rec encode_exponential_histogram (v:Metrics_types.exponential_histogram) encoder = - List.iter (fun x -> - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_exponential_histogram_data_point x) encoder; - ) v.Metrics_types.data_points; - Pbrt.Encoder.key (2, Pbrt.Varint) encoder; - encode_aggregation_temporality v.Metrics_types.aggregation_temporality encoder; - () - -let rec encode_summary_data_point_value_at_quantile (v:Metrics_types.summary_data_point_value_at_quantile) encoder = - Pbrt.Encoder.key (1, Pbrt.Bits64) encoder; - Pbrt.Encoder.float_as_bits64 v.Metrics_types.quantile encoder; - Pbrt.Encoder.key (2, Pbrt.Bits64) encoder; - Pbrt.Encoder.float_as_bits64 v.Metrics_types.value encoder; - () - -let rec encode_summary_data_point (v:Metrics_types.summary_data_point) encoder = - List.iter (fun x -> - Pbrt.Encoder.key (7, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (Common_pb.encode_key_value x) encoder; - ) v.Metrics_types.attributes; - Pbrt.Encoder.key (2, Pbrt.Bits64) encoder; - Pbrt.Encoder.int64_as_bits64 v.Metrics_types.start_time_unix_nano encoder; - Pbrt.Encoder.key (3, Pbrt.Bits64) encoder; - Pbrt.Encoder.int64_as_bits64 v.Metrics_types.time_unix_nano encoder; - Pbrt.Encoder.key (4, Pbrt.Bits64) encoder; - Pbrt.Encoder.int64_as_bits64 v.Metrics_types.count encoder; - Pbrt.Encoder.key (5, Pbrt.Bits64) encoder; - Pbrt.Encoder.float_as_bits64 v.Metrics_types.sum encoder; - List.iter (fun x -> - Pbrt.Encoder.key (6, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_summary_data_point_value_at_quantile x) encoder; - ) v.Metrics_types.quantile_values; - Pbrt.Encoder.key (8, Pbrt.Varint) encoder; - Pbrt.Encoder.int32_as_varint v.Metrics_types.flags encoder; - () - -let rec encode_summary (v:Metrics_types.summary) encoder = - List.iter (fun x -> - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_summary_data_point x) encoder; - ) v.Metrics_types.data_points; - () - -let rec encode_metric_data (v:Metrics_types.metric_data) encoder = - begin match v with - | Metrics_types.Gauge x -> - Pbrt.Encoder.key (5, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_gauge x) encoder; - | Metrics_types.Sum x -> - Pbrt.Encoder.key (7, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_sum x) encoder; - | Metrics_types.Histogram x -> - Pbrt.Encoder.key (9, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_histogram x) encoder; - | Metrics_types.Exponential_histogram x -> - Pbrt.Encoder.key (10, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_exponential_histogram x) encoder; - | Metrics_types.Summary x -> - Pbrt.Encoder.key (11, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_summary x) encoder; - end - -and encode_metric (v:Metrics_types.metric) encoder = - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.string v.Metrics_types.name encoder; - Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; - Pbrt.Encoder.string v.Metrics_types.description encoder; - Pbrt.Encoder.key (3, Pbrt.Bytes) encoder; - Pbrt.Encoder.string v.Metrics_types.unit_ encoder; - begin match v.Metrics_types.data with - | Metrics_types.Gauge x -> - Pbrt.Encoder.key (5, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_gauge x) encoder; - | Metrics_types.Sum x -> - Pbrt.Encoder.key (7, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_sum x) encoder; - | Metrics_types.Histogram x -> - Pbrt.Encoder.key (9, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_histogram x) encoder; - | Metrics_types.Exponential_histogram x -> - Pbrt.Encoder.key (10, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_exponential_histogram x) encoder; - | Metrics_types.Summary x -> - Pbrt.Encoder.key (11, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_summary x) encoder; - end; - () - -let rec encode_scope_metrics (v:Metrics_types.scope_metrics) encoder = - begin match v.Metrics_types.scope with - | Some x -> - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (Common_pb.encode_instrumentation_scope x) encoder; - | None -> (); - end; - List.iter (fun x -> - Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_metric x) encoder; - ) v.Metrics_types.metrics; - Pbrt.Encoder.key (3, Pbrt.Bytes) encoder; - Pbrt.Encoder.string v.Metrics_types.schema_url encoder; - () - -let rec encode_resource_metrics (v:Metrics_types.resource_metrics) encoder = - begin match v.Metrics_types.resource with - | Some x -> - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (Resource_pb.encode_resource x) encoder; - | None -> (); - end; - List.iter (fun x -> - Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_scope_metrics x) encoder; - ) v.Metrics_types.scope_metrics; - Pbrt.Encoder.key (3, Pbrt.Bytes) encoder; - Pbrt.Encoder.string v.Metrics_types.schema_url encoder; - () - -let rec encode_metrics_data (v:Metrics_types.metrics_data) encoder = - List.iter (fun x -> - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_resource_metrics x) encoder; - ) v.Metrics_types.resource_metrics; - () - -let rec encode_data_point_flags (v:Metrics_types.data_point_flags) encoder = - match v with - | Metrics_types.Data_point_flags_do_not_use -> Pbrt.Encoder.int_as_varint (0) encoder - | Metrics_types.Data_point_flags_no_recorded_value_mask -> Pbrt.Encoder.int_as_varint 1 encoder diff --git a/src/metrics_pb.mli b/src/metrics_pb.mli deleted file mode 100644 index 6393cedd..00000000 --- a/src/metrics_pb.mli +++ /dev/null @@ -1,133 +0,0 @@ -(** metrics.proto Binary Encoding *) - - -(** {2 Protobuf Encoding} *) - -val encode_exemplar_value : Metrics_types.exemplar_value -> Pbrt.Encoder.t -> unit -(** [encode_exemplar_value v encoder] encodes [v] with the given [encoder] *) - -val encode_exemplar : Metrics_types.exemplar -> Pbrt.Encoder.t -> unit -(** [encode_exemplar v encoder] encodes [v] with the given [encoder] *) - -val encode_number_data_point_value : Metrics_types.number_data_point_value -> Pbrt.Encoder.t -> unit -(** [encode_number_data_point_value v encoder] encodes [v] with the given [encoder] *) - -val encode_number_data_point : Metrics_types.number_data_point -> Pbrt.Encoder.t -> unit -(** [encode_number_data_point v encoder] encodes [v] with the given [encoder] *) - -val encode_gauge : Metrics_types.gauge -> Pbrt.Encoder.t -> unit -(** [encode_gauge v encoder] encodes [v] with the given [encoder] *) - -val encode_aggregation_temporality : Metrics_types.aggregation_temporality -> Pbrt.Encoder.t -> unit -(** [encode_aggregation_temporality v encoder] encodes [v] with the given [encoder] *) - -val encode_sum : Metrics_types.sum -> Pbrt.Encoder.t -> unit -(** [encode_sum v encoder] encodes [v] with the given [encoder] *) - -val encode_histogram_data_point : Metrics_types.histogram_data_point -> Pbrt.Encoder.t -> unit -(** [encode_histogram_data_point v encoder] encodes [v] with the given [encoder] *) - -val encode_histogram : Metrics_types.histogram -> Pbrt.Encoder.t -> unit -(** [encode_histogram v encoder] encodes [v] with the given [encoder] *) - -val encode_exponential_histogram_data_point_buckets : Metrics_types.exponential_histogram_data_point_buckets -> Pbrt.Encoder.t -> unit -(** [encode_exponential_histogram_data_point_buckets v encoder] encodes [v] with the given [encoder] *) - -val encode_exponential_histogram_data_point : Metrics_types.exponential_histogram_data_point -> Pbrt.Encoder.t -> unit -(** [encode_exponential_histogram_data_point v encoder] encodes [v] with the given [encoder] *) - -val encode_exponential_histogram : Metrics_types.exponential_histogram -> Pbrt.Encoder.t -> unit -(** [encode_exponential_histogram v encoder] encodes [v] with the given [encoder] *) - -val encode_summary_data_point_value_at_quantile : Metrics_types.summary_data_point_value_at_quantile -> Pbrt.Encoder.t -> unit -(** [encode_summary_data_point_value_at_quantile v encoder] encodes [v] with the given [encoder] *) - -val encode_summary_data_point : Metrics_types.summary_data_point -> Pbrt.Encoder.t -> unit -(** [encode_summary_data_point v encoder] encodes [v] with the given [encoder] *) - -val encode_summary : Metrics_types.summary -> Pbrt.Encoder.t -> unit -(** [encode_summary v encoder] encodes [v] with the given [encoder] *) - -val encode_metric_data : Metrics_types.metric_data -> Pbrt.Encoder.t -> unit -(** [encode_metric_data v encoder] encodes [v] with the given [encoder] *) - -val encode_metric : Metrics_types.metric -> Pbrt.Encoder.t -> unit -(** [encode_metric v encoder] encodes [v] with the given [encoder] *) - -val encode_scope_metrics : Metrics_types.scope_metrics -> Pbrt.Encoder.t -> unit -(** [encode_scope_metrics v encoder] encodes [v] with the given [encoder] *) - -val encode_resource_metrics : Metrics_types.resource_metrics -> Pbrt.Encoder.t -> unit -(** [encode_resource_metrics v encoder] encodes [v] with the given [encoder] *) - -val encode_metrics_data : Metrics_types.metrics_data -> Pbrt.Encoder.t -> unit -(** [encode_metrics_data v encoder] encodes [v] with the given [encoder] *) - -val encode_data_point_flags : Metrics_types.data_point_flags -> Pbrt.Encoder.t -> unit -(** [encode_data_point_flags v encoder] encodes [v] with the given [encoder] *) - - -(** {2 Protobuf Decoding} *) - -val decode_exemplar_value : Pbrt.Decoder.t -> Metrics_types.exemplar_value -(** [decode_exemplar_value decoder] decodes a [exemplar_value] value from [decoder] *) - -val decode_exemplar : Pbrt.Decoder.t -> Metrics_types.exemplar -(** [decode_exemplar decoder] decodes a [exemplar] value from [decoder] *) - -val decode_number_data_point_value : Pbrt.Decoder.t -> Metrics_types.number_data_point_value -(** [decode_number_data_point_value decoder] decodes a [number_data_point_value] value from [decoder] *) - -val decode_number_data_point : Pbrt.Decoder.t -> Metrics_types.number_data_point -(** [decode_number_data_point decoder] decodes a [number_data_point] value from [decoder] *) - -val decode_gauge : Pbrt.Decoder.t -> Metrics_types.gauge -(** [decode_gauge decoder] decodes a [gauge] value from [decoder] *) - -val decode_aggregation_temporality : Pbrt.Decoder.t -> Metrics_types.aggregation_temporality -(** [decode_aggregation_temporality decoder] decodes a [aggregation_temporality] value from [decoder] *) - -val decode_sum : Pbrt.Decoder.t -> Metrics_types.sum -(** [decode_sum decoder] decodes a [sum] value from [decoder] *) - -val decode_histogram_data_point : Pbrt.Decoder.t -> Metrics_types.histogram_data_point -(** [decode_histogram_data_point decoder] decodes a [histogram_data_point] value from [decoder] *) - -val decode_histogram : Pbrt.Decoder.t -> Metrics_types.histogram -(** [decode_histogram decoder] decodes a [histogram] value from [decoder] *) - -val decode_exponential_histogram_data_point_buckets : Pbrt.Decoder.t -> Metrics_types.exponential_histogram_data_point_buckets -(** [decode_exponential_histogram_data_point_buckets decoder] decodes a [exponential_histogram_data_point_buckets] value from [decoder] *) - -val decode_exponential_histogram_data_point : Pbrt.Decoder.t -> Metrics_types.exponential_histogram_data_point -(** [decode_exponential_histogram_data_point decoder] decodes a [exponential_histogram_data_point] value from [decoder] *) - -val decode_exponential_histogram : Pbrt.Decoder.t -> Metrics_types.exponential_histogram -(** [decode_exponential_histogram decoder] decodes a [exponential_histogram] value from [decoder] *) - -val decode_summary_data_point_value_at_quantile : Pbrt.Decoder.t -> Metrics_types.summary_data_point_value_at_quantile -(** [decode_summary_data_point_value_at_quantile decoder] decodes a [summary_data_point_value_at_quantile] value from [decoder] *) - -val decode_summary_data_point : Pbrt.Decoder.t -> Metrics_types.summary_data_point -(** [decode_summary_data_point decoder] decodes a [summary_data_point] value from [decoder] *) - -val decode_summary : Pbrt.Decoder.t -> Metrics_types.summary -(** [decode_summary decoder] decodes a [summary] value from [decoder] *) - -val decode_metric_data : Pbrt.Decoder.t -> Metrics_types.metric_data -(** [decode_metric_data decoder] decodes a [metric_data] value from [decoder] *) - -val decode_metric : Pbrt.Decoder.t -> Metrics_types.metric -(** [decode_metric decoder] decodes a [metric] value from [decoder] *) - -val decode_scope_metrics : Pbrt.Decoder.t -> Metrics_types.scope_metrics -(** [decode_scope_metrics decoder] decodes a [scope_metrics] value from [decoder] *) - -val decode_resource_metrics : Pbrt.Decoder.t -> Metrics_types.resource_metrics -(** [decode_resource_metrics decoder] decodes a [resource_metrics] value from [decoder] *) - -val decode_metrics_data : Pbrt.Decoder.t -> Metrics_types.metrics_data -(** [decode_metrics_data decoder] decodes a [metrics_data] value from [decoder] *) - -val decode_data_point_flags : Pbrt.Decoder.t -> Metrics_types.data_point_flags -(** [decode_data_point_flags decoder] decodes a [data_point_flags] value from [decoder] *) diff --git a/src/metrics_pp.ml b/src/metrics_pp.ml deleted file mode 100644 index 838343ff..00000000 --- a/src/metrics_pp.ml +++ /dev/null @@ -1,177 +0,0 @@ -[@@@ocaml.warning "-27-30-39"] - -let rec pp_exemplar_value fmt (v:Metrics_types.exemplar_value) = - match v with - | Metrics_types.As_double x -> Format.fprintf fmt "@[As_double(@,%a)@]" Pbrt.Pp.pp_float x - | Metrics_types.As_int x -> Format.fprintf fmt "@[As_int(@,%a)@]" Pbrt.Pp.pp_int64 x - -and pp_exemplar fmt (v:Metrics_types.exemplar) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "filtered_attributes" (Pbrt.Pp.pp_list Common_pp.pp_key_value) fmt v.Metrics_types.filtered_attributes; - Pbrt.Pp.pp_record_field ~first:false "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Metrics_types.time_unix_nano; - Pbrt.Pp.pp_record_field ~first:false "value" pp_exemplar_value fmt v.Metrics_types.value; - Pbrt.Pp.pp_record_field ~first:false "span_id" Pbrt.Pp.pp_bytes fmt v.Metrics_types.span_id; - Pbrt.Pp.pp_record_field ~first:false "trace_id" Pbrt.Pp.pp_bytes fmt v.Metrics_types.trace_id; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_number_data_point_value fmt (v:Metrics_types.number_data_point_value) = - match v with - | Metrics_types.As_double x -> Format.fprintf fmt "@[As_double(@,%a)@]" Pbrt.Pp.pp_float x - | Metrics_types.As_int x -> Format.fprintf fmt "@[As_int(@,%a)@]" Pbrt.Pp.pp_int64 x - -and pp_number_data_point fmt (v:Metrics_types.number_data_point) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "attributes" (Pbrt.Pp.pp_list Common_pp.pp_key_value) fmt v.Metrics_types.attributes; - Pbrt.Pp.pp_record_field ~first:false "start_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Metrics_types.start_time_unix_nano; - Pbrt.Pp.pp_record_field ~first:false "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Metrics_types.time_unix_nano; - Pbrt.Pp.pp_record_field ~first:false "value" pp_number_data_point_value fmt v.Metrics_types.value; - Pbrt.Pp.pp_record_field ~first:false "exemplars" (Pbrt.Pp.pp_list pp_exemplar) fmt v.Metrics_types.exemplars; - Pbrt.Pp.pp_record_field ~first:false "flags" Pbrt.Pp.pp_int32 fmt v.Metrics_types.flags; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_gauge fmt (v:Metrics_types.gauge) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "data_points" (Pbrt.Pp.pp_list pp_number_data_point) fmt v.Metrics_types.data_points; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_aggregation_temporality fmt (v:Metrics_types.aggregation_temporality) = - match v with - | Metrics_types.Aggregation_temporality_unspecified -> Format.fprintf fmt "Aggregation_temporality_unspecified" - | Metrics_types.Aggregation_temporality_delta -> Format.fprintf fmt "Aggregation_temporality_delta" - | Metrics_types.Aggregation_temporality_cumulative -> Format.fprintf fmt "Aggregation_temporality_cumulative" - -let rec pp_sum fmt (v:Metrics_types.sum) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "data_points" (Pbrt.Pp.pp_list pp_number_data_point) fmt v.Metrics_types.data_points; - Pbrt.Pp.pp_record_field ~first:false "aggregation_temporality" pp_aggregation_temporality fmt v.Metrics_types.aggregation_temporality; - Pbrt.Pp.pp_record_field ~first:false "is_monotonic" Pbrt.Pp.pp_bool fmt v.Metrics_types.is_monotonic; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_histogram_data_point fmt (v:Metrics_types.histogram_data_point) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "attributes" (Pbrt.Pp.pp_list Common_pp.pp_key_value) fmt v.Metrics_types.attributes; - Pbrt.Pp.pp_record_field ~first:false "start_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Metrics_types.start_time_unix_nano; - Pbrt.Pp.pp_record_field ~first:false "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Metrics_types.time_unix_nano; - Pbrt.Pp.pp_record_field ~first:false "count" Pbrt.Pp.pp_int64 fmt v.Metrics_types.count; - Pbrt.Pp.pp_record_field ~first:false "sum" (Pbrt.Pp.pp_option Pbrt.Pp.pp_float) fmt v.Metrics_types.sum; - Pbrt.Pp.pp_record_field ~first:false "bucket_counts" (Pbrt.Pp.pp_list Pbrt.Pp.pp_int64) fmt v.Metrics_types.bucket_counts; - Pbrt.Pp.pp_record_field ~first:false "explicit_bounds" (Pbrt.Pp.pp_list Pbrt.Pp.pp_float) fmt v.Metrics_types.explicit_bounds; - Pbrt.Pp.pp_record_field ~first:false "exemplars" (Pbrt.Pp.pp_list pp_exemplar) fmt v.Metrics_types.exemplars; - Pbrt.Pp.pp_record_field ~first:false "flags" Pbrt.Pp.pp_int32 fmt v.Metrics_types.flags; - Pbrt.Pp.pp_record_field ~first:false "min" (Pbrt.Pp.pp_option Pbrt.Pp.pp_float) fmt v.Metrics_types.min; - Pbrt.Pp.pp_record_field ~first:false "max" (Pbrt.Pp.pp_option Pbrt.Pp.pp_float) fmt v.Metrics_types.max; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_histogram fmt (v:Metrics_types.histogram) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "data_points" (Pbrt.Pp.pp_list pp_histogram_data_point) fmt v.Metrics_types.data_points; - Pbrt.Pp.pp_record_field ~first:false "aggregation_temporality" pp_aggregation_temporality fmt v.Metrics_types.aggregation_temporality; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_exponential_histogram_data_point_buckets fmt (v:Metrics_types.exponential_histogram_data_point_buckets) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "offset" Pbrt.Pp.pp_int32 fmt v.Metrics_types.offset; - Pbrt.Pp.pp_record_field ~first:false "bucket_counts" (Pbrt.Pp.pp_list Pbrt.Pp.pp_int64) fmt v.Metrics_types.bucket_counts; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_exponential_histogram_data_point fmt (v:Metrics_types.exponential_histogram_data_point) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "attributes" (Pbrt.Pp.pp_list Common_pp.pp_key_value) fmt v.Metrics_types.attributes; - Pbrt.Pp.pp_record_field ~first:false "start_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Metrics_types.start_time_unix_nano; - Pbrt.Pp.pp_record_field ~first:false "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Metrics_types.time_unix_nano; - Pbrt.Pp.pp_record_field ~first:false "count" Pbrt.Pp.pp_int64 fmt v.Metrics_types.count; - Pbrt.Pp.pp_record_field ~first:false "sum" (Pbrt.Pp.pp_option Pbrt.Pp.pp_float) fmt v.Metrics_types.sum; - Pbrt.Pp.pp_record_field ~first:false "scale" Pbrt.Pp.pp_int32 fmt v.Metrics_types.scale; - Pbrt.Pp.pp_record_field ~first:false "zero_count" Pbrt.Pp.pp_int64 fmt v.Metrics_types.zero_count; - Pbrt.Pp.pp_record_field ~first:false "positive" (Pbrt.Pp.pp_option pp_exponential_histogram_data_point_buckets) fmt v.Metrics_types.positive; - Pbrt.Pp.pp_record_field ~first:false "negative" (Pbrt.Pp.pp_option pp_exponential_histogram_data_point_buckets) fmt v.Metrics_types.negative; - Pbrt.Pp.pp_record_field ~first:false "flags" Pbrt.Pp.pp_int32 fmt v.Metrics_types.flags; - Pbrt.Pp.pp_record_field ~first:false "exemplars" (Pbrt.Pp.pp_list pp_exemplar) fmt v.Metrics_types.exemplars; - Pbrt.Pp.pp_record_field ~first:false "min" (Pbrt.Pp.pp_option Pbrt.Pp.pp_float) fmt v.Metrics_types.min; - Pbrt.Pp.pp_record_field ~first:false "max" (Pbrt.Pp.pp_option Pbrt.Pp.pp_float) fmt v.Metrics_types.max; - Pbrt.Pp.pp_record_field ~first:false "zero_threshold" Pbrt.Pp.pp_float fmt v.Metrics_types.zero_threshold; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_exponential_histogram fmt (v:Metrics_types.exponential_histogram) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "data_points" (Pbrt.Pp.pp_list pp_exponential_histogram_data_point) fmt v.Metrics_types.data_points; - Pbrt.Pp.pp_record_field ~first:false "aggregation_temporality" pp_aggregation_temporality fmt v.Metrics_types.aggregation_temporality; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_summary_data_point_value_at_quantile fmt (v:Metrics_types.summary_data_point_value_at_quantile) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "quantile" Pbrt.Pp.pp_float fmt v.Metrics_types.quantile; - Pbrt.Pp.pp_record_field ~first:false "value" Pbrt.Pp.pp_float fmt v.Metrics_types.value; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_summary_data_point fmt (v:Metrics_types.summary_data_point) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "attributes" (Pbrt.Pp.pp_list Common_pp.pp_key_value) fmt v.Metrics_types.attributes; - Pbrt.Pp.pp_record_field ~first:false "start_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Metrics_types.start_time_unix_nano; - Pbrt.Pp.pp_record_field ~first:false "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Metrics_types.time_unix_nano; - Pbrt.Pp.pp_record_field ~first:false "count" Pbrt.Pp.pp_int64 fmt v.Metrics_types.count; - Pbrt.Pp.pp_record_field ~first:false "sum" Pbrt.Pp.pp_float fmt v.Metrics_types.sum; - Pbrt.Pp.pp_record_field ~first:false "quantile_values" (Pbrt.Pp.pp_list pp_summary_data_point_value_at_quantile) fmt v.Metrics_types.quantile_values; - Pbrt.Pp.pp_record_field ~first:false "flags" Pbrt.Pp.pp_int32 fmt v.Metrics_types.flags; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_summary fmt (v:Metrics_types.summary) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "data_points" (Pbrt.Pp.pp_list pp_summary_data_point) fmt v.Metrics_types.data_points; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_metric_data fmt (v:Metrics_types.metric_data) = - match v with - | Metrics_types.Gauge x -> Format.fprintf fmt "@[Gauge(@,%a)@]" pp_gauge x - | Metrics_types.Sum x -> Format.fprintf fmt "@[Sum(@,%a)@]" pp_sum x - | Metrics_types.Histogram x -> Format.fprintf fmt "@[Histogram(@,%a)@]" pp_histogram x - | Metrics_types.Exponential_histogram x -> Format.fprintf fmt "@[Exponential_histogram(@,%a)@]" pp_exponential_histogram x - | Metrics_types.Summary x -> Format.fprintf fmt "@[Summary(@,%a)@]" pp_summary x - -and pp_metric fmt (v:Metrics_types.metric) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "name" Pbrt.Pp.pp_string fmt v.Metrics_types.name; - Pbrt.Pp.pp_record_field ~first:false "description" Pbrt.Pp.pp_string fmt v.Metrics_types.description; - Pbrt.Pp.pp_record_field ~first:false "unit_" Pbrt.Pp.pp_string fmt v.Metrics_types.unit_; - Pbrt.Pp.pp_record_field ~first:false "data" pp_metric_data fmt v.Metrics_types.data; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_scope_metrics fmt (v:Metrics_types.scope_metrics) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "scope" (Pbrt.Pp.pp_option Common_pp.pp_instrumentation_scope) fmt v.Metrics_types.scope; - Pbrt.Pp.pp_record_field ~first:false "metrics" (Pbrt.Pp.pp_list pp_metric) fmt v.Metrics_types.metrics; - Pbrt.Pp.pp_record_field ~first:false "schema_url" Pbrt.Pp.pp_string fmt v.Metrics_types.schema_url; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_resource_metrics fmt (v:Metrics_types.resource_metrics) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "resource" (Pbrt.Pp.pp_option Resource_pp.pp_resource) fmt v.Metrics_types.resource; - Pbrt.Pp.pp_record_field ~first:false "scope_metrics" (Pbrt.Pp.pp_list pp_scope_metrics) fmt v.Metrics_types.scope_metrics; - Pbrt.Pp.pp_record_field ~first:false "schema_url" Pbrt.Pp.pp_string fmt v.Metrics_types.schema_url; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_metrics_data fmt (v:Metrics_types.metrics_data) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "resource_metrics" (Pbrt.Pp.pp_list pp_resource_metrics) fmt v.Metrics_types.resource_metrics; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_data_point_flags fmt (v:Metrics_types.data_point_flags) = - match v with - | Metrics_types.Data_point_flags_do_not_use -> Format.fprintf fmt "Data_point_flags_do_not_use" - | Metrics_types.Data_point_flags_no_recorded_value_mask -> Format.fprintf fmt "Data_point_flags_no_recorded_value_mask" diff --git a/src/metrics_pp.mli b/src/metrics_pp.mli deleted file mode 100644 index c506e897..00000000 --- a/src/metrics_pp.mli +++ /dev/null @@ -1,67 +0,0 @@ -(** metrics.proto Pretty Printing *) - - -(** {2 Formatters} *) - -val pp_exemplar_value : Format.formatter -> Metrics_types.exemplar_value -> unit -(** [pp_exemplar_value v] formats v *) - -val pp_exemplar : Format.formatter -> Metrics_types.exemplar -> unit -(** [pp_exemplar v] formats v *) - -val pp_number_data_point_value : Format.formatter -> Metrics_types.number_data_point_value -> unit -(** [pp_number_data_point_value v] formats v *) - -val pp_number_data_point : Format.formatter -> Metrics_types.number_data_point -> unit -(** [pp_number_data_point v] formats v *) - -val pp_gauge : Format.formatter -> Metrics_types.gauge -> unit -(** [pp_gauge v] formats v *) - -val pp_aggregation_temporality : Format.formatter -> Metrics_types.aggregation_temporality -> unit -(** [pp_aggregation_temporality v] formats v *) - -val pp_sum : Format.formatter -> Metrics_types.sum -> unit -(** [pp_sum v] formats v *) - -val pp_histogram_data_point : Format.formatter -> Metrics_types.histogram_data_point -> unit -(** [pp_histogram_data_point v] formats v *) - -val pp_histogram : Format.formatter -> Metrics_types.histogram -> unit -(** [pp_histogram v] formats v *) - -val pp_exponential_histogram_data_point_buckets : Format.formatter -> Metrics_types.exponential_histogram_data_point_buckets -> unit -(** [pp_exponential_histogram_data_point_buckets v] formats v *) - -val pp_exponential_histogram_data_point : Format.formatter -> Metrics_types.exponential_histogram_data_point -> unit -(** [pp_exponential_histogram_data_point v] formats v *) - -val pp_exponential_histogram : Format.formatter -> Metrics_types.exponential_histogram -> unit -(** [pp_exponential_histogram v] formats v *) - -val pp_summary_data_point_value_at_quantile : Format.formatter -> Metrics_types.summary_data_point_value_at_quantile -> unit -(** [pp_summary_data_point_value_at_quantile v] formats v *) - -val pp_summary_data_point : Format.formatter -> Metrics_types.summary_data_point -> unit -(** [pp_summary_data_point v] formats v *) - -val pp_summary : Format.formatter -> Metrics_types.summary -> unit -(** [pp_summary v] formats v *) - -val pp_metric_data : Format.formatter -> Metrics_types.metric_data -> unit -(** [pp_metric_data v] formats v *) - -val pp_metric : Format.formatter -> Metrics_types.metric -> unit -(** [pp_metric v] formats v *) - -val pp_scope_metrics : Format.formatter -> Metrics_types.scope_metrics -> unit -(** [pp_scope_metrics v] formats v *) - -val pp_resource_metrics : Format.formatter -> Metrics_types.resource_metrics -> unit -(** [pp_resource_metrics v] formats v *) - -val pp_metrics_data : Format.formatter -> Metrics_types.metrics_data -> unit -(** [pp_metrics_data v] formats v *) - -val pp_data_point_flags : Format.formatter -> Metrics_types.data_point_flags -> unit -(** [pp_data_point_flags v] formats v *) diff --git a/src/metrics_service_pb.ml b/src/metrics_service_pb.ml deleted file mode 100644 index dd839d9b..00000000 --- a/src/metrics_service_pb.ml +++ /dev/null @@ -1,112 +0,0 @@ -[@@@ocaml.warning "-27-30-39"] - -type export_metrics_service_request_mutable = { - mutable resource_metrics : Metrics_types.resource_metrics list; -} - -let default_export_metrics_service_request_mutable () : export_metrics_service_request_mutable = { - resource_metrics = []; -} - -type export_metrics_partial_success_mutable = { - mutable rejected_data_points : int64; - mutable error_message : string; -} - -let default_export_metrics_partial_success_mutable () : export_metrics_partial_success_mutable = { - rejected_data_points = 0L; - error_message = ""; -} - -type export_metrics_service_response_mutable = { - mutable partial_success : Metrics_service_types.export_metrics_partial_success option; -} - -let default_export_metrics_service_response_mutable () : export_metrics_service_response_mutable = { - partial_success = None; -} - - -let rec decode_export_metrics_service_request d = - let v = default_export_metrics_service_request_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.resource_metrics <- List.rev v.resource_metrics; - ); continue__ := false - | Some (1, Pbrt.Bytes) -> begin - v.resource_metrics <- (Metrics_pb.decode_resource_metrics (Pbrt.Decoder.nested d)) :: v.resource_metrics; - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(export_metrics_service_request), field(1)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Metrics_service_types.resource_metrics = v.resource_metrics; - } : Metrics_service_types.export_metrics_service_request) - -let rec decode_export_metrics_partial_success d = - let v = default_export_metrics_partial_success_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - ); continue__ := false - | Some (1, Pbrt.Varint) -> begin - v.rejected_data_points <- Pbrt.Decoder.int64_as_varint d; - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(export_metrics_partial_success), field(1)" pk - | Some (2, Pbrt.Bytes) -> begin - v.error_message <- Pbrt.Decoder.string d; - end - | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(export_metrics_partial_success), field(2)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Metrics_service_types.rejected_data_points = v.rejected_data_points; - Metrics_service_types.error_message = v.error_message; - } : Metrics_service_types.export_metrics_partial_success) - -let rec decode_export_metrics_service_response d = - let v = default_export_metrics_service_response_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - ); continue__ := false - | Some (1, Pbrt.Bytes) -> begin - v.partial_success <- Some (decode_export_metrics_partial_success (Pbrt.Decoder.nested d)); - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(export_metrics_service_response), field(1)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Metrics_service_types.partial_success = v.partial_success; - } : Metrics_service_types.export_metrics_service_response) - -let rec encode_export_metrics_service_request (v:Metrics_service_types.export_metrics_service_request) encoder = - List.iter (fun x -> - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (Metrics_pb.encode_resource_metrics x) encoder; - ) v.Metrics_service_types.resource_metrics; - () - -let rec encode_export_metrics_partial_success (v:Metrics_service_types.export_metrics_partial_success) encoder = - Pbrt.Encoder.key (1, Pbrt.Varint) encoder; - Pbrt.Encoder.int64_as_varint v.Metrics_service_types.rejected_data_points encoder; - Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; - Pbrt.Encoder.string v.Metrics_service_types.error_message encoder; - () - -let rec encode_export_metrics_service_response (v:Metrics_service_types.export_metrics_service_response) encoder = - begin match v.Metrics_service_types.partial_success with - | Some x -> - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_export_metrics_partial_success x) encoder; - | None -> (); - end; - () diff --git a/src/metrics_service_pb.mli b/src/metrics_service_pb.mli deleted file mode 100644 index ed839b04..00000000 --- a/src/metrics_service_pb.mli +++ /dev/null @@ -1,25 +0,0 @@ -(** metrics_service.proto Binary Encoding *) - - -(** {2 Protobuf Encoding} *) - -val encode_export_metrics_service_request : Metrics_service_types.export_metrics_service_request -> Pbrt.Encoder.t -> unit -(** [encode_export_metrics_service_request v encoder] encodes [v] with the given [encoder] *) - -val encode_export_metrics_partial_success : Metrics_service_types.export_metrics_partial_success -> Pbrt.Encoder.t -> unit -(** [encode_export_metrics_partial_success v encoder] encodes [v] with the given [encoder] *) - -val encode_export_metrics_service_response : Metrics_service_types.export_metrics_service_response -> Pbrt.Encoder.t -> unit -(** [encode_export_metrics_service_response v encoder] encodes [v] with the given [encoder] *) - - -(** {2 Protobuf Decoding} *) - -val decode_export_metrics_service_request : Pbrt.Decoder.t -> Metrics_service_types.export_metrics_service_request -(** [decode_export_metrics_service_request decoder] decodes a [export_metrics_service_request] value from [decoder] *) - -val decode_export_metrics_partial_success : Pbrt.Decoder.t -> Metrics_service_types.export_metrics_partial_success -(** [decode_export_metrics_partial_success decoder] decodes a [export_metrics_partial_success] value from [decoder] *) - -val decode_export_metrics_service_response : Pbrt.Decoder.t -> Metrics_service_types.export_metrics_service_response -(** [decode_export_metrics_service_response decoder] decodes a [export_metrics_service_response] value from [decoder] *) diff --git a/src/metrics_service_pp.ml b/src/metrics_service_pp.ml deleted file mode 100644 index bb0f7a3b..00000000 --- a/src/metrics_service_pp.ml +++ /dev/null @@ -1,20 +0,0 @@ -[@@@ocaml.warning "-27-30-39"] - -let rec pp_export_metrics_service_request fmt (v:Metrics_service_types.export_metrics_service_request) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "resource_metrics" (Pbrt.Pp.pp_list Metrics_pp.pp_resource_metrics) fmt v.Metrics_service_types.resource_metrics; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_export_metrics_partial_success fmt (v:Metrics_service_types.export_metrics_partial_success) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "rejected_data_points" Pbrt.Pp.pp_int64 fmt v.Metrics_service_types.rejected_data_points; - Pbrt.Pp.pp_record_field ~first:false "error_message" Pbrt.Pp.pp_string fmt v.Metrics_service_types.error_message; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_export_metrics_service_response fmt (v:Metrics_service_types.export_metrics_service_response) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "partial_success" (Pbrt.Pp.pp_option pp_export_metrics_partial_success) fmt v.Metrics_service_types.partial_success; - in - Pbrt.Pp.pp_brk pp_i fmt () diff --git a/src/metrics_service_pp.mli b/src/metrics_service_pp.mli deleted file mode 100644 index 90301da8..00000000 --- a/src/metrics_service_pp.mli +++ /dev/null @@ -1,13 +0,0 @@ -(** metrics_service.proto Pretty Printing *) - - -(** {2 Formatters} *) - -val pp_export_metrics_service_request : Format.formatter -> Metrics_service_types.export_metrics_service_request -> unit -(** [pp_export_metrics_service_request v] formats v *) - -val pp_export_metrics_partial_success : Format.formatter -> Metrics_service_types.export_metrics_partial_success -> unit -(** [pp_export_metrics_partial_success v] formats v *) - -val pp_export_metrics_service_response : Format.formatter -> Metrics_service_types.export_metrics_service_response -> unit -(** [pp_export_metrics_service_response v] formats v *) diff --git a/src/metrics_service_types.ml b/src/metrics_service_types.ml deleted file mode 100644 index 8b252a24..00000000 --- a/src/metrics_service_types.ml +++ /dev/null @@ -1,35 +0,0 @@ -[@@@ocaml.warning "-27-30-39"] - - -type export_metrics_service_request = { - resource_metrics : Metrics_types.resource_metrics list; -} - -type export_metrics_partial_success = { - rejected_data_points : int64; - error_message : string; -} - -type export_metrics_service_response = { - partial_success : export_metrics_partial_success option; -} - -let rec default_export_metrics_service_request - ?resource_metrics:((resource_metrics:Metrics_types.resource_metrics list) = []) - () : export_metrics_service_request = { - resource_metrics; -} - -let rec default_export_metrics_partial_success - ?rejected_data_points:((rejected_data_points:int64) = 0L) - ?error_message:((error_message:string) = "") - () : export_metrics_partial_success = { - rejected_data_points; - error_message; -} - -let rec default_export_metrics_service_response - ?partial_success:((partial_success:export_metrics_partial_success option) = None) - () : export_metrics_service_response = { - partial_success; -} diff --git a/src/metrics_service_types.mli b/src/metrics_service_types.mli deleted file mode 100644 index cbcddfed..00000000 --- a/src/metrics_service_types.mli +++ /dev/null @@ -1,40 +0,0 @@ -(** metrics_service.proto Types *) - - - -(** {2 Types} *) - -type export_metrics_service_request = { - resource_metrics : Metrics_types.resource_metrics list; -} - -type export_metrics_partial_success = { - rejected_data_points : int64; - error_message : string; -} - -type export_metrics_service_response = { - partial_success : export_metrics_partial_success option; -} - - -(** {2 Default values} *) - -val default_export_metrics_service_request : - ?resource_metrics:Metrics_types.resource_metrics list -> - unit -> - export_metrics_service_request -(** [default_export_metrics_service_request ()] is the default value for type [export_metrics_service_request] *) - -val default_export_metrics_partial_success : - ?rejected_data_points:int64 -> - ?error_message:string -> - unit -> - export_metrics_partial_success -(** [default_export_metrics_partial_success ()] is the default value for type [export_metrics_partial_success] *) - -val default_export_metrics_service_response : - ?partial_success:export_metrics_partial_success option -> - unit -> - export_metrics_service_response -(** [default_export_metrics_service_response ()] is the default value for type [export_metrics_service_response] *) diff --git a/src/metrics_types.ml b/src/metrics_types.ml deleted file mode 100644 index 4cd9c09e..00000000 --- a/src/metrics_types.ml +++ /dev/null @@ -1,349 +0,0 @@ -[@@@ocaml.warning "-27-30-39"] - - -type exemplar_value = - | As_double of float - | As_int of int64 - -and exemplar = { - filtered_attributes : Common_types.key_value list; - time_unix_nano : int64; - value : exemplar_value; - span_id : bytes; - trace_id : bytes; -} - -type number_data_point_value = - | As_double of float - | As_int of int64 - -and number_data_point = { - attributes : Common_types.key_value list; - start_time_unix_nano : int64; - time_unix_nano : int64; - value : number_data_point_value; - exemplars : exemplar list; - flags : int32; -} - -type gauge = { - data_points : number_data_point list; -} - -type aggregation_temporality = - | Aggregation_temporality_unspecified - | Aggregation_temporality_delta - | Aggregation_temporality_cumulative - -type sum = { - data_points : number_data_point list; - aggregation_temporality : aggregation_temporality; - is_monotonic : bool; -} - -type histogram_data_point = { - attributes : Common_types.key_value list; - start_time_unix_nano : int64; - time_unix_nano : int64; - count : int64; - sum : float option; - bucket_counts : int64 list; - explicit_bounds : float list; - exemplars : exemplar list; - flags : int32; - min : float option; - max : float option; -} - -type histogram = { - data_points : histogram_data_point list; - aggregation_temporality : aggregation_temporality; -} - -type exponential_histogram_data_point_buckets = { - offset : int32; - bucket_counts : int64 list; -} - -type exponential_histogram_data_point = { - attributes : Common_types.key_value list; - start_time_unix_nano : int64; - time_unix_nano : int64; - count : int64; - sum : float option; - scale : int32; - zero_count : int64; - positive : exponential_histogram_data_point_buckets option; - negative : exponential_histogram_data_point_buckets option; - flags : int32; - exemplars : exemplar list; - min : float option; - max : float option; - zero_threshold : float; -} - -type exponential_histogram = { - data_points : exponential_histogram_data_point list; - aggregation_temporality : aggregation_temporality; -} - -type summary_data_point_value_at_quantile = { - quantile : float; - value : float; -} - -type summary_data_point = { - attributes : Common_types.key_value list; - start_time_unix_nano : int64; - time_unix_nano : int64; - count : int64; - sum : float; - quantile_values : summary_data_point_value_at_quantile list; - flags : int32; -} - -type summary = { - data_points : summary_data_point list; -} - -type metric_data = - | Gauge of gauge - | Sum of sum - | Histogram of histogram - | Exponential_histogram of exponential_histogram - | Summary of summary - -and metric = { - name : string; - description : string; - unit_ : string; - data : metric_data; -} - -type scope_metrics = { - scope : Common_types.instrumentation_scope option; - metrics : metric list; - schema_url : string; -} - -type resource_metrics = { - resource : Resource_types.resource option; - scope_metrics : scope_metrics list; - schema_url : string; -} - -type metrics_data = { - resource_metrics : resource_metrics list; -} - -type data_point_flags = - | Data_point_flags_do_not_use - | Data_point_flags_no_recorded_value_mask - -let rec default_exemplar_value () : exemplar_value = As_double (0.) - -and default_exemplar - ?filtered_attributes:((filtered_attributes:Common_types.key_value list) = []) - ?time_unix_nano:((time_unix_nano:int64) = 0L) - ?value:((value:exemplar_value) = As_double (0.)) - ?span_id:((span_id:bytes) = Bytes.create 0) - ?trace_id:((trace_id:bytes) = Bytes.create 0) - () : exemplar = { - filtered_attributes; - time_unix_nano; - value; - span_id; - trace_id; -} - -let rec default_number_data_point_value () : number_data_point_value = As_double (0.) - -and default_number_data_point - ?attributes:((attributes:Common_types.key_value list) = []) - ?start_time_unix_nano:((start_time_unix_nano:int64) = 0L) - ?time_unix_nano:((time_unix_nano:int64) = 0L) - ?value:((value:number_data_point_value) = As_double (0.)) - ?exemplars:((exemplars:exemplar list) = []) - ?flags:((flags:int32) = 0l) - () : number_data_point = { - attributes; - start_time_unix_nano; - time_unix_nano; - value; - exemplars; - flags; -} - -let rec default_gauge - ?data_points:((data_points:number_data_point list) = []) - () : gauge = { - data_points; -} - -let rec default_aggregation_temporality () = (Aggregation_temporality_unspecified:aggregation_temporality) - -let rec default_sum - ?data_points:((data_points:number_data_point list) = []) - ?aggregation_temporality:((aggregation_temporality:aggregation_temporality) = default_aggregation_temporality ()) - ?is_monotonic:((is_monotonic:bool) = false) - () : sum = { - data_points; - aggregation_temporality; - is_monotonic; -} - -let rec default_histogram_data_point - ?attributes:((attributes:Common_types.key_value list) = []) - ?start_time_unix_nano:((start_time_unix_nano:int64) = 0L) - ?time_unix_nano:((time_unix_nano:int64) = 0L) - ?count:((count:int64) = 0L) - ?sum:((sum:float option) = None) - ?bucket_counts:((bucket_counts:int64 list) = []) - ?explicit_bounds:((explicit_bounds:float list) = []) - ?exemplars:((exemplars:exemplar list) = []) - ?flags:((flags:int32) = 0l) - ?min:((min:float option) = None) - ?max:((max:float option) = None) - () : histogram_data_point = { - attributes; - start_time_unix_nano; - time_unix_nano; - count; - sum; - bucket_counts; - explicit_bounds; - exemplars; - flags; - min; - max; -} - -let rec default_histogram - ?data_points:((data_points:histogram_data_point list) = []) - ?aggregation_temporality:((aggregation_temporality:aggregation_temporality) = default_aggregation_temporality ()) - () : histogram = { - data_points; - aggregation_temporality; -} - -let rec default_exponential_histogram_data_point_buckets - ?offset:((offset:int32) = 0l) - ?bucket_counts:((bucket_counts:int64 list) = []) - () : exponential_histogram_data_point_buckets = { - offset; - bucket_counts; -} - -let rec default_exponential_histogram_data_point - ?attributes:((attributes:Common_types.key_value list) = []) - ?start_time_unix_nano:((start_time_unix_nano:int64) = 0L) - ?time_unix_nano:((time_unix_nano:int64) = 0L) - ?count:((count:int64) = 0L) - ?sum:((sum:float option) = None) - ?scale:((scale:int32) = 0l) - ?zero_count:((zero_count:int64) = 0L) - ?positive:((positive:exponential_histogram_data_point_buckets option) = None) - ?negative:((negative:exponential_histogram_data_point_buckets option) = None) - ?flags:((flags:int32) = 0l) - ?exemplars:((exemplars:exemplar list) = []) - ?min:((min:float option) = None) - ?max:((max:float option) = None) - ?zero_threshold:((zero_threshold:float) = 0.) - () : exponential_histogram_data_point = { - attributes; - start_time_unix_nano; - time_unix_nano; - count; - sum; - scale; - zero_count; - positive; - negative; - flags; - exemplars; - min; - max; - zero_threshold; -} - -let rec default_exponential_histogram - ?data_points:((data_points:exponential_histogram_data_point list) = []) - ?aggregation_temporality:((aggregation_temporality:aggregation_temporality) = default_aggregation_temporality ()) - () : exponential_histogram = { - data_points; - aggregation_temporality; -} - -let rec default_summary_data_point_value_at_quantile - ?quantile:((quantile:float) = 0.) - ?value:((value:float) = 0.) - () : summary_data_point_value_at_quantile = { - quantile; - value; -} - -let rec default_summary_data_point - ?attributes:((attributes:Common_types.key_value list) = []) - ?start_time_unix_nano:((start_time_unix_nano:int64) = 0L) - ?time_unix_nano:((time_unix_nano:int64) = 0L) - ?count:((count:int64) = 0L) - ?sum:((sum:float) = 0.) - ?quantile_values:((quantile_values:summary_data_point_value_at_quantile list) = []) - ?flags:((flags:int32) = 0l) - () : summary_data_point = { - attributes; - start_time_unix_nano; - time_unix_nano; - count; - sum; - quantile_values; - flags; -} - -let rec default_summary - ?data_points:((data_points:summary_data_point list) = []) - () : summary = { - data_points; -} - -let rec default_metric_data () : metric_data = Gauge (default_gauge ()) - -and default_metric - ?name:((name:string) = "") - ?description:((description:string) = "") - ?unit_:((unit_:string) = "") - ?data:((data:metric_data) = Gauge (default_gauge ())) - () : metric = { - name; - description; - unit_; - data; -} - -let rec default_scope_metrics - ?scope:((scope:Common_types.instrumentation_scope option) = None) - ?metrics:((metrics:metric list) = []) - ?schema_url:((schema_url:string) = "") - () : scope_metrics = { - scope; - metrics; - schema_url; -} - -let rec default_resource_metrics - ?resource:((resource:Resource_types.resource option) = None) - ?scope_metrics:((scope_metrics:scope_metrics list) = []) - ?schema_url:((schema_url:string) = "") - () : resource_metrics = { - resource; - scope_metrics; - schema_url; -} - -let rec default_metrics_data - ?resource_metrics:((resource_metrics:resource_metrics list) = []) - () : metrics_data = { - resource_metrics; -} - -let rec default_data_point_flags () = (Data_point_flags_do_not_use:data_point_flags) diff --git a/src/metrics_types.mli b/src/metrics_types.mli deleted file mode 100644 index 8cf43dbf..00000000 --- a/src/metrics_types.mli +++ /dev/null @@ -1,309 +0,0 @@ -(** metrics.proto Types *) - - - -(** {2 Types} *) - -type exemplar_value = - | As_double of float - | As_int of int64 - -and exemplar = { - filtered_attributes : Common_types.key_value list; - time_unix_nano : int64; - value : exemplar_value; - span_id : bytes; - trace_id : bytes; -} - -type number_data_point_value = - | As_double of float - | As_int of int64 - -and number_data_point = { - attributes : Common_types.key_value list; - start_time_unix_nano : int64; - time_unix_nano : int64; - value : number_data_point_value; - exemplars : exemplar list; - flags : int32; -} - -type gauge = { - data_points : number_data_point list; -} - -type aggregation_temporality = - | Aggregation_temporality_unspecified - | Aggregation_temporality_delta - | Aggregation_temporality_cumulative - -type sum = { - data_points : number_data_point list; - aggregation_temporality : aggregation_temporality; - is_monotonic : bool; -} - -type histogram_data_point = { - attributes : Common_types.key_value list; - start_time_unix_nano : int64; - time_unix_nano : int64; - count : int64; - sum : float option; - bucket_counts : int64 list; - explicit_bounds : float list; - exemplars : exemplar list; - flags : int32; - min : float option; - max : float option; -} - -type histogram = { - data_points : histogram_data_point list; - aggregation_temporality : aggregation_temporality; -} - -type exponential_histogram_data_point_buckets = { - offset : int32; - bucket_counts : int64 list; -} - -type exponential_histogram_data_point = { - attributes : Common_types.key_value list; - start_time_unix_nano : int64; - time_unix_nano : int64; - count : int64; - sum : float option; - scale : int32; - zero_count : int64; - positive : exponential_histogram_data_point_buckets option; - negative : exponential_histogram_data_point_buckets option; - flags : int32; - exemplars : exemplar list; - min : float option; - max : float option; - zero_threshold : float; -} - -type exponential_histogram = { - data_points : exponential_histogram_data_point list; - aggregation_temporality : aggregation_temporality; -} - -type summary_data_point_value_at_quantile = { - quantile : float; - value : float; -} - -type summary_data_point = { - attributes : Common_types.key_value list; - start_time_unix_nano : int64; - time_unix_nano : int64; - count : int64; - sum : float; - quantile_values : summary_data_point_value_at_quantile list; - flags : int32; -} - -type summary = { - data_points : summary_data_point list; -} - -type metric_data = - | Gauge of gauge - | Sum of sum - | Histogram of histogram - | Exponential_histogram of exponential_histogram - | Summary of summary - -and metric = { - name : string; - description : string; - unit_ : string; - data : metric_data; -} - -type scope_metrics = { - scope : Common_types.instrumentation_scope option; - metrics : metric list; - schema_url : string; -} - -type resource_metrics = { - resource : Resource_types.resource option; - scope_metrics : scope_metrics list; - schema_url : string; -} - -type metrics_data = { - resource_metrics : resource_metrics list; -} - -type data_point_flags = - | Data_point_flags_do_not_use - | Data_point_flags_no_recorded_value_mask - - -(** {2 Default values} *) - -val default_exemplar_value : unit -> exemplar_value -(** [default_exemplar_value ()] is the default value for type [exemplar_value] *) - -val default_exemplar : - ?filtered_attributes:Common_types.key_value list -> - ?time_unix_nano:int64 -> - ?value:exemplar_value -> - ?span_id:bytes -> - ?trace_id:bytes -> - unit -> - exemplar -(** [default_exemplar ()] is the default value for type [exemplar] *) - -val default_number_data_point_value : unit -> number_data_point_value -(** [default_number_data_point_value ()] is the default value for type [number_data_point_value] *) - -val default_number_data_point : - ?attributes:Common_types.key_value list -> - ?start_time_unix_nano:int64 -> - ?time_unix_nano:int64 -> - ?value:number_data_point_value -> - ?exemplars:exemplar list -> - ?flags:int32 -> - unit -> - number_data_point -(** [default_number_data_point ()] is the default value for type [number_data_point] *) - -val default_gauge : - ?data_points:number_data_point list -> - unit -> - gauge -(** [default_gauge ()] is the default value for type [gauge] *) - -val default_aggregation_temporality : unit -> aggregation_temporality -(** [default_aggregation_temporality ()] is the default value for type [aggregation_temporality] *) - -val default_sum : - ?data_points:number_data_point list -> - ?aggregation_temporality:aggregation_temporality -> - ?is_monotonic:bool -> - unit -> - sum -(** [default_sum ()] is the default value for type [sum] *) - -val default_histogram_data_point : - ?attributes:Common_types.key_value list -> - ?start_time_unix_nano:int64 -> - ?time_unix_nano:int64 -> - ?count:int64 -> - ?sum:float option -> - ?bucket_counts:int64 list -> - ?explicit_bounds:float list -> - ?exemplars:exemplar list -> - ?flags:int32 -> - ?min:float option -> - ?max:float option -> - unit -> - histogram_data_point -(** [default_histogram_data_point ()] is the default value for type [histogram_data_point] *) - -val default_histogram : - ?data_points:histogram_data_point list -> - ?aggregation_temporality:aggregation_temporality -> - unit -> - histogram -(** [default_histogram ()] is the default value for type [histogram] *) - -val default_exponential_histogram_data_point_buckets : - ?offset:int32 -> - ?bucket_counts:int64 list -> - unit -> - exponential_histogram_data_point_buckets -(** [default_exponential_histogram_data_point_buckets ()] is the default value for type [exponential_histogram_data_point_buckets] *) - -val default_exponential_histogram_data_point : - ?attributes:Common_types.key_value list -> - ?start_time_unix_nano:int64 -> - ?time_unix_nano:int64 -> - ?count:int64 -> - ?sum:float option -> - ?scale:int32 -> - ?zero_count:int64 -> - ?positive:exponential_histogram_data_point_buckets option -> - ?negative:exponential_histogram_data_point_buckets option -> - ?flags:int32 -> - ?exemplars:exemplar list -> - ?min:float option -> - ?max:float option -> - ?zero_threshold:float -> - unit -> - exponential_histogram_data_point -(** [default_exponential_histogram_data_point ()] is the default value for type [exponential_histogram_data_point] *) - -val default_exponential_histogram : - ?data_points:exponential_histogram_data_point list -> - ?aggregation_temporality:aggregation_temporality -> - unit -> - exponential_histogram -(** [default_exponential_histogram ()] is the default value for type [exponential_histogram] *) - -val default_summary_data_point_value_at_quantile : - ?quantile:float -> - ?value:float -> - unit -> - summary_data_point_value_at_quantile -(** [default_summary_data_point_value_at_quantile ()] is the default value for type [summary_data_point_value_at_quantile] *) - -val default_summary_data_point : - ?attributes:Common_types.key_value list -> - ?start_time_unix_nano:int64 -> - ?time_unix_nano:int64 -> - ?count:int64 -> - ?sum:float -> - ?quantile_values:summary_data_point_value_at_quantile list -> - ?flags:int32 -> - unit -> - summary_data_point -(** [default_summary_data_point ()] is the default value for type [summary_data_point] *) - -val default_summary : - ?data_points:summary_data_point list -> - unit -> - summary -(** [default_summary ()] is the default value for type [summary] *) - -val default_metric_data : unit -> metric_data -(** [default_metric_data ()] is the default value for type [metric_data] *) - -val default_metric : - ?name:string -> - ?description:string -> - ?unit_:string -> - ?data:metric_data -> - unit -> - metric -(** [default_metric ()] is the default value for type [metric] *) - -val default_scope_metrics : - ?scope:Common_types.instrumentation_scope option -> - ?metrics:metric list -> - ?schema_url:string -> - unit -> - scope_metrics -(** [default_scope_metrics ()] is the default value for type [scope_metrics] *) - -val default_resource_metrics : - ?resource:Resource_types.resource option -> - ?scope_metrics:scope_metrics list -> - ?schema_url:string -> - unit -> - resource_metrics -(** [default_resource_metrics ()] is the default value for type [resource_metrics] *) - -val default_metrics_data : - ?resource_metrics:resource_metrics list -> - unit -> - metrics_data -(** [default_metrics_data ()] is the default value for type [metrics_data] *) - -val default_data_point_flags : unit -> data_point_flags -(** [default_data_point_flags ()] is the default value for type [data_point_flags] *) diff --git a/src/resource_pb.ml b/src/resource_pb.ml deleted file mode 100644 index ac8a051f..00000000 --- a/src/resource_pb.ml +++ /dev/null @@ -1,46 +0,0 @@ -[@@@ocaml.warning "-27-30-39"] - -type resource_mutable = { - mutable attributes : Common_types.key_value list; - mutable dropped_attributes_count : int32; -} - -let default_resource_mutable () : resource_mutable = { - attributes = []; - dropped_attributes_count = 0l; -} - - -let rec decode_resource d = - let v = default_resource_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.attributes <- List.rev v.attributes; - ); continue__ := false - | Some (1, Pbrt.Bytes) -> begin - v.attributes <- (Common_pb.decode_key_value (Pbrt.Decoder.nested d)) :: v.attributes; - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(resource), field(1)" pk - | Some (2, Pbrt.Varint) -> begin - v.dropped_attributes_count <- Pbrt.Decoder.int32_as_varint d; - end - | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(resource), field(2)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Resource_types.attributes = v.attributes; - Resource_types.dropped_attributes_count = v.dropped_attributes_count; - } : Resource_types.resource) - -let rec encode_resource (v:Resource_types.resource) encoder = - List.iter (fun x -> - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (Common_pb.encode_key_value x) encoder; - ) v.Resource_types.attributes; - Pbrt.Encoder.key (2, Pbrt.Varint) encoder; - Pbrt.Encoder.int32_as_varint v.Resource_types.dropped_attributes_count encoder; - () diff --git a/src/resource_pb.mli b/src/resource_pb.mli deleted file mode 100644 index 81136cbe..00000000 --- a/src/resource_pb.mli +++ /dev/null @@ -1,13 +0,0 @@ -(** resource.proto Binary Encoding *) - - -(** {2 Protobuf Encoding} *) - -val encode_resource : Resource_types.resource -> Pbrt.Encoder.t -> unit -(** [encode_resource v encoder] encodes [v] with the given [encoder] *) - - -(** {2 Protobuf Decoding} *) - -val decode_resource : Pbrt.Decoder.t -> Resource_types.resource -(** [decode_resource decoder] decodes a [resource] value from [decoder] *) diff --git a/src/resource_pp.ml b/src/resource_pp.ml deleted file mode 100644 index 299fcdfc..00000000 --- a/src/resource_pp.ml +++ /dev/null @@ -1,8 +0,0 @@ -[@@@ocaml.warning "-27-30-39"] - -let rec pp_resource fmt (v:Resource_types.resource) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "attributes" (Pbrt.Pp.pp_list Common_pp.pp_key_value) fmt v.Resource_types.attributes; - Pbrt.Pp.pp_record_field ~first:false "dropped_attributes_count" Pbrt.Pp.pp_int32 fmt v.Resource_types.dropped_attributes_count; - in - Pbrt.Pp.pp_brk pp_i fmt () diff --git a/src/resource_pp.mli b/src/resource_pp.mli deleted file mode 100644 index 60d1f43a..00000000 --- a/src/resource_pp.mli +++ /dev/null @@ -1,7 +0,0 @@ -(** resource.proto Pretty Printing *) - - -(** {2 Formatters} *) - -val pp_resource : Format.formatter -> Resource_types.resource -> unit -(** [pp_resource v] formats v *) diff --git a/src/resource_types.ml b/src/resource_types.ml deleted file mode 100644 index 74b42266..00000000 --- a/src/resource_types.ml +++ /dev/null @@ -1,15 +0,0 @@ -[@@@ocaml.warning "-27-30-39"] - - -type resource = { - attributes : Common_types.key_value list; - dropped_attributes_count : int32; -} - -let rec default_resource - ?attributes:((attributes:Common_types.key_value list) = []) - ?dropped_attributes_count:((dropped_attributes_count:int32) = 0l) - () : resource = { - attributes; - dropped_attributes_count; -} diff --git a/src/resource_types.mli b/src/resource_types.mli deleted file mode 100644 index ff01acd2..00000000 --- a/src/resource_types.mli +++ /dev/null @@ -1,20 +0,0 @@ -(** resource.proto Types *) - - - -(** {2 Types} *) - -type resource = { - attributes : Common_types.key_value list; - dropped_attributes_count : int32; -} - - -(** {2 Default values} *) - -val default_resource : - ?attributes:Common_types.key_value list -> - ?dropped_attributes_count:int32 -> - unit -> - resource -(** [default_resource ()] is the default value for type [resource] *) diff --git a/src/status.proto b/src/status.proto deleted file mode 100644 index 9812db51..00000000 --- a/src/status.proto +++ /dev/null @@ -1,10 +0,0 @@ - -syntax = "proto3"; - -// from https://pkg.go.dev/google.golang.org/genproto/googleapis/rpc/status?utm_source=godoc#Status - -message Status { - int32 code = 1; - bytes message = 2; - repeated bytes details = 3; -} diff --git a/src/status_pb.ml b/src/status_pb.ml deleted file mode 100644 index 3fba0000..00000000 --- a/src/status_pb.ml +++ /dev/null @@ -1,56 +0,0 @@ -[@@@ocaml.warning "-27-30-39"] - -type status_mutable = { - mutable code : int32; - mutable message : bytes; - mutable details : bytes list; -} - -let default_status_mutable () : status_mutable = { - code = 0l; - message = Bytes.create 0; - details = []; -} - - -let rec decode_status d = - let v = default_status_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.details <- List.rev v.details; - ); continue__ := false - | Some (1, Pbrt.Varint) -> begin - v.code <- Pbrt.Decoder.int32_as_varint d; - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(status), field(1)" pk - | Some (2, Pbrt.Bytes) -> begin - v.message <- Pbrt.Decoder.bytes d; - end - | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(status), field(2)" pk - | Some (3, Pbrt.Bytes) -> begin - v.details <- (Pbrt.Decoder.bytes d) :: v.details; - end - | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(status), field(3)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Status_types.code = v.code; - Status_types.message = v.message; - Status_types.details = v.details; - } : Status_types.status) - -let rec encode_status (v:Status_types.status) encoder = - Pbrt.Encoder.key (1, Pbrt.Varint) encoder; - Pbrt.Encoder.int32_as_varint v.Status_types.code encoder; - Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; - Pbrt.Encoder.bytes v.Status_types.message encoder; - List.iter (fun x -> - Pbrt.Encoder.key (3, Pbrt.Bytes) encoder; - Pbrt.Encoder.bytes x encoder; - ) v.Status_types.details; - () diff --git a/src/status_pb.mli b/src/status_pb.mli deleted file mode 100644 index e6bcfaed..00000000 --- a/src/status_pb.mli +++ /dev/null @@ -1,13 +0,0 @@ -(** status.proto Binary Encoding *) - - -(** {2 Protobuf Encoding} *) - -val encode_status : Status_types.status -> Pbrt.Encoder.t -> unit -(** [encode_status v encoder] encodes [v] with the given [encoder] *) - - -(** {2 Protobuf Decoding} *) - -val decode_status : Pbrt.Decoder.t -> Status_types.status -(** [decode_status decoder] decodes a [status] value from [decoder] *) diff --git a/src/status_pp.ml b/src/status_pp.ml deleted file mode 100644 index c5df29d9..00000000 --- a/src/status_pp.ml +++ /dev/null @@ -1,9 +0,0 @@ -[@@@ocaml.warning "-27-30-39"] - -let rec pp_status fmt (v:Status_types.status) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "code" Pbrt.Pp.pp_int32 fmt v.Status_types.code; - Pbrt.Pp.pp_record_field ~first:false "message" Pbrt.Pp.pp_bytes fmt v.Status_types.message; - Pbrt.Pp.pp_record_field ~first:false "details" (Pbrt.Pp.pp_list Pbrt.Pp.pp_bytes) fmt v.Status_types.details; - in - Pbrt.Pp.pp_brk pp_i fmt () diff --git a/src/status_pp.mli b/src/status_pp.mli deleted file mode 100644 index cb19e3bd..00000000 --- a/src/status_pp.mli +++ /dev/null @@ -1,7 +0,0 @@ -(** status.proto Pretty Printing *) - - -(** {2 Formatters} *) - -val pp_status : Format.formatter -> Status_types.status -> unit -(** [pp_status v] formats v *) diff --git a/src/status_types.ml b/src/status_types.ml deleted file mode 100644 index 14af622b..00000000 --- a/src/status_types.ml +++ /dev/null @@ -1,18 +0,0 @@ -[@@@ocaml.warning "-27-30-39"] - - -type status = { - code : int32; - message : bytes; - details : bytes list; -} - -let rec default_status - ?code:((code:int32) = 0l) - ?message:((message:bytes) = Bytes.create 0) - ?details:((details:bytes list) = []) - () : status = { - code; - message; - details; -} diff --git a/src/status_types.mli b/src/status_types.mli deleted file mode 100644 index 9947bc58..00000000 --- a/src/status_types.mli +++ /dev/null @@ -1,22 +0,0 @@ -(** status.proto Types *) - - - -(** {2 Types} *) - -type status = { - code : int32; - message : bytes; - details : bytes list; -} - - -(** {2 Default values} *) - -val default_status : - ?code:int32 -> - ?message:bytes -> - ?details:bytes list -> - unit -> - status -(** [default_status ()] is the default value for type [status] *) diff --git a/src/trace_pb.ml b/src/trace_pb.ml deleted file mode 100644 index 1d2acfd9..00000000 --- a/src/trace_pb.ml +++ /dev/null @@ -1,547 +0,0 @@ -[@@@ocaml.warning "-27-30-39"] - -type span_event_mutable = { - mutable time_unix_nano : int64; - mutable name : string; - mutable attributes : Common_types.key_value list; - mutable dropped_attributes_count : int32; -} - -let default_span_event_mutable () : span_event_mutable = { - time_unix_nano = 0L; - name = ""; - attributes = []; - dropped_attributes_count = 0l; -} - -type span_link_mutable = { - mutable trace_id : bytes; - mutable span_id : bytes; - mutable trace_state : string; - mutable attributes : Common_types.key_value list; - mutable dropped_attributes_count : int32; -} - -let default_span_link_mutable () : span_link_mutable = { - trace_id = Bytes.create 0; - span_id = Bytes.create 0; - trace_state = ""; - attributes = []; - dropped_attributes_count = 0l; -} - -type status_mutable = { - mutable message : string; - mutable code : Trace_types.status_status_code; -} - -let default_status_mutable () : status_mutable = { - message = ""; - code = Trace_types.default_status_status_code (); -} - -type span_mutable = { - mutable trace_id : bytes; - mutable span_id : bytes; - mutable trace_state : string; - mutable parent_span_id : bytes; - mutable name : string; - mutable kind : Trace_types.span_span_kind; - mutable start_time_unix_nano : int64; - mutable end_time_unix_nano : int64; - mutable attributes : Common_types.key_value list; - mutable dropped_attributes_count : int32; - mutable events : Trace_types.span_event list; - mutable dropped_events_count : int32; - mutable links : Trace_types.span_link list; - mutable dropped_links_count : int32; - mutable status : Trace_types.status option; -} - -let default_span_mutable () : span_mutable = { - trace_id = Bytes.create 0; - span_id = Bytes.create 0; - trace_state = ""; - parent_span_id = Bytes.create 0; - name = ""; - kind = Trace_types.default_span_span_kind (); - start_time_unix_nano = 0L; - end_time_unix_nano = 0L; - attributes = []; - dropped_attributes_count = 0l; - events = []; - dropped_events_count = 0l; - links = []; - dropped_links_count = 0l; - status = None; -} - -type scope_spans_mutable = { - mutable scope : Common_types.instrumentation_scope option; - mutable spans : Trace_types.span list; - mutable schema_url : string; -} - -let default_scope_spans_mutable () : scope_spans_mutable = { - scope = None; - spans = []; - schema_url = ""; -} - -type resource_spans_mutable = { - mutable resource : Resource_types.resource option; - mutable scope_spans : Trace_types.scope_spans list; - mutable schema_url : string; -} - -let default_resource_spans_mutable () : resource_spans_mutable = { - resource = None; - scope_spans = []; - schema_url = ""; -} - -type traces_data_mutable = { - mutable resource_spans : Trace_types.resource_spans list; -} - -let default_traces_data_mutable () : traces_data_mutable = { - resource_spans = []; -} - - -let rec decode_span_span_kind d = - match Pbrt.Decoder.int_as_varint d with - | 0 -> (Trace_types.Span_kind_unspecified:Trace_types.span_span_kind) - | 1 -> (Trace_types.Span_kind_internal:Trace_types.span_span_kind) - | 2 -> (Trace_types.Span_kind_server:Trace_types.span_span_kind) - | 3 -> (Trace_types.Span_kind_client:Trace_types.span_span_kind) - | 4 -> (Trace_types.Span_kind_producer:Trace_types.span_span_kind) - | 5 -> (Trace_types.Span_kind_consumer:Trace_types.span_span_kind) - | _ -> Pbrt.Decoder.malformed_variant "span_span_kind" - -let rec decode_span_event d = - let v = default_span_event_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.attributes <- List.rev v.attributes; - ); continue__ := false - | Some (1, Pbrt.Bits64) -> begin - v.time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span_event), field(1)" pk - | Some (2, Pbrt.Bytes) -> begin - v.name <- Pbrt.Decoder.string d; - end - | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span_event), field(2)" pk - | Some (3, Pbrt.Bytes) -> begin - v.attributes <- (Common_pb.decode_key_value (Pbrt.Decoder.nested d)) :: v.attributes; - end - | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span_event), field(3)" pk - | Some (4, Pbrt.Varint) -> begin - v.dropped_attributes_count <- Pbrt.Decoder.int32_as_varint d; - end - | Some (4, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span_event), field(4)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Trace_types.time_unix_nano = v.time_unix_nano; - Trace_types.name = v.name; - Trace_types.attributes = v.attributes; - Trace_types.dropped_attributes_count = v.dropped_attributes_count; - } : Trace_types.span_event) - -let rec decode_span_link d = - let v = default_span_link_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.attributes <- List.rev v.attributes; - ); continue__ := false - | Some (1, Pbrt.Bytes) -> begin - v.trace_id <- Pbrt.Decoder.bytes d; - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span_link), field(1)" pk - | Some (2, Pbrt.Bytes) -> begin - v.span_id <- Pbrt.Decoder.bytes d; - end - | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span_link), field(2)" pk - | Some (3, Pbrt.Bytes) -> begin - v.trace_state <- Pbrt.Decoder.string d; - end - | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span_link), field(3)" pk - | Some (4, Pbrt.Bytes) -> begin - v.attributes <- (Common_pb.decode_key_value (Pbrt.Decoder.nested d)) :: v.attributes; - end - | Some (4, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span_link), field(4)" pk - | Some (5, Pbrt.Varint) -> begin - v.dropped_attributes_count <- Pbrt.Decoder.int32_as_varint d; - end - | Some (5, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span_link), field(5)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Trace_types.trace_id = v.trace_id; - Trace_types.span_id = v.span_id; - Trace_types.trace_state = v.trace_state; - Trace_types.attributes = v.attributes; - Trace_types.dropped_attributes_count = v.dropped_attributes_count; - } : Trace_types.span_link) - -let rec decode_status_status_code d = - match Pbrt.Decoder.int_as_varint d with - | 0 -> (Trace_types.Status_code_unset:Trace_types.status_status_code) - | 1 -> (Trace_types.Status_code_ok:Trace_types.status_status_code) - | 2 -> (Trace_types.Status_code_error:Trace_types.status_status_code) - | _ -> Pbrt.Decoder.malformed_variant "status_status_code" - -let rec decode_status d = - let v = default_status_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - ); continue__ := false - | Some (2, Pbrt.Bytes) -> begin - v.message <- Pbrt.Decoder.string d; - end - | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(status), field(2)" pk - | Some (3, Pbrt.Varint) -> begin - v.code <- decode_status_status_code d; - end - | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(status), field(3)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Trace_types.message = v.message; - Trace_types.code = v.code; - } : Trace_types.status) - -let rec decode_span d = - let v = default_span_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.links <- List.rev v.links; - v.events <- List.rev v.events; - v.attributes <- List.rev v.attributes; - ); continue__ := false - | Some (1, Pbrt.Bytes) -> begin - v.trace_id <- Pbrt.Decoder.bytes d; - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span), field(1)" pk - | Some (2, Pbrt.Bytes) -> begin - v.span_id <- Pbrt.Decoder.bytes d; - end - | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span), field(2)" pk - | Some (3, Pbrt.Bytes) -> begin - v.trace_state <- Pbrt.Decoder.string d; - end - | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span), field(3)" pk - | Some (4, Pbrt.Bytes) -> begin - v.parent_span_id <- Pbrt.Decoder.bytes d; - end - | Some (4, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span), field(4)" pk - | Some (5, Pbrt.Bytes) -> begin - v.name <- Pbrt.Decoder.string d; - end - | Some (5, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span), field(5)" pk - | Some (6, Pbrt.Varint) -> begin - v.kind <- decode_span_span_kind d; - end - | Some (6, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span), field(6)" pk - | Some (7, Pbrt.Bits64) -> begin - v.start_time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; - end - | Some (7, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span), field(7)" pk - | Some (8, Pbrt.Bits64) -> begin - v.end_time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; - end - | Some (8, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span), field(8)" pk - | Some (9, Pbrt.Bytes) -> begin - v.attributes <- (Common_pb.decode_key_value (Pbrt.Decoder.nested d)) :: v.attributes; - end - | Some (9, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span), field(9)" pk - | Some (10, Pbrt.Varint) -> begin - v.dropped_attributes_count <- Pbrt.Decoder.int32_as_varint d; - end - | Some (10, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span), field(10)" pk - | Some (11, Pbrt.Bytes) -> begin - v.events <- (decode_span_event (Pbrt.Decoder.nested d)) :: v.events; - end - | Some (11, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span), field(11)" pk - | Some (12, Pbrt.Varint) -> begin - v.dropped_events_count <- Pbrt.Decoder.int32_as_varint d; - end - | Some (12, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span), field(12)" pk - | Some (13, Pbrt.Bytes) -> begin - v.links <- (decode_span_link (Pbrt.Decoder.nested d)) :: v.links; - end - | Some (13, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span), field(13)" pk - | Some (14, Pbrt.Varint) -> begin - v.dropped_links_count <- Pbrt.Decoder.int32_as_varint d; - end - | Some (14, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span), field(14)" pk - | Some (15, Pbrt.Bytes) -> begin - v.status <- Some (decode_status (Pbrt.Decoder.nested d)); - end - | Some (15, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span), field(15)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Trace_types.trace_id = v.trace_id; - Trace_types.span_id = v.span_id; - Trace_types.trace_state = v.trace_state; - Trace_types.parent_span_id = v.parent_span_id; - Trace_types.name = v.name; - Trace_types.kind = v.kind; - Trace_types.start_time_unix_nano = v.start_time_unix_nano; - Trace_types.end_time_unix_nano = v.end_time_unix_nano; - Trace_types.attributes = v.attributes; - Trace_types.dropped_attributes_count = v.dropped_attributes_count; - Trace_types.events = v.events; - Trace_types.dropped_events_count = v.dropped_events_count; - Trace_types.links = v.links; - Trace_types.dropped_links_count = v.dropped_links_count; - Trace_types.status = v.status; - } : Trace_types.span) - -let rec decode_scope_spans d = - let v = default_scope_spans_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.spans <- List.rev v.spans; - ); continue__ := false - | Some (1, Pbrt.Bytes) -> begin - v.scope <- Some (Common_pb.decode_instrumentation_scope (Pbrt.Decoder.nested d)); - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(scope_spans), field(1)" pk - | Some (2, Pbrt.Bytes) -> begin - v.spans <- (decode_span (Pbrt.Decoder.nested d)) :: v.spans; - end - | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(scope_spans), field(2)" pk - | Some (3, Pbrt.Bytes) -> begin - v.schema_url <- Pbrt.Decoder.string d; - end - | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(scope_spans), field(3)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Trace_types.scope = v.scope; - Trace_types.spans = v.spans; - Trace_types.schema_url = v.schema_url; - } : Trace_types.scope_spans) - -let rec decode_resource_spans d = - let v = default_resource_spans_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.scope_spans <- List.rev v.scope_spans; - ); continue__ := false - | Some (1, Pbrt.Bytes) -> begin - v.resource <- Some (Resource_pb.decode_resource (Pbrt.Decoder.nested d)); - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(resource_spans), field(1)" pk - | Some (2, Pbrt.Bytes) -> begin - v.scope_spans <- (decode_scope_spans (Pbrt.Decoder.nested d)) :: v.scope_spans; - end - | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(resource_spans), field(2)" pk - | Some (3, Pbrt.Bytes) -> begin - v.schema_url <- Pbrt.Decoder.string d; - end - | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(resource_spans), field(3)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Trace_types.resource = v.resource; - Trace_types.scope_spans = v.scope_spans; - Trace_types.schema_url = v.schema_url; - } : Trace_types.resource_spans) - -let rec decode_traces_data d = - let v = default_traces_data_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.resource_spans <- List.rev v.resource_spans; - ); continue__ := false - | Some (1, Pbrt.Bytes) -> begin - v.resource_spans <- (decode_resource_spans (Pbrt.Decoder.nested d)) :: v.resource_spans; - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(traces_data), field(1)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Trace_types.resource_spans = v.resource_spans; - } : Trace_types.traces_data) - -let rec encode_span_span_kind (v:Trace_types.span_span_kind) encoder = - match v with - | Trace_types.Span_kind_unspecified -> Pbrt.Encoder.int_as_varint (0) encoder - | Trace_types.Span_kind_internal -> Pbrt.Encoder.int_as_varint 1 encoder - | Trace_types.Span_kind_server -> Pbrt.Encoder.int_as_varint 2 encoder - | Trace_types.Span_kind_client -> Pbrt.Encoder.int_as_varint 3 encoder - | Trace_types.Span_kind_producer -> Pbrt.Encoder.int_as_varint 4 encoder - | Trace_types.Span_kind_consumer -> Pbrt.Encoder.int_as_varint 5 encoder - -let rec encode_span_event (v:Trace_types.span_event) encoder = - Pbrt.Encoder.key (1, Pbrt.Bits64) encoder; - Pbrt.Encoder.int64_as_bits64 v.Trace_types.time_unix_nano encoder; - Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; - Pbrt.Encoder.string v.Trace_types.name encoder; - List.iter (fun x -> - Pbrt.Encoder.key (3, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (Common_pb.encode_key_value x) encoder; - ) v.Trace_types.attributes; - Pbrt.Encoder.key (4, Pbrt.Varint) encoder; - Pbrt.Encoder.int32_as_varint v.Trace_types.dropped_attributes_count encoder; - () - -let rec encode_span_link (v:Trace_types.span_link) encoder = - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.bytes v.Trace_types.trace_id encoder; - Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; - Pbrt.Encoder.bytes v.Trace_types.span_id encoder; - Pbrt.Encoder.key (3, Pbrt.Bytes) encoder; - Pbrt.Encoder.string v.Trace_types.trace_state encoder; - List.iter (fun x -> - Pbrt.Encoder.key (4, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (Common_pb.encode_key_value x) encoder; - ) v.Trace_types.attributes; - Pbrt.Encoder.key (5, Pbrt.Varint) encoder; - Pbrt.Encoder.int32_as_varint v.Trace_types.dropped_attributes_count encoder; - () - -let rec encode_status_status_code (v:Trace_types.status_status_code) encoder = - match v with - | Trace_types.Status_code_unset -> Pbrt.Encoder.int_as_varint (0) encoder - | Trace_types.Status_code_ok -> Pbrt.Encoder.int_as_varint 1 encoder - | Trace_types.Status_code_error -> Pbrt.Encoder.int_as_varint 2 encoder - -let rec encode_status (v:Trace_types.status) encoder = - Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; - Pbrt.Encoder.string v.Trace_types.message encoder; - Pbrt.Encoder.key (3, Pbrt.Varint) encoder; - encode_status_status_code v.Trace_types.code encoder; - () - -let rec encode_span (v:Trace_types.span) encoder = - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.bytes v.Trace_types.trace_id encoder; - Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; - Pbrt.Encoder.bytes v.Trace_types.span_id encoder; - Pbrt.Encoder.key (3, Pbrt.Bytes) encoder; - Pbrt.Encoder.string v.Trace_types.trace_state encoder; - Pbrt.Encoder.key (4, Pbrt.Bytes) encoder; - Pbrt.Encoder.bytes v.Trace_types.parent_span_id encoder; - Pbrt.Encoder.key (5, Pbrt.Bytes) encoder; - Pbrt.Encoder.string v.Trace_types.name encoder; - Pbrt.Encoder.key (6, Pbrt.Varint) encoder; - encode_span_span_kind v.Trace_types.kind encoder; - Pbrt.Encoder.key (7, Pbrt.Bits64) encoder; - Pbrt.Encoder.int64_as_bits64 v.Trace_types.start_time_unix_nano encoder; - Pbrt.Encoder.key (8, Pbrt.Bits64) encoder; - Pbrt.Encoder.int64_as_bits64 v.Trace_types.end_time_unix_nano encoder; - List.iter (fun x -> - Pbrt.Encoder.key (9, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (Common_pb.encode_key_value x) encoder; - ) v.Trace_types.attributes; - Pbrt.Encoder.key (10, Pbrt.Varint) encoder; - Pbrt.Encoder.int32_as_varint v.Trace_types.dropped_attributes_count encoder; - List.iter (fun x -> - Pbrt.Encoder.key (11, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_span_event x) encoder; - ) v.Trace_types.events; - Pbrt.Encoder.key (12, Pbrt.Varint) encoder; - Pbrt.Encoder.int32_as_varint v.Trace_types.dropped_events_count encoder; - List.iter (fun x -> - Pbrt.Encoder.key (13, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_span_link x) encoder; - ) v.Trace_types.links; - Pbrt.Encoder.key (14, Pbrt.Varint) encoder; - Pbrt.Encoder.int32_as_varint v.Trace_types.dropped_links_count encoder; - begin match v.Trace_types.status with - | Some x -> - Pbrt.Encoder.key (15, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_status x) encoder; - | None -> (); - end; - () - -let rec encode_scope_spans (v:Trace_types.scope_spans) encoder = - begin match v.Trace_types.scope with - | Some x -> - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (Common_pb.encode_instrumentation_scope x) encoder; - | None -> (); - end; - List.iter (fun x -> - Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_span x) encoder; - ) v.Trace_types.spans; - Pbrt.Encoder.key (3, Pbrt.Bytes) encoder; - Pbrt.Encoder.string v.Trace_types.schema_url encoder; - () - -let rec encode_resource_spans (v:Trace_types.resource_spans) encoder = - begin match v.Trace_types.resource with - | Some x -> - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (Resource_pb.encode_resource x) encoder; - | None -> (); - end; - List.iter (fun x -> - Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_scope_spans x) encoder; - ) v.Trace_types.scope_spans; - Pbrt.Encoder.key (3, Pbrt.Bytes) encoder; - Pbrt.Encoder.string v.Trace_types.schema_url encoder; - () - -let rec encode_traces_data (v:Trace_types.traces_data) encoder = - List.iter (fun x -> - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_resource_spans x) encoder; - ) v.Trace_types.resource_spans; - () diff --git a/src/trace_pb.mli b/src/trace_pb.mli deleted file mode 100644 index 8e93dba6..00000000 --- a/src/trace_pb.mli +++ /dev/null @@ -1,61 +0,0 @@ -(** trace.proto Binary Encoding *) - - -(** {2 Protobuf Encoding} *) - -val encode_span_span_kind : Trace_types.span_span_kind -> Pbrt.Encoder.t -> unit -(** [encode_span_span_kind v encoder] encodes [v] with the given [encoder] *) - -val encode_span_event : Trace_types.span_event -> Pbrt.Encoder.t -> unit -(** [encode_span_event v encoder] encodes [v] with the given [encoder] *) - -val encode_span_link : Trace_types.span_link -> Pbrt.Encoder.t -> unit -(** [encode_span_link v encoder] encodes [v] with the given [encoder] *) - -val encode_status_status_code : Trace_types.status_status_code -> Pbrt.Encoder.t -> unit -(** [encode_status_status_code v encoder] encodes [v] with the given [encoder] *) - -val encode_status : Trace_types.status -> Pbrt.Encoder.t -> unit -(** [encode_status v encoder] encodes [v] with the given [encoder] *) - -val encode_span : Trace_types.span -> Pbrt.Encoder.t -> unit -(** [encode_span v encoder] encodes [v] with the given [encoder] *) - -val encode_scope_spans : Trace_types.scope_spans -> Pbrt.Encoder.t -> unit -(** [encode_scope_spans v encoder] encodes [v] with the given [encoder] *) - -val encode_resource_spans : Trace_types.resource_spans -> Pbrt.Encoder.t -> unit -(** [encode_resource_spans v encoder] encodes [v] with the given [encoder] *) - -val encode_traces_data : Trace_types.traces_data -> Pbrt.Encoder.t -> unit -(** [encode_traces_data v encoder] encodes [v] with the given [encoder] *) - - -(** {2 Protobuf Decoding} *) - -val decode_span_span_kind : Pbrt.Decoder.t -> Trace_types.span_span_kind -(** [decode_span_span_kind decoder] decodes a [span_span_kind] value from [decoder] *) - -val decode_span_event : Pbrt.Decoder.t -> Trace_types.span_event -(** [decode_span_event decoder] decodes a [span_event] value from [decoder] *) - -val decode_span_link : Pbrt.Decoder.t -> Trace_types.span_link -(** [decode_span_link decoder] decodes a [span_link] value from [decoder] *) - -val decode_status_status_code : Pbrt.Decoder.t -> Trace_types.status_status_code -(** [decode_status_status_code decoder] decodes a [status_status_code] value from [decoder] *) - -val decode_status : Pbrt.Decoder.t -> Trace_types.status -(** [decode_status decoder] decodes a [status] value from [decoder] *) - -val decode_span : Pbrt.Decoder.t -> Trace_types.span -(** [decode_span decoder] decodes a [span] value from [decoder] *) - -val decode_scope_spans : Pbrt.Decoder.t -> Trace_types.scope_spans -(** [decode_scope_spans decoder] decodes a [scope_spans] value from [decoder] *) - -val decode_resource_spans : Pbrt.Decoder.t -> Trace_types.resource_spans -(** [decode_resource_spans decoder] decodes a [resource_spans] value from [decoder] *) - -val decode_traces_data : Pbrt.Decoder.t -> Trace_types.traces_data -(** [decode_traces_data decoder] decodes a [traces_data] value from [decoder] *) diff --git a/src/trace_pp.ml b/src/trace_pp.ml deleted file mode 100644 index 97faa78b..00000000 --- a/src/trace_pp.ml +++ /dev/null @@ -1,84 +0,0 @@ -[@@@ocaml.warning "-27-30-39"] - -let rec pp_span_span_kind fmt (v:Trace_types.span_span_kind) = - match v with - | Trace_types.Span_kind_unspecified -> Format.fprintf fmt "Span_kind_unspecified" - | Trace_types.Span_kind_internal -> Format.fprintf fmt "Span_kind_internal" - | Trace_types.Span_kind_server -> Format.fprintf fmt "Span_kind_server" - | Trace_types.Span_kind_client -> Format.fprintf fmt "Span_kind_client" - | Trace_types.Span_kind_producer -> Format.fprintf fmt "Span_kind_producer" - | Trace_types.Span_kind_consumer -> Format.fprintf fmt "Span_kind_consumer" - -let rec pp_span_event fmt (v:Trace_types.span_event) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Trace_types.time_unix_nano; - Pbrt.Pp.pp_record_field ~first:false "name" Pbrt.Pp.pp_string fmt v.Trace_types.name; - Pbrt.Pp.pp_record_field ~first:false "attributes" (Pbrt.Pp.pp_list Common_pp.pp_key_value) fmt v.Trace_types.attributes; - Pbrt.Pp.pp_record_field ~first:false "dropped_attributes_count" Pbrt.Pp.pp_int32 fmt v.Trace_types.dropped_attributes_count; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_span_link fmt (v:Trace_types.span_link) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "trace_id" Pbrt.Pp.pp_bytes fmt v.Trace_types.trace_id; - Pbrt.Pp.pp_record_field ~first:false "span_id" Pbrt.Pp.pp_bytes fmt v.Trace_types.span_id; - Pbrt.Pp.pp_record_field ~first:false "trace_state" Pbrt.Pp.pp_string fmt v.Trace_types.trace_state; - Pbrt.Pp.pp_record_field ~first:false "attributes" (Pbrt.Pp.pp_list Common_pp.pp_key_value) fmt v.Trace_types.attributes; - Pbrt.Pp.pp_record_field ~first:false "dropped_attributes_count" Pbrt.Pp.pp_int32 fmt v.Trace_types.dropped_attributes_count; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_status_status_code fmt (v:Trace_types.status_status_code) = - match v with - | Trace_types.Status_code_unset -> Format.fprintf fmt "Status_code_unset" - | Trace_types.Status_code_ok -> Format.fprintf fmt "Status_code_ok" - | Trace_types.Status_code_error -> Format.fprintf fmt "Status_code_error" - -let rec pp_status fmt (v:Trace_types.status) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "message" Pbrt.Pp.pp_string fmt v.Trace_types.message; - Pbrt.Pp.pp_record_field ~first:false "code" pp_status_status_code fmt v.Trace_types.code; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_span fmt (v:Trace_types.span) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "trace_id" Pbrt.Pp.pp_bytes fmt v.Trace_types.trace_id; - Pbrt.Pp.pp_record_field ~first:false "span_id" Pbrt.Pp.pp_bytes fmt v.Trace_types.span_id; - Pbrt.Pp.pp_record_field ~first:false "trace_state" Pbrt.Pp.pp_string fmt v.Trace_types.trace_state; - Pbrt.Pp.pp_record_field ~first:false "parent_span_id" Pbrt.Pp.pp_bytes fmt v.Trace_types.parent_span_id; - Pbrt.Pp.pp_record_field ~first:false "name" Pbrt.Pp.pp_string fmt v.Trace_types.name; - Pbrt.Pp.pp_record_field ~first:false "kind" pp_span_span_kind fmt v.Trace_types.kind; - Pbrt.Pp.pp_record_field ~first:false "start_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Trace_types.start_time_unix_nano; - Pbrt.Pp.pp_record_field ~first:false "end_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Trace_types.end_time_unix_nano; - Pbrt.Pp.pp_record_field ~first:false "attributes" (Pbrt.Pp.pp_list Common_pp.pp_key_value) fmt v.Trace_types.attributes; - Pbrt.Pp.pp_record_field ~first:false "dropped_attributes_count" Pbrt.Pp.pp_int32 fmt v.Trace_types.dropped_attributes_count; - Pbrt.Pp.pp_record_field ~first:false "events" (Pbrt.Pp.pp_list pp_span_event) fmt v.Trace_types.events; - Pbrt.Pp.pp_record_field ~first:false "dropped_events_count" Pbrt.Pp.pp_int32 fmt v.Trace_types.dropped_events_count; - Pbrt.Pp.pp_record_field ~first:false "links" (Pbrt.Pp.pp_list pp_span_link) fmt v.Trace_types.links; - Pbrt.Pp.pp_record_field ~first:false "dropped_links_count" Pbrt.Pp.pp_int32 fmt v.Trace_types.dropped_links_count; - Pbrt.Pp.pp_record_field ~first:false "status" (Pbrt.Pp.pp_option pp_status) fmt v.Trace_types.status; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_scope_spans fmt (v:Trace_types.scope_spans) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "scope" (Pbrt.Pp.pp_option Common_pp.pp_instrumentation_scope) fmt v.Trace_types.scope; - Pbrt.Pp.pp_record_field ~first:false "spans" (Pbrt.Pp.pp_list pp_span) fmt v.Trace_types.spans; - Pbrt.Pp.pp_record_field ~first:false "schema_url" Pbrt.Pp.pp_string fmt v.Trace_types.schema_url; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_resource_spans fmt (v:Trace_types.resource_spans) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "resource" (Pbrt.Pp.pp_option Resource_pp.pp_resource) fmt v.Trace_types.resource; - Pbrt.Pp.pp_record_field ~first:false "scope_spans" (Pbrt.Pp.pp_list pp_scope_spans) fmt v.Trace_types.scope_spans; - Pbrt.Pp.pp_record_field ~first:false "schema_url" Pbrt.Pp.pp_string fmt v.Trace_types.schema_url; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_traces_data fmt (v:Trace_types.traces_data) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "resource_spans" (Pbrt.Pp.pp_list pp_resource_spans) fmt v.Trace_types.resource_spans; - in - Pbrt.Pp.pp_brk pp_i fmt () diff --git a/src/trace_pp.mli b/src/trace_pp.mli deleted file mode 100644 index 047f5207..00000000 --- a/src/trace_pp.mli +++ /dev/null @@ -1,31 +0,0 @@ -(** trace.proto Pretty Printing *) - - -(** {2 Formatters} *) - -val pp_span_span_kind : Format.formatter -> Trace_types.span_span_kind -> unit -(** [pp_span_span_kind v] formats v *) - -val pp_span_event : Format.formatter -> Trace_types.span_event -> unit -(** [pp_span_event v] formats v *) - -val pp_span_link : Format.formatter -> Trace_types.span_link -> unit -(** [pp_span_link v] formats v *) - -val pp_status_status_code : Format.formatter -> Trace_types.status_status_code -> unit -(** [pp_status_status_code v] formats v *) - -val pp_status : Format.formatter -> Trace_types.status -> unit -(** [pp_status v] formats v *) - -val pp_span : Format.formatter -> Trace_types.span -> unit -(** [pp_span v] formats v *) - -val pp_scope_spans : Format.formatter -> Trace_types.scope_spans -> unit -(** [pp_scope_spans v] formats v *) - -val pp_resource_spans : Format.formatter -> Trace_types.resource_spans -> unit -(** [pp_resource_spans v] formats v *) - -val pp_traces_data : Format.formatter -> Trace_types.traces_data -> unit -(** [pp_traces_data v] formats v *) diff --git a/src/trace_service_pb.ml b/src/trace_service_pb.ml deleted file mode 100644 index 68733bcf..00000000 --- a/src/trace_service_pb.ml +++ /dev/null @@ -1,112 +0,0 @@ -[@@@ocaml.warning "-27-30-39"] - -type export_trace_service_request_mutable = { - mutable resource_spans : Trace_types.resource_spans list; -} - -let default_export_trace_service_request_mutable () : export_trace_service_request_mutable = { - resource_spans = []; -} - -type export_trace_partial_success_mutable = { - mutable rejected_spans : int64; - mutable error_message : string; -} - -let default_export_trace_partial_success_mutable () : export_trace_partial_success_mutable = { - rejected_spans = 0L; - error_message = ""; -} - -type export_trace_service_response_mutable = { - mutable partial_success : Trace_service_types.export_trace_partial_success option; -} - -let default_export_trace_service_response_mutable () : export_trace_service_response_mutable = { - partial_success = None; -} - - -let rec decode_export_trace_service_request d = - let v = default_export_trace_service_request_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.resource_spans <- List.rev v.resource_spans; - ); continue__ := false - | Some (1, Pbrt.Bytes) -> begin - v.resource_spans <- (Trace_pb.decode_resource_spans (Pbrt.Decoder.nested d)) :: v.resource_spans; - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(export_trace_service_request), field(1)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Trace_service_types.resource_spans = v.resource_spans; - } : Trace_service_types.export_trace_service_request) - -let rec decode_export_trace_partial_success d = - let v = default_export_trace_partial_success_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - ); continue__ := false - | Some (1, Pbrt.Varint) -> begin - v.rejected_spans <- Pbrt.Decoder.int64_as_varint d; - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(export_trace_partial_success), field(1)" pk - | Some (2, Pbrt.Bytes) -> begin - v.error_message <- Pbrt.Decoder.string d; - end - | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(export_trace_partial_success), field(2)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Trace_service_types.rejected_spans = v.rejected_spans; - Trace_service_types.error_message = v.error_message; - } : Trace_service_types.export_trace_partial_success) - -let rec decode_export_trace_service_response d = - let v = default_export_trace_service_response_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - ); continue__ := false - | Some (1, Pbrt.Bytes) -> begin - v.partial_success <- Some (decode_export_trace_partial_success (Pbrt.Decoder.nested d)); - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(export_trace_service_response), field(1)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Trace_service_types.partial_success = v.partial_success; - } : Trace_service_types.export_trace_service_response) - -let rec encode_export_trace_service_request (v:Trace_service_types.export_trace_service_request) encoder = - List.iter (fun x -> - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (Trace_pb.encode_resource_spans x) encoder; - ) v.Trace_service_types.resource_spans; - () - -let rec encode_export_trace_partial_success (v:Trace_service_types.export_trace_partial_success) encoder = - Pbrt.Encoder.key (1, Pbrt.Varint) encoder; - Pbrt.Encoder.int64_as_varint v.Trace_service_types.rejected_spans encoder; - Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; - Pbrt.Encoder.string v.Trace_service_types.error_message encoder; - () - -let rec encode_export_trace_service_response (v:Trace_service_types.export_trace_service_response) encoder = - begin match v.Trace_service_types.partial_success with - | Some x -> - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_export_trace_partial_success x) encoder; - | None -> (); - end; - () diff --git a/src/trace_service_pb.mli b/src/trace_service_pb.mli deleted file mode 100644 index afd94a31..00000000 --- a/src/trace_service_pb.mli +++ /dev/null @@ -1,25 +0,0 @@ -(** trace_service.proto Binary Encoding *) - - -(** {2 Protobuf Encoding} *) - -val encode_export_trace_service_request : Trace_service_types.export_trace_service_request -> Pbrt.Encoder.t -> unit -(** [encode_export_trace_service_request v encoder] encodes [v] with the given [encoder] *) - -val encode_export_trace_partial_success : Trace_service_types.export_trace_partial_success -> Pbrt.Encoder.t -> unit -(** [encode_export_trace_partial_success v encoder] encodes [v] with the given [encoder] *) - -val encode_export_trace_service_response : Trace_service_types.export_trace_service_response -> Pbrt.Encoder.t -> unit -(** [encode_export_trace_service_response v encoder] encodes [v] with the given [encoder] *) - - -(** {2 Protobuf Decoding} *) - -val decode_export_trace_service_request : Pbrt.Decoder.t -> Trace_service_types.export_trace_service_request -(** [decode_export_trace_service_request decoder] decodes a [export_trace_service_request] value from [decoder] *) - -val decode_export_trace_partial_success : Pbrt.Decoder.t -> Trace_service_types.export_trace_partial_success -(** [decode_export_trace_partial_success decoder] decodes a [export_trace_partial_success] value from [decoder] *) - -val decode_export_trace_service_response : Pbrt.Decoder.t -> Trace_service_types.export_trace_service_response -(** [decode_export_trace_service_response decoder] decodes a [export_trace_service_response] value from [decoder] *) diff --git a/src/trace_service_pp.ml b/src/trace_service_pp.ml deleted file mode 100644 index edc069f2..00000000 --- a/src/trace_service_pp.ml +++ /dev/null @@ -1,20 +0,0 @@ -[@@@ocaml.warning "-27-30-39"] - -let rec pp_export_trace_service_request fmt (v:Trace_service_types.export_trace_service_request) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "resource_spans" (Pbrt.Pp.pp_list Trace_pp.pp_resource_spans) fmt v.Trace_service_types.resource_spans; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_export_trace_partial_success fmt (v:Trace_service_types.export_trace_partial_success) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "rejected_spans" Pbrt.Pp.pp_int64 fmt v.Trace_service_types.rejected_spans; - Pbrt.Pp.pp_record_field ~first:false "error_message" Pbrt.Pp.pp_string fmt v.Trace_service_types.error_message; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_export_trace_service_response fmt (v:Trace_service_types.export_trace_service_response) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "partial_success" (Pbrt.Pp.pp_option pp_export_trace_partial_success) fmt v.Trace_service_types.partial_success; - in - Pbrt.Pp.pp_brk pp_i fmt () diff --git a/src/trace_service_pp.mli b/src/trace_service_pp.mli deleted file mode 100644 index d7d52f99..00000000 --- a/src/trace_service_pp.mli +++ /dev/null @@ -1,13 +0,0 @@ -(** trace_service.proto Pretty Printing *) - - -(** {2 Formatters} *) - -val pp_export_trace_service_request : Format.formatter -> Trace_service_types.export_trace_service_request -> unit -(** [pp_export_trace_service_request v] formats v *) - -val pp_export_trace_partial_success : Format.formatter -> Trace_service_types.export_trace_partial_success -> unit -(** [pp_export_trace_partial_success v] formats v *) - -val pp_export_trace_service_response : Format.formatter -> Trace_service_types.export_trace_service_response -> unit -(** [pp_export_trace_service_response v] formats v *) diff --git a/src/trace_service_types.ml b/src/trace_service_types.ml deleted file mode 100644 index 6476d53c..00000000 --- a/src/trace_service_types.ml +++ /dev/null @@ -1,35 +0,0 @@ -[@@@ocaml.warning "-27-30-39"] - - -type export_trace_service_request = { - resource_spans : Trace_types.resource_spans list; -} - -type export_trace_partial_success = { - rejected_spans : int64; - error_message : string; -} - -type export_trace_service_response = { - partial_success : export_trace_partial_success option; -} - -let rec default_export_trace_service_request - ?resource_spans:((resource_spans:Trace_types.resource_spans list) = []) - () : export_trace_service_request = { - resource_spans; -} - -let rec default_export_trace_partial_success - ?rejected_spans:((rejected_spans:int64) = 0L) - ?error_message:((error_message:string) = "") - () : export_trace_partial_success = { - rejected_spans; - error_message; -} - -let rec default_export_trace_service_response - ?partial_success:((partial_success:export_trace_partial_success option) = None) - () : export_trace_service_response = { - partial_success; -} diff --git a/src/trace_service_types.mli b/src/trace_service_types.mli deleted file mode 100644 index e7480e77..00000000 --- a/src/trace_service_types.mli +++ /dev/null @@ -1,40 +0,0 @@ -(** trace_service.proto Types *) - - - -(** {2 Types} *) - -type export_trace_service_request = { - resource_spans : Trace_types.resource_spans list; -} - -type export_trace_partial_success = { - rejected_spans : int64; - error_message : string; -} - -type export_trace_service_response = { - partial_success : export_trace_partial_success option; -} - - -(** {2 Default values} *) - -val default_export_trace_service_request : - ?resource_spans:Trace_types.resource_spans list -> - unit -> - export_trace_service_request -(** [default_export_trace_service_request ()] is the default value for type [export_trace_service_request] *) - -val default_export_trace_partial_success : - ?rejected_spans:int64 -> - ?error_message:string -> - unit -> - export_trace_partial_success -(** [default_export_trace_partial_success ()] is the default value for type [export_trace_partial_success] *) - -val default_export_trace_service_response : - ?partial_success:export_trace_partial_success option -> - unit -> - export_trace_service_response -(** [default_export_trace_service_response ()] is the default value for type [export_trace_service_response] *) diff --git a/src/trace_types.ml b/src/trace_types.ml deleted file mode 100644 index 3e51df35..00000000 --- a/src/trace_types.ml +++ /dev/null @@ -1,167 +0,0 @@ -[@@@ocaml.warning "-27-30-39"] - - -type span_span_kind = - | Span_kind_unspecified - | Span_kind_internal - | Span_kind_server - | Span_kind_client - | Span_kind_producer - | Span_kind_consumer - -type span_event = { - time_unix_nano : int64; - name : string; - attributes : Common_types.key_value list; - dropped_attributes_count : int32; -} - -type span_link = { - trace_id : bytes; - span_id : bytes; - trace_state : string; - attributes : Common_types.key_value list; - dropped_attributes_count : int32; -} - -type status_status_code = - | Status_code_unset - | Status_code_ok - | Status_code_error - -type status = { - message : string; - code : status_status_code; -} - -type span = { - trace_id : bytes; - span_id : bytes; - trace_state : string; - parent_span_id : bytes; - name : string; - kind : span_span_kind; - start_time_unix_nano : int64; - end_time_unix_nano : int64; - attributes : Common_types.key_value list; - dropped_attributes_count : int32; - events : span_event list; - dropped_events_count : int32; - links : span_link list; - dropped_links_count : int32; - status : status option; -} - -type scope_spans = { - scope : Common_types.instrumentation_scope option; - spans : span list; - schema_url : string; -} - -type resource_spans = { - resource : Resource_types.resource option; - scope_spans : scope_spans list; - schema_url : string; -} - -type traces_data = { - resource_spans : resource_spans list; -} - -let rec default_span_span_kind () = (Span_kind_unspecified:span_span_kind) - -let rec default_span_event - ?time_unix_nano:((time_unix_nano:int64) = 0L) - ?name:((name:string) = "") - ?attributes:((attributes:Common_types.key_value list) = []) - ?dropped_attributes_count:((dropped_attributes_count:int32) = 0l) - () : span_event = { - time_unix_nano; - name; - attributes; - dropped_attributes_count; -} - -let rec default_span_link - ?trace_id:((trace_id:bytes) = Bytes.create 0) - ?span_id:((span_id:bytes) = Bytes.create 0) - ?trace_state:((trace_state:string) = "") - ?attributes:((attributes:Common_types.key_value list) = []) - ?dropped_attributes_count:((dropped_attributes_count:int32) = 0l) - () : span_link = { - trace_id; - span_id; - trace_state; - attributes; - dropped_attributes_count; -} - -let rec default_status_status_code () = (Status_code_unset:status_status_code) - -let rec default_status - ?message:((message:string) = "") - ?code:((code:status_status_code) = default_status_status_code ()) - () : status = { - message; - code; -} - -let rec default_span - ?trace_id:((trace_id:bytes) = Bytes.create 0) - ?span_id:((span_id:bytes) = Bytes.create 0) - ?trace_state:((trace_state:string) = "") - ?parent_span_id:((parent_span_id:bytes) = Bytes.create 0) - ?name:((name:string) = "") - ?kind:((kind:span_span_kind) = default_span_span_kind ()) - ?start_time_unix_nano:((start_time_unix_nano:int64) = 0L) - ?end_time_unix_nano:((end_time_unix_nano:int64) = 0L) - ?attributes:((attributes:Common_types.key_value list) = []) - ?dropped_attributes_count:((dropped_attributes_count:int32) = 0l) - ?events:((events:span_event list) = []) - ?dropped_events_count:((dropped_events_count:int32) = 0l) - ?links:((links:span_link list) = []) - ?dropped_links_count:((dropped_links_count:int32) = 0l) - ?status:((status:status option) = None) - () : span = { - trace_id; - span_id; - trace_state; - parent_span_id; - name; - kind; - start_time_unix_nano; - end_time_unix_nano; - attributes; - dropped_attributes_count; - events; - dropped_events_count; - links; - dropped_links_count; - status; -} - -let rec default_scope_spans - ?scope:((scope:Common_types.instrumentation_scope option) = None) - ?spans:((spans:span list) = []) - ?schema_url:((schema_url:string) = "") - () : scope_spans = { - scope; - spans; - schema_url; -} - -let rec default_resource_spans - ?resource:((resource:Resource_types.resource option) = None) - ?scope_spans:((scope_spans:scope_spans list) = []) - ?schema_url:((schema_url:string) = "") - () : resource_spans = { - resource; - scope_spans; - schema_url; -} - -let rec default_traces_data - ?resource_spans:((resource_spans:resource_spans list) = []) - () : traces_data = { - resource_spans; -} diff --git a/src/trace_types.mli b/src/trace_types.mli deleted file mode 100644 index ef7ac6dc..00000000 --- a/src/trace_types.mli +++ /dev/null @@ -1,149 +0,0 @@ -(** trace.proto Types *) - - - -(** {2 Types} *) - -type span_span_kind = - | Span_kind_unspecified - | Span_kind_internal - | Span_kind_server - | Span_kind_client - | Span_kind_producer - | Span_kind_consumer - -type span_event = { - time_unix_nano : int64; - name : string; - attributes : Common_types.key_value list; - dropped_attributes_count : int32; -} - -type span_link = { - trace_id : bytes; - span_id : bytes; - trace_state : string; - attributes : Common_types.key_value list; - dropped_attributes_count : int32; -} - -type status_status_code = - | Status_code_unset - | Status_code_ok - | Status_code_error - -type status = { - message : string; - code : status_status_code; -} - -type span = { - trace_id : bytes; - span_id : bytes; - trace_state : string; - parent_span_id : bytes; - name : string; - kind : span_span_kind; - start_time_unix_nano : int64; - end_time_unix_nano : int64; - attributes : Common_types.key_value list; - dropped_attributes_count : int32; - events : span_event list; - dropped_events_count : int32; - links : span_link list; - dropped_links_count : int32; - status : status option; -} - -type scope_spans = { - scope : Common_types.instrumentation_scope option; - spans : span list; - schema_url : string; -} - -type resource_spans = { - resource : Resource_types.resource option; - scope_spans : scope_spans list; - schema_url : string; -} - -type traces_data = { - resource_spans : resource_spans list; -} - - -(** {2 Default values} *) - -val default_span_span_kind : unit -> span_span_kind -(** [default_span_span_kind ()] is the default value for type [span_span_kind] *) - -val default_span_event : - ?time_unix_nano:int64 -> - ?name:string -> - ?attributes:Common_types.key_value list -> - ?dropped_attributes_count:int32 -> - unit -> - span_event -(** [default_span_event ()] is the default value for type [span_event] *) - -val default_span_link : - ?trace_id:bytes -> - ?span_id:bytes -> - ?trace_state:string -> - ?attributes:Common_types.key_value list -> - ?dropped_attributes_count:int32 -> - unit -> - span_link -(** [default_span_link ()] is the default value for type [span_link] *) - -val default_status_status_code : unit -> status_status_code -(** [default_status_status_code ()] is the default value for type [status_status_code] *) - -val default_status : - ?message:string -> - ?code:status_status_code -> - unit -> - status -(** [default_status ()] is the default value for type [status] *) - -val default_span : - ?trace_id:bytes -> - ?span_id:bytes -> - ?trace_state:string -> - ?parent_span_id:bytes -> - ?name:string -> - ?kind:span_span_kind -> - ?start_time_unix_nano:int64 -> - ?end_time_unix_nano:int64 -> - ?attributes:Common_types.key_value list -> - ?dropped_attributes_count:int32 -> - ?events:span_event list -> - ?dropped_events_count:int32 -> - ?links:span_link list -> - ?dropped_links_count:int32 -> - ?status:status option -> - unit -> - span -(** [default_span ()] is the default value for type [span] *) - -val default_scope_spans : - ?scope:Common_types.instrumentation_scope option -> - ?spans:span list -> - ?schema_url:string -> - unit -> - scope_spans -(** [default_scope_spans ()] is the default value for type [scope_spans] *) - -val default_resource_spans : - ?resource:Resource_types.resource option -> - ?scope_spans:scope_spans list -> - ?schema_url:string -> - unit -> - resource_spans -(** [default_resource_spans ()] is the default value for type [resource_spans] *) - -val default_traces_data : - ?resource_spans:resource_spans list -> - unit -> - traces_data -(** [default_traces_data ()] is the default value for type [traces_data] *) From db45d9ff5613c82f7a982e18eae02dc2338abac3 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Tue, 7 Nov 2023 15:35:40 -0500 Subject: [PATCH 2/9] no open --- src/core/dune | 2 +- src/core/opentelemetry.ml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/dune b/src/core/dune index f3dcfa4e..f3671f64 100644 --- a/src/core/dune +++ b/src/core/dune @@ -1,7 +1,7 @@ (library (name opentelemetry) (synopsis "API for opentelemetry instrumentation") - (flags :standard -warn-error -a+8 -open Opentelemetry_proto) + (flags :standard -warn-error -a+8) (libraries opentelemetry.proto ambient-context ptime ptime.clock.os pbrt threads opentelemetry.atomic) (public_name opentelemetry)) diff --git a/src/core/opentelemetry.ml b/src/core/opentelemetry.ml index 66ca27d2..983ca128 100644 --- a/src/core/opentelemetry.ml +++ b/src/core/opentelemetry.ml @@ -19,6 +19,8 @@ end This is mostly useful internally. Users should not need to touch it. *) module Proto = struct + open Opentelemetry_proto + module Common = struct include Common_types include Common_pp @@ -887,6 +889,7 @@ end See {{: https://opentelemetry.io/docs/reference/specification/overview/#metric-signal} the spec} *) module Metrics = struct + open Opentelemetry_proto open Metrics_types type t = Metrics_types.metric @@ -989,6 +992,7 @@ end See {{: https://opentelemetry.io/docs/reference/specification/overview/#log-signal} the spec} *) module Logs = struct + open Opentelemetry_proto open Logs_types type t = log_record From 6bf49dc050868e8b609663a318df06b4dcac2a37 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Wed, 8 Nov 2023 11:35:19 -0500 Subject: [PATCH 3/9] refactor tests to avoid circular dependencies --- dune-project | 40 ++------------------ opentelemetry-client-cohttp-lwt.opam | 1 - opentelemetry-client-ocurl.opam | 1 - opentelemetry-cohttp-lwt.opam | 2 - opentelemetry-lwt.opam | 2 - opentelemetry.opam | 2 - tests/cohttp/dune | 4 ++ tests/{ => cohttp}/test_get_url.expected | 1 - tests/{ => cohttp}/test_get_url.ml | 10 +---- tests/core/dune | 5 +++ tests/{ => core}/test_trace_context.expected | 0 tests/{ => core}/test_trace_context.ml | 0 tests/dune | 4 -- tests/implicit_scope/sync/dune | 1 + tests/ocurl/dune | 5 +++ tests/ocurl/test_get_url.expected | 1 + tests/ocurl/test_get_url.ml | 9 +++++ 17 files changed, 30 insertions(+), 58 deletions(-) create mode 100644 tests/cohttp/dune rename tests/{ => cohttp}/test_get_url.expected (50%) rename tests/{ => cohttp}/test_get_url.ml (51%) create mode 100644 tests/core/dune rename tests/{ => core}/test_trace_context.expected (100%) rename tests/{ => core}/test_trace_context.ml (100%) delete mode 100644 tests/dune create mode 100644 tests/ocurl/dune create mode 100644 tests/ocurl/test_get_url.expected create mode 100644 tests/ocurl/test_get_url.ml diff --git a/dune-project b/dune-project index c7d242e6..3938038b 100644 --- a/dune-project +++ b/dune-project @@ -30,14 +30,6 @@ ambient-context (odoc :with-doc) (alcotest :with-test) - (opentelemetry-client-cohttp-lwt - (and - :with-test - (= :version))) - (opentelemetry-client-ocurl - (and - :with-test - (= :version))) (pbrt (>= 2.3)) (ocaml-lsp-server :with-dev-setup) @@ -70,15 +62,7 @@ (>= "5.3")) (lwt_ppx (>= "2.0")) - (alcotest :with-test) - (opentelemetry-client-cohttp-lwt - (and - :with-test - (= :version))) - (opentelemetry-client-ocurl - (and - :with-test - (= :version)))) + (alcotest :with-test)) (tags (instrumentation tracing opentelemetry datadog lwt))) @@ -99,11 +83,7 @@ (ezcurl (>= 0.2.3)) ocurl - (alcotest :with-test) - (opentelemetry-client-cohttp-lwt - (and - :with-test - (= :version)))) + (alcotest :with-test)) (synopsis "Collector client for opentelemetry, using http + ezcurl")) (package @@ -120,15 +100,7 @@ (>= "5.3")) (cohttp-lwt (>= "4.0.0")) - (alcotest :with-test) - (opentelemetry-client-cohttp-lwt - (and - :with-test - (= :version))) - (opentelemetry-client-ocurl - (and - :with-test - (= :version)))) + (alcotest :with-test)) (synopsis "Opentelemetry tracing for Cohttp HTTP servers")) (package @@ -150,9 +122,5 @@ (>= "2.0")) cohttp-lwt cohttp-lwt-unix - (alcotest :with-test) - (opentelemetry-client-ocurl - (and - :with-test - (= :version)))) + (alcotest :with-test)) (synopsis "Collector client for opentelemetry, using cohttp + lwt")) diff --git a/opentelemetry-client-cohttp-lwt.opam b/opentelemetry-client-cohttp-lwt.opam index 93b11939..8ded95ec 100644 --- a/opentelemetry-client-cohttp-lwt.opam +++ b/opentelemetry-client-cohttp-lwt.opam @@ -23,7 +23,6 @@ depends: [ "cohttp-lwt" "cohttp-lwt-unix" "alcotest" {with-test} - "opentelemetry-client-ocurl" {with-test & = version} ] build: [ ["dune" "subst"] {dev} diff --git a/opentelemetry-client-ocurl.opam b/opentelemetry-client-ocurl.opam index 0a32fc67..21d01814 100644 --- a/opentelemetry-client-ocurl.opam +++ b/opentelemetry-client-ocurl.opam @@ -21,7 +21,6 @@ depends: [ "ezcurl" {>= "0.2.3"} "ocurl" "alcotest" {with-test} - "opentelemetry-client-cohttp-lwt" {with-test & = version} ] build: [ ["dune" "subst"] {dev} diff --git a/opentelemetry-cohttp-lwt.opam b/opentelemetry-cohttp-lwt.opam index 94ec245d..20c5321a 100644 --- a/opentelemetry-cohttp-lwt.opam +++ b/opentelemetry-cohttp-lwt.opam @@ -20,8 +20,6 @@ depends: [ "lwt" {>= "5.3"} "cohttp-lwt" {>= "4.0.0"} "alcotest" {with-test} - "opentelemetry-client-cohttp-lwt" {with-test & = version} - "opentelemetry-client-ocurl" {with-test & = version} ] build: [ ["dune" "subst"] {dev} diff --git a/opentelemetry-lwt.opam b/opentelemetry-lwt.opam index ff13e0d6..a03196a2 100644 --- a/opentelemetry-lwt.opam +++ b/opentelemetry-lwt.opam @@ -22,8 +22,6 @@ depends: [ "lwt" {>= "5.3"} "lwt_ppx" {>= "2.0"} "alcotest" {with-test} - "opentelemetry-client-cohttp-lwt" {with-test & = version} - "opentelemetry-client-ocurl" {with-test & = version} ] build: [ ["dune" "subst"] {dev} diff --git a/opentelemetry.opam b/opentelemetry.opam index cfc11eeb..cf4a98f3 100644 --- a/opentelemetry.opam +++ b/opentelemetry.opam @@ -19,8 +19,6 @@ depends: [ "ambient-context" "odoc" {with-doc} "alcotest" {with-test} - "opentelemetry-client-cohttp-lwt" {with-test & = version} - "opentelemetry-client-ocurl" {with-test & = version} "pbrt" {>= "2.3"} "ocaml-lsp-server" {with-dev-setup} "ocamlformat" {with-dev-setup & >= "0.24" & < "0.25"} diff --git a/tests/cohttp/dune b/tests/cohttp/dune new file mode 100644 index 00000000..b467b27c --- /dev/null +++ b/tests/cohttp/dune @@ -0,0 +1,4 @@ +(tests + (names test_get_url) + (package opentelemetry-client-cohttp-lwt) + (libraries opentelemetry opentelemetry-client-cohttp-lwt)) diff --git a/tests/test_get_url.expected b/tests/cohttp/test_get_url.expected similarity index 50% rename from tests/test_get_url.expected rename to tests/cohttp/test_get_url.expected index bafd6ea4..400f46eb 100644 --- a/tests/test_get_url.expected +++ b/tests/cohttp/test_get_url.expected @@ -1,2 +1 @@ -ocurl url = http://localhost:3000 cohttp url = http://localhost:3000 diff --git a/tests/test_get_url.ml b/tests/cohttp/test_get_url.ml similarity index 51% rename from tests/test_get_url.ml rename to tests/cohttp/test_get_url.ml index 397996d3..3a271956 100644 --- a/tests/test_get_url.ml +++ b/tests/cohttp/test_get_url.ml @@ -1,17 +1,9 @@ let url = "http://localhost:3000" -let ocurl () = - let config = Opentelemetry_client_ocurl.Config.make ~url () in - Opentelemetry_client_ocurl.with_setup ~config () @@ fun () -> - let url = Opentelemetry_client_ocurl.get_url () in - print_endline @@ Printf.sprintf "ocurl url = %s" url - let cohttp () = let config = Opentelemetry_client_cohttp_lwt.Config.make ~url () in Opentelemetry_client_cohttp_lwt.with_setup ~config () @@ fun () -> let url = Opentelemetry_client_cohttp_lwt.get_url () in print_endline @@ Printf.sprintf "cohttp url = %s" url -let () = - ocurl (); - cohttp () +let () = cohttp () diff --git a/tests/core/dune b/tests/core/dune new file mode 100644 index 00000000..da93554f --- /dev/null +++ b/tests/core/dune @@ -0,0 +1,5 @@ + +(tests + (names test_trace_context ) + (package opentelemetry) + (libraries opentelemetry)) diff --git a/tests/test_trace_context.expected b/tests/core/test_trace_context.expected similarity index 100% rename from tests/test_trace_context.expected rename to tests/core/test_trace_context.expected diff --git a/tests/test_trace_context.ml b/tests/core/test_trace_context.ml similarity index 100% rename from tests/test_trace_context.ml rename to tests/core/test_trace_context.ml diff --git a/tests/dune b/tests/dune deleted file mode 100644 index c005f866..00000000 --- a/tests/dune +++ /dev/null @@ -1,4 +0,0 @@ -(tests - (names test_trace_context test_get_url) - (libraries opentelemetry opentelemetry-client-ocurl - opentelemetry-client-cohttp-lwt)) diff --git a/tests/implicit_scope/sync/dune b/tests/implicit_scope/sync/dune index 072eee77..8b5407f4 100644 --- a/tests/implicit_scope/sync/dune +++ b/tests/implicit_scope/sync/dune @@ -1,3 +1,4 @@ (tests (names test_implicit_scope_sync) + (package opentelemetry-client-cohttp-lwt) (libraries alcotest opentelemetry opentelemetry-client-cohttp-lwt)) diff --git a/tests/ocurl/dune b/tests/ocurl/dune new file mode 100644 index 00000000..18a15fca --- /dev/null +++ b/tests/ocurl/dune @@ -0,0 +1,5 @@ + +(tests + (names test_get_url) + (package opentelemetry-client-ocurl) + (libraries opentelemetry opentelemetry-client-ocurl)) diff --git a/tests/ocurl/test_get_url.expected b/tests/ocurl/test_get_url.expected new file mode 100644 index 00000000..0b9a4214 --- /dev/null +++ b/tests/ocurl/test_get_url.expected @@ -0,0 +1 @@ +ocurl url = http://localhost:3000 diff --git a/tests/ocurl/test_get_url.ml b/tests/ocurl/test_get_url.ml new file mode 100644 index 00000000..1e142015 --- /dev/null +++ b/tests/ocurl/test_get_url.ml @@ -0,0 +1,9 @@ +let url = "http://localhost:3000" + +let ocurl () = + let config = Opentelemetry_client_ocurl.Config.make ~url () in + Opentelemetry_client_ocurl.with_setup ~config () @@ fun () -> + let url = Opentelemetry_client_ocurl.get_url () in + print_endline @@ Printf.sprintf "ocurl url = %s" url + +let () = ocurl () From 0532c9b9efb57115ae03f2988dee69b43ee72258 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Wed, 8 Nov 2023 11:41:59 -0500 Subject: [PATCH 4/9] add missing proto directory --- src/proto/common_pb.ml | 224 +++++ src/proto/common_pb.mli | 37 + src/proto/common_pp.ml | 39 + src/proto/common_pp.mli | 20 + src/proto/common_types.ml | 65 ++ src/proto/common_types.mli | 68 ++ src/proto/dune | 126 +++ src/proto/logs_pb.ml | 348 ++++++++ src/proto/logs_pb.mli | 43 + src/proto/logs_pp.ml | 71 ++ src/proto/logs_pp.mli | 23 + src/proto/logs_service_pb.ml | 112 +++ src/proto/logs_service_pb.mli | 25 + src/proto/logs_service_pp.ml | 20 + src/proto/logs_service_pp.mli | 14 + src/proto/logs_service_types.ml | 35 + src/proto/logs_service_types.mli | 40 + src/proto/logs_types.ml | 116 +++ src/proto/logs_types.mli | 111 +++ src/proto/metrics_pb.ml | 1282 +++++++++++++++++++++++++++ src/proto/metrics_pb.mli | 133 +++ src/proto/metrics_pp.ml | 177 ++++ src/proto/metrics_pp.mli | 68 ++ src/proto/metrics_service_pb.ml | 112 +++ src/proto/metrics_service_pb.mli | 25 + src/proto/metrics_service_pp.ml | 20 + src/proto/metrics_service_pp.mli | 14 + src/proto/metrics_service_types.ml | 35 + src/proto/metrics_service_types.mli | 40 + src/proto/metrics_types.ml | 349 ++++++++ src/proto/metrics_types.mli | 309 +++++++ src/proto/resource_pb.ml | 46 + src/proto/resource_pb.mli | 13 + src/proto/resource_pp.ml | 8 + src/proto/resource_pp.mli | 8 + src/proto/resource_types.ml | 15 + src/proto/resource_types.mli | 20 + src/proto/status.proto | 10 + src/proto/status_pb.ml | 56 ++ src/proto/status_pb.mli | 13 + src/proto/status_pp.ml | 9 + src/proto/status_pp.mli | 8 + src/proto/status_types.ml | 18 + src/proto/status_types.mli | 22 + src/proto/trace_pb.ml | 547 ++++++++++++ src/proto/trace_pb.mli | 61 ++ src/proto/trace_pp.ml | 84 ++ src/proto/trace_pp.mli | 32 + src/proto/trace_service_pb.ml | 112 +++ src/proto/trace_service_pb.mli | 25 + src/proto/trace_service_pp.ml | 20 + src/proto/trace_service_pp.mli | 14 + src/proto/trace_service_types.ml | 35 + src/proto/trace_service_types.mli | 40 + src/proto/trace_types.ml | 167 ++++ src/proto/trace_types.mli | 149 ++++ 56 files changed, 5633 insertions(+) create mode 100644 src/proto/common_pb.ml create mode 100644 src/proto/common_pb.mli create mode 100644 src/proto/common_pp.ml create mode 100644 src/proto/common_pp.mli create mode 100644 src/proto/common_types.ml create mode 100644 src/proto/common_types.mli create mode 100644 src/proto/dune create mode 100644 src/proto/logs_pb.ml create mode 100644 src/proto/logs_pb.mli create mode 100644 src/proto/logs_pp.ml create mode 100644 src/proto/logs_pp.mli create mode 100644 src/proto/logs_service_pb.ml create mode 100644 src/proto/logs_service_pb.mli create mode 100644 src/proto/logs_service_pp.ml create mode 100644 src/proto/logs_service_pp.mli create mode 100644 src/proto/logs_service_types.ml create mode 100644 src/proto/logs_service_types.mli create mode 100644 src/proto/logs_types.ml create mode 100644 src/proto/logs_types.mli create mode 100644 src/proto/metrics_pb.ml create mode 100644 src/proto/metrics_pb.mli create mode 100644 src/proto/metrics_pp.ml create mode 100644 src/proto/metrics_pp.mli create mode 100644 src/proto/metrics_service_pb.ml create mode 100644 src/proto/metrics_service_pb.mli create mode 100644 src/proto/metrics_service_pp.ml create mode 100644 src/proto/metrics_service_pp.mli create mode 100644 src/proto/metrics_service_types.ml create mode 100644 src/proto/metrics_service_types.mli create mode 100644 src/proto/metrics_types.ml create mode 100644 src/proto/metrics_types.mli create mode 100644 src/proto/resource_pb.ml create mode 100644 src/proto/resource_pb.mli create mode 100644 src/proto/resource_pp.ml create mode 100644 src/proto/resource_pp.mli create mode 100644 src/proto/resource_types.ml create mode 100644 src/proto/resource_types.mli create mode 100644 src/proto/status.proto create mode 100644 src/proto/status_pb.ml create mode 100644 src/proto/status_pb.mli create mode 100644 src/proto/status_pp.ml create mode 100644 src/proto/status_pp.mli create mode 100644 src/proto/status_types.ml create mode 100644 src/proto/status_types.mli create mode 100644 src/proto/trace_pb.ml create mode 100644 src/proto/trace_pb.mli create mode 100644 src/proto/trace_pp.ml create mode 100644 src/proto/trace_pp.mli create mode 100644 src/proto/trace_service_pb.ml create mode 100644 src/proto/trace_service_pb.mli create mode 100644 src/proto/trace_service_pp.ml create mode 100644 src/proto/trace_service_pp.mli create mode 100644 src/proto/trace_service_types.ml create mode 100644 src/proto/trace_service_types.mli create mode 100644 src/proto/trace_types.ml create mode 100644 src/proto/trace_types.mli diff --git a/src/proto/common_pb.ml b/src/proto/common_pb.ml new file mode 100644 index 00000000..cc2f7034 --- /dev/null +++ b/src/proto/common_pb.ml @@ -0,0 +1,224 @@ +[@@@ocaml.warning "-27-30-39"] + +type key_value_list_mutable = { + mutable values : Common_types.key_value list; +} + +let default_key_value_list_mutable () : key_value_list_mutable = { + values = []; +} + +type key_value_mutable = { + mutable key : string; + mutable value : Common_types.any_value option; +} + +let default_key_value_mutable () : key_value_mutable = { + key = ""; + value = None; +} + +type array_value_mutable = { + mutable values : Common_types.any_value list; +} + +let default_array_value_mutable () : array_value_mutable = { + values = []; +} + +type instrumentation_scope_mutable = { + mutable name : string; + mutable version : string; + mutable attributes : Common_types.key_value list; + mutable dropped_attributes_count : int32; +} + +let default_instrumentation_scope_mutable () : instrumentation_scope_mutable = { + name = ""; + version = ""; + attributes = []; + dropped_attributes_count = 0l; +} + + +let rec decode_any_value d = + let rec loop () = + let ret:Common_types.any_value = match Pbrt.Decoder.key d with + | None -> Pbrt.Decoder.malformed_variant "any_value" + | Some (7, _) -> (Common_types.Bytes_value (Pbrt.Decoder.bytes d) : Common_types.any_value) + | Some (6, _) -> (Common_types.Kvlist_value (decode_key_value_list (Pbrt.Decoder.nested d)) : Common_types.any_value) + | Some (5, _) -> (Common_types.Array_value (decode_array_value (Pbrt.Decoder.nested d)) : Common_types.any_value) + | Some (4, _) -> (Common_types.Double_value (Pbrt.Decoder.float_as_bits64 d) : Common_types.any_value) + | Some (3, _) -> (Common_types.Int_value (Pbrt.Decoder.int64_as_varint d) : Common_types.any_value) + | Some (2, _) -> (Common_types.Bool_value (Pbrt.Decoder.bool d) : Common_types.any_value) + | Some (1, _) -> (Common_types.String_value (Pbrt.Decoder.string d) : Common_types.any_value) + | Some (n, payload_kind) -> ( + Pbrt.Decoder.skip d payload_kind; + loop () + ) + in + ret + in + loop () + +and decode_key_value_list d = + let v = default_key_value_list_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.values <- List.rev v.values; + ); continue__ := false + | Some (1, Pbrt.Bytes) -> begin + v.values <- (decode_key_value (Pbrt.Decoder.nested d)) :: v.values; + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(key_value_list), field(1)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Common_types.values = v.values; + } : Common_types.key_value_list) + +and decode_key_value d = + let v = default_key_value_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + ); continue__ := false + | Some (1, Pbrt.Bytes) -> begin + v.key <- Pbrt.Decoder.string d; + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(key_value), field(1)" pk + | Some (2, Pbrt.Bytes) -> begin + v.value <- Some (decode_any_value (Pbrt.Decoder.nested d)); + end + | Some (2, pk) -> + Pbrt.Decoder.unexpected_payload "Message(key_value), field(2)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Common_types.key = v.key; + Common_types.value = v.value; + } : Common_types.key_value) + +and decode_array_value d = + let v = default_array_value_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.values <- List.rev v.values; + ); continue__ := false + | Some (1, Pbrt.Bytes) -> begin + v.values <- (decode_any_value (Pbrt.Decoder.nested d)) :: v.values; + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(array_value), field(1)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Common_types.values = v.values; + } : Common_types.array_value) + +let rec decode_instrumentation_scope d = + let v = default_instrumentation_scope_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.attributes <- List.rev v.attributes; + ); continue__ := false + | Some (1, Pbrt.Bytes) -> begin + v.name <- Pbrt.Decoder.string d; + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(instrumentation_scope), field(1)" pk + | Some (2, Pbrt.Bytes) -> begin + v.version <- Pbrt.Decoder.string d; + end + | Some (2, pk) -> + Pbrt.Decoder.unexpected_payload "Message(instrumentation_scope), field(2)" pk + | Some (3, Pbrt.Bytes) -> begin + v.attributes <- (decode_key_value (Pbrt.Decoder.nested d)) :: v.attributes; + end + | Some (3, pk) -> + Pbrt.Decoder.unexpected_payload "Message(instrumentation_scope), field(3)" pk + | Some (4, Pbrt.Varint) -> begin + v.dropped_attributes_count <- Pbrt.Decoder.int32_as_varint d; + end + | Some (4, pk) -> + Pbrt.Decoder.unexpected_payload "Message(instrumentation_scope), field(4)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Common_types.name = v.name; + Common_types.version = v.version; + Common_types.attributes = v.attributes; + Common_types.dropped_attributes_count = v.dropped_attributes_count; + } : Common_types.instrumentation_scope) + +let rec encode_any_value (v:Common_types.any_value) encoder = + begin match v with + | Common_types.Bytes_value x -> + Pbrt.Encoder.key (7, Pbrt.Bytes) encoder; + Pbrt.Encoder.bytes x encoder; + | Common_types.Kvlist_value x -> + Pbrt.Encoder.key (6, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_key_value_list x) encoder; + | Common_types.Array_value x -> + Pbrt.Encoder.key (5, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_array_value x) encoder; + | Common_types.Double_value x -> + Pbrt.Encoder.key (4, Pbrt.Bits64) encoder; + Pbrt.Encoder.float_as_bits64 x encoder; + | Common_types.Int_value x -> + Pbrt.Encoder.key (3, Pbrt.Varint) encoder; + Pbrt.Encoder.int64_as_varint x encoder; + | Common_types.Bool_value x -> + Pbrt.Encoder.key (2, Pbrt.Varint) encoder; + Pbrt.Encoder.bool x encoder; + | Common_types.String_value x -> + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.string x encoder; + end + +and encode_key_value_list (v:Common_types.key_value_list) encoder = + List.iter (fun x -> + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_key_value x) encoder; + ) v.Common_types.values; + () + +and encode_key_value (v:Common_types.key_value) encoder = + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.string v.Common_types.key encoder; + begin match v.Common_types.value with + | Some x -> + Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_any_value x) encoder; + | None -> (); + end; + () + +and encode_array_value (v:Common_types.array_value) encoder = + List.iter (fun x -> + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_any_value x) encoder; + ) v.Common_types.values; + () + +let rec encode_instrumentation_scope (v:Common_types.instrumentation_scope) encoder = + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.string v.Common_types.name encoder; + Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; + Pbrt.Encoder.string v.Common_types.version encoder; + List.iter (fun x -> + Pbrt.Encoder.key (3, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_key_value x) encoder; + ) v.Common_types.attributes; + Pbrt.Encoder.key (4, Pbrt.Varint) encoder; + Pbrt.Encoder.int32_as_varint v.Common_types.dropped_attributes_count encoder; + () diff --git a/src/proto/common_pb.mli b/src/proto/common_pb.mli new file mode 100644 index 00000000..a415b483 --- /dev/null +++ b/src/proto/common_pb.mli @@ -0,0 +1,37 @@ +(** common.proto Binary Encoding *) + + +(** {2 Protobuf Encoding} *) + +val encode_any_value : Common_types.any_value -> Pbrt.Encoder.t -> unit +(** [encode_any_value v encoder] encodes [v] with the given [encoder] *) + +val encode_key_value_list : Common_types.key_value_list -> Pbrt.Encoder.t -> unit +(** [encode_key_value_list v encoder] encodes [v] with the given [encoder] *) + +val encode_key_value : Common_types.key_value -> Pbrt.Encoder.t -> unit +(** [encode_key_value v encoder] encodes [v] with the given [encoder] *) + +val encode_array_value : Common_types.array_value -> Pbrt.Encoder.t -> unit +(** [encode_array_value v encoder] encodes [v] with the given [encoder] *) + +val encode_instrumentation_scope : Common_types.instrumentation_scope -> Pbrt.Encoder.t -> unit +(** [encode_instrumentation_scope v encoder] encodes [v] with the given [encoder] *) + + +(** {2 Protobuf Decoding} *) + +val decode_any_value : Pbrt.Decoder.t -> Common_types.any_value +(** [decode_any_value decoder] decodes a [any_value] value from [decoder] *) + +val decode_key_value_list : Pbrt.Decoder.t -> Common_types.key_value_list +(** [decode_key_value_list decoder] decodes a [key_value_list] value from [decoder] *) + +val decode_key_value : Pbrt.Decoder.t -> Common_types.key_value +(** [decode_key_value decoder] decodes a [key_value] value from [decoder] *) + +val decode_array_value : Pbrt.Decoder.t -> Common_types.array_value +(** [decode_array_value decoder] decodes a [array_value] value from [decoder] *) + +val decode_instrumentation_scope : Pbrt.Decoder.t -> Common_types.instrumentation_scope +(** [decode_instrumentation_scope decoder] decodes a [instrumentation_scope] value from [decoder] *) diff --git a/src/proto/common_pp.ml b/src/proto/common_pp.ml new file mode 100644 index 00000000..0bbc2906 --- /dev/null +++ b/src/proto/common_pp.ml @@ -0,0 +1,39 @@ +[@@@ocaml.warning "-27-30-39"] + +let rec pp_any_value fmt (v:Common_types.any_value) = + match v with + | Common_types.Bytes_value x -> Format.fprintf fmt "@[Bytes_value(@,%a)@]" Pbrt.Pp.pp_bytes x + | Common_types.Kvlist_value x -> Format.fprintf fmt "@[Kvlist_value(@,%a)@]" pp_key_value_list x + | Common_types.Array_value x -> Format.fprintf fmt "@[Array_value(@,%a)@]" pp_array_value x + | Common_types.Double_value x -> Format.fprintf fmt "@[Double_value(@,%a)@]" Pbrt.Pp.pp_float x + | Common_types.Int_value x -> Format.fprintf fmt "@[Int_value(@,%a)@]" Pbrt.Pp.pp_int64 x + | Common_types.Bool_value x -> Format.fprintf fmt "@[Bool_value(@,%a)@]" Pbrt.Pp.pp_bool x + | Common_types.String_value x -> Format.fprintf fmt "@[String_value(@,%a)@]" Pbrt.Pp.pp_string x + +and pp_key_value_list fmt (v:Common_types.key_value_list) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "values" (Pbrt.Pp.pp_list pp_key_value) fmt v.Common_types.values; + in + Pbrt.Pp.pp_brk pp_i fmt () + +and pp_key_value fmt (v:Common_types.key_value) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "key" Pbrt.Pp.pp_string fmt v.Common_types.key; + Pbrt.Pp.pp_record_field ~first:false "value" (Pbrt.Pp.pp_option pp_any_value) fmt v.Common_types.value; + in + Pbrt.Pp.pp_brk pp_i fmt () + +and pp_array_value fmt (v:Common_types.array_value) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "values" (Pbrt.Pp.pp_list pp_any_value) fmt v.Common_types.values; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_instrumentation_scope fmt (v:Common_types.instrumentation_scope) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "name" Pbrt.Pp.pp_string fmt v.Common_types.name; + Pbrt.Pp.pp_record_field ~first:false "version" Pbrt.Pp.pp_string fmt v.Common_types.version; + Pbrt.Pp.pp_record_field ~first:false "attributes" (Pbrt.Pp.pp_list pp_key_value) fmt v.Common_types.attributes; + Pbrt.Pp.pp_record_field ~first:false "dropped_attributes_count" Pbrt.Pp.pp_int32 fmt v.Common_types.dropped_attributes_count; + in + Pbrt.Pp.pp_brk pp_i fmt () diff --git a/src/proto/common_pp.mli b/src/proto/common_pp.mli new file mode 100644 index 00000000..64c5f919 --- /dev/null +++ b/src/proto/common_pp.mli @@ -0,0 +1,20 @@ + +(** common.proto Pretty Printing *) + + +(** {2 Formatters} *) + +val pp_any_value : Format.formatter -> Common_types.any_value -> unit +(** [pp_any_value v] formats v *) + +val pp_key_value_list : Format.formatter -> Common_types.key_value_list -> unit +(** [pp_key_value_list v] formats v *) + +val pp_key_value : Format.formatter -> Common_types.key_value -> unit +(** [pp_key_value v] formats v *) + +val pp_array_value : Format.formatter -> Common_types.array_value -> unit +(** [pp_array_value v] formats v *) + +val pp_instrumentation_scope : Format.formatter -> Common_types.instrumentation_scope -> unit +(** [pp_instrumentation_scope v] formats v *) diff --git a/src/proto/common_types.ml b/src/proto/common_types.ml new file mode 100644 index 00000000..3d010172 --- /dev/null +++ b/src/proto/common_types.ml @@ -0,0 +1,65 @@ +[@@@ocaml.warning "-27-30-39"] + + +type any_value = + | Bytes_value of bytes + | Kvlist_value of key_value_list + | Array_value of array_value + | Double_value of float + | Int_value of int64 + | Bool_value of bool + | String_value of string + +and key_value_list = { + values : key_value list; +} + +and key_value = { + key : string; + value : any_value option; +} + +and array_value = { + values : any_value list; +} + +type instrumentation_scope = { + name : string; + version : string; + attributes : key_value list; + dropped_attributes_count : int32; +} + +let rec default_any_value () : any_value = Bytes_value (Bytes.create 0) + +and default_key_value_list + ?values:((values:key_value list) = []) + () : key_value_list = { + values; +} + +and default_key_value + ?key:((key:string) = "") + ?value:((value:any_value option) = None) + () : key_value = { + key; + value; +} + +and default_array_value + ?values:((values:any_value list) = []) + () : array_value = { + values; +} + +let rec default_instrumentation_scope + ?name:((name:string) = "") + ?version:((version:string) = "") + ?attributes:((attributes:key_value list) = []) + ?dropped_attributes_count:((dropped_attributes_count:int32) = 0l) + () : instrumentation_scope = { + name; + version; + attributes; + dropped_attributes_count; +} diff --git a/src/proto/common_types.mli b/src/proto/common_types.mli new file mode 100644 index 00000000..2e72d579 --- /dev/null +++ b/src/proto/common_types.mli @@ -0,0 +1,68 @@ +(** common.proto Types *) + + + +(** {2 Types} *) + +type any_value = + | Bytes_value of bytes + | Kvlist_value of key_value_list + | Array_value of array_value + | Double_value of float + | Int_value of int64 + | Bool_value of bool + | String_value of string + +and key_value_list = { + values : key_value list; +} + +and key_value = { + key : string; + value : any_value option; +} + +and array_value = { + values : any_value list; +} + +type instrumentation_scope = { + name : string; + version : string; + attributes : key_value list; + dropped_attributes_count : int32; +} + + +(** {2 Default values} *) + +val default_any_value : unit -> any_value +(** [default_any_value ()] is the default value for type [any_value] *) + +val default_key_value_list : + ?values:key_value list -> + unit -> + key_value_list +(** [default_key_value_list ()] is the default value for type [key_value_list] *) + +val default_key_value : + ?key:string -> + ?value:any_value option -> + unit -> + key_value +(** [default_key_value ()] is the default value for type [key_value] *) + +val default_array_value : + ?values:any_value list -> + unit -> + array_value +(** [default_array_value ()] is the default value for type [array_value] *) + +val default_instrumentation_scope : + ?name:string -> + ?version:string -> + ?attributes:key_value list -> + ?dropped_attributes_count:int32 -> + unit -> + instrumentation_scope +(** [default_instrumentation_scope ()] is the default value for type [instrumentation_scope] *) diff --git a/src/proto/dune b/src/proto/dune new file mode 100644 index 00000000..a87df75d --- /dev/null +++ b/src/proto/dune @@ -0,0 +1,126 @@ + +(library + (name opentelemetry_proto) + (public_name opentelemetry.proto) + (synopsis "Protobuf generated code for opentelemetry") + (flags :standard -warn-error -a+8) + (libraries pbrt)) + +; ### protobuf rules ### + +(rule + (alias lint) + (mode promote) + (targets status_types.ml status_types.mli status_pb.ml status_pb.mli + status_pp.ml status_pp.mli) + (deps + (:file status.proto) + (source_tree %{project_root}/vendor/opentelemetry-proto/)) + (action + (run ocaml-protoc %{file} -ml_out . -pp -binary))) + +(rule + (alias lint) + (mode promote) + (targets common_types.ml common_types.mli common_pb.ml common_pb.mli + common_pp.ml common_pp.mli) + (deps + (:file + %{project_root}/vendor/opentelemetry-proto/opentelemetry/proto/common/v1/common.proto) + (source_tree %{project_root}/vendor/opentelemetry-proto/)) + (action + (run ocaml-protoc %{file} -I %{project_root}/vendor/opentelemetry-proto/ + -ml_out . -pp -binary))) + +(rule + (alias lint) + (mode promote) + (targets resource_types.ml resource_types.mli resource_pb.ml resource_pb.mli + resource_pp.ml resource_pp.mli) + (deps + (:file + %{project_root}/vendor/opentelemetry-proto/opentelemetry/proto/resource/v1/resource.proto) + (source_tree %{project_root}/vendor/opentelemetry-proto/)) + (action + (run ocaml-protoc %{file} -I %{project_root}/vendor/opentelemetry-proto/ + -ml_out . -pp -binary))) + +(rule + (alias lint) + (mode promote) + (targets trace_types.ml trace_types.mli trace_pb.ml trace_pb.mli trace_pp.ml + trace_pp.mli) + (deps + (:file + %{project_root}/vendor/opentelemetry-proto/opentelemetry/proto/trace/v1/trace.proto) + (source_tree %{project_root}/vendor/opentelemetry-proto/)) + (action + (run ocaml-protoc %{file} -I %{project_root}/vendor/opentelemetry-proto/ + -ml_out . -pp -binary))) + +(rule + (alias lint) + (mode promote) + (targets metrics_types.ml metrics_types.mli metrics_pb.ml metrics_pb.mli + metrics_pp.ml metrics_pp.mli) + (deps + (:file + %{project_root}/vendor/opentelemetry-proto/opentelemetry/proto/metrics/v1/metrics.proto) + (source_tree %{project_root}/vendor/opentelemetry-proto/)) + (action + (run ocaml-protoc %{file} -I %{project_root}/vendor/opentelemetry-proto/ + -ml_out . -pp -binary))) + +(rule + (alias lint) + (mode promote) + (targets logs_types.ml logs_types.mli logs_pb.ml logs_pb.mli logs_pp.ml + logs_pp.mli) + (deps + (:file + %{project_root}/vendor/opentelemetry-proto/opentelemetry/proto/logs/v1/logs.proto) + (source_tree %{project_root}/vendor/opentelemetry-proto/)) + (action + (run ocaml-protoc %{file} -I %{project_root}/vendor/opentelemetry-proto/ + -ml_out . -pp -binary))) + +(rule + (alias lint) + (mode promote) + (targets metrics_service_types.ml metrics_service_types.mli + metrics_service_pp.ml metrics_service_pp.mli metrics_service_pb.ml + metrics_service_pb.mli) + (deps + (:file + %{project_root}/vendor/opentelemetry-proto/opentelemetry/proto/collector/metrics/v1/metrics_service.proto) + (source_tree %{project_root}/vendor/opentelemetry-proto/)) + (action + (run ocaml-protoc %{file} -I %{project_root}/vendor/opentelemetry-proto/ + -ml_out . -pp -binary))) + +(rule + (alias lint) + (mode promote) + (targets trace_service_types.ml trace_service_types.mli trace_service_pp.ml + trace_service_pp.mli trace_service_pb.ml trace_service_pb.mli) + (deps + (:file + %{project_root}/vendor/opentelemetry-proto/opentelemetry/proto/collector/trace/v1/trace_service.proto) + (source_tree %{project_root}/vendor/opentelemetry-proto/)) + (action + (run ocaml-protoc %{file} -I %{project_root}/vendor/opentelemetry-proto/ + -ml_out . -pp -binary))) + +(rule + (alias lint) + (mode promote) + (targets logs_service_types.ml logs_service_types.mli logs_service_pp.ml + logs_service_pp.mli logs_service_pb.ml logs_service_pb.mli) + (deps + (:file + %{project_root}/vendor/opentelemetry-proto/opentelemetry/proto/collector/logs/v1/logs_service.proto) + (source_tree %{project_root}/vendor/opentelemetry-proto/)) + (action + (run ocaml-protoc %{file} -I %{project_root}/vendor/opentelemetry-proto/ + -ml_out . -pp -binary))) + diff --git a/src/proto/logs_pb.ml b/src/proto/logs_pb.ml new file mode 100644 index 00000000..2ad391c5 --- /dev/null +++ b/src/proto/logs_pb.ml @@ -0,0 +1,348 @@ +[@@@ocaml.warning "-27-30-39"] + +type log_record_mutable = { + mutable time_unix_nano : int64; + mutable observed_time_unix_nano : int64; + mutable severity_number : Logs_types.severity_number; + mutable severity_text : string; + mutable body : Common_types.any_value option; + mutable attributes : Common_types.key_value list; + mutable dropped_attributes_count : int32; + mutable flags : int32; + mutable trace_id : bytes; + mutable span_id : bytes; +} + +let default_log_record_mutable () : log_record_mutable = { + time_unix_nano = 0L; + observed_time_unix_nano = 0L; + severity_number = Logs_types.default_severity_number (); + severity_text = ""; + body = None; + attributes = []; + dropped_attributes_count = 0l; + flags = 0l; + trace_id = Bytes.create 0; + span_id = Bytes.create 0; +} + +type scope_logs_mutable = { + mutable scope : Common_types.instrumentation_scope option; + mutable log_records : Logs_types.log_record list; + mutable schema_url : string; +} + +let default_scope_logs_mutable () : scope_logs_mutable = { + scope = None; + log_records = []; + schema_url = ""; +} + +type resource_logs_mutable = { + mutable resource : Resource_types.resource option; + mutable scope_logs : Logs_types.scope_logs list; + mutable schema_url : string; +} + +let default_resource_logs_mutable () : resource_logs_mutable = { + resource = None; + scope_logs = []; + schema_url = ""; +} + +type logs_data_mutable = { + mutable resource_logs : Logs_types.resource_logs list; +} + +let default_logs_data_mutable () : logs_data_mutable = { + resource_logs = []; +} + + +let rec decode_severity_number d = + match Pbrt.Decoder.int_as_varint d with + | 0 -> (Logs_types.Severity_number_unspecified:Logs_types.severity_number) + | 1 -> (Logs_types.Severity_number_trace:Logs_types.severity_number) + | 2 -> (Logs_types.Severity_number_trace2:Logs_types.severity_number) + | 3 -> (Logs_types.Severity_number_trace3:Logs_types.severity_number) + | 4 -> (Logs_types.Severity_number_trace4:Logs_types.severity_number) + | 5 -> (Logs_types.Severity_number_debug:Logs_types.severity_number) + | 6 -> (Logs_types.Severity_number_debug2:Logs_types.severity_number) + | 7 -> (Logs_types.Severity_number_debug3:Logs_types.severity_number) + | 8 -> (Logs_types.Severity_number_debug4:Logs_types.severity_number) + | 9 -> (Logs_types.Severity_number_info:Logs_types.severity_number) + | 10 -> (Logs_types.Severity_number_info2:Logs_types.severity_number) + | 11 -> (Logs_types.Severity_number_info3:Logs_types.severity_number) + | 12 -> (Logs_types.Severity_number_info4:Logs_types.severity_number) + | 13 -> (Logs_types.Severity_number_warn:Logs_types.severity_number) + | 14 -> (Logs_types.Severity_number_warn2:Logs_types.severity_number) + | 15 -> (Logs_types.Severity_number_warn3:Logs_types.severity_number) + | 16 -> (Logs_types.Severity_number_warn4:Logs_types.severity_number) + | 17 -> (Logs_types.Severity_number_error:Logs_types.severity_number) + | 18 -> (Logs_types.Severity_number_error2:Logs_types.severity_number) + | 19 -> (Logs_types.Severity_number_error3:Logs_types.severity_number) + | 20 -> (Logs_types.Severity_number_error4:Logs_types.severity_number) + | 21 -> (Logs_types.Severity_number_fatal:Logs_types.severity_number) + | 22 -> (Logs_types.Severity_number_fatal2:Logs_types.severity_number) + | 23 -> (Logs_types.Severity_number_fatal3:Logs_types.severity_number) + | 24 -> (Logs_types.Severity_number_fatal4:Logs_types.severity_number) + | _ -> Pbrt.Decoder.malformed_variant "severity_number" + +let rec decode_log_record d = + let v = default_log_record_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.attributes <- List.rev v.attributes; + ); continue__ := false + | Some (1, Pbrt.Bits64) -> begin + v.time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(log_record), field(1)" pk + | Some (11, Pbrt.Bits64) -> begin + v.observed_time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; + end + | Some (11, pk) -> + Pbrt.Decoder.unexpected_payload "Message(log_record), field(11)" pk + | Some (2, Pbrt.Varint) -> begin + v.severity_number <- decode_severity_number d; + end + | Some (2, pk) -> + Pbrt.Decoder.unexpected_payload "Message(log_record), field(2)" pk + | Some (3, Pbrt.Bytes) -> begin + v.severity_text <- Pbrt.Decoder.string d; + end + | Some (3, pk) -> + Pbrt.Decoder.unexpected_payload "Message(log_record), field(3)" pk + | Some (5, Pbrt.Bytes) -> begin + v.body <- Some (Common_pb.decode_any_value (Pbrt.Decoder.nested d)); + end + | Some (5, pk) -> + Pbrt.Decoder.unexpected_payload "Message(log_record), field(5)" pk + | Some (6, Pbrt.Bytes) -> begin + v.attributes <- (Common_pb.decode_key_value (Pbrt.Decoder.nested d)) :: v.attributes; + end + | Some (6, pk) -> + Pbrt.Decoder.unexpected_payload "Message(log_record), field(6)" pk + | Some (7, Pbrt.Varint) -> begin + v.dropped_attributes_count <- Pbrt.Decoder.int32_as_varint d; + end + | Some (7, pk) -> + Pbrt.Decoder.unexpected_payload "Message(log_record), field(7)" pk + | Some (8, Pbrt.Bits32) -> begin + v.flags <- Pbrt.Decoder.int32_as_bits32 d; + end + | Some (8, pk) -> + Pbrt.Decoder.unexpected_payload "Message(log_record), field(8)" pk + | Some (9, Pbrt.Bytes) -> begin + v.trace_id <- Pbrt.Decoder.bytes d; + end + | Some (9, pk) -> + Pbrt.Decoder.unexpected_payload "Message(log_record), field(9)" pk + | Some (10, Pbrt.Bytes) -> begin + v.span_id <- Pbrt.Decoder.bytes d; + end + | Some (10, pk) -> + Pbrt.Decoder.unexpected_payload "Message(log_record), field(10)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Logs_types.time_unix_nano = v.time_unix_nano; + Logs_types.observed_time_unix_nano = v.observed_time_unix_nano; + Logs_types.severity_number = v.severity_number; + Logs_types.severity_text = v.severity_text; + Logs_types.body = v.body; + Logs_types.attributes = v.attributes; + Logs_types.dropped_attributes_count = v.dropped_attributes_count; + Logs_types.flags = v.flags; + Logs_types.trace_id = v.trace_id; + Logs_types.span_id = v.span_id; + } : Logs_types.log_record) + +let rec decode_scope_logs d = + let v = default_scope_logs_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.log_records <- List.rev v.log_records; + ); continue__ := false + | Some (1, Pbrt.Bytes) -> begin + v.scope <- Some (Common_pb.decode_instrumentation_scope (Pbrt.Decoder.nested d)); + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(scope_logs), field(1)" pk + | Some (2, Pbrt.Bytes) -> begin + v.log_records <- (decode_log_record (Pbrt.Decoder.nested d)) :: v.log_records; + end + | Some (2, pk) -> + Pbrt.Decoder.unexpected_payload "Message(scope_logs), field(2)" pk + | Some (3, Pbrt.Bytes) -> begin + v.schema_url <- Pbrt.Decoder.string d; + end + | Some (3, pk) -> + Pbrt.Decoder.unexpected_payload "Message(scope_logs), field(3)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Logs_types.scope = v.scope; + Logs_types.log_records = v.log_records; + Logs_types.schema_url = v.schema_url; + } : Logs_types.scope_logs) + +let rec decode_resource_logs d = + let v = default_resource_logs_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.scope_logs <- List.rev v.scope_logs; + ); continue__ := false + | Some (1, Pbrt.Bytes) -> begin + v.resource <- Some (Resource_pb.decode_resource (Pbrt.Decoder.nested d)); + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(resource_logs), field(1)" pk + | Some (2, Pbrt.Bytes) -> begin + v.scope_logs <- (decode_scope_logs (Pbrt.Decoder.nested d)) :: v.scope_logs; + end + | Some (2, pk) -> + Pbrt.Decoder.unexpected_payload "Message(resource_logs), field(2)" pk + | Some (3, Pbrt.Bytes) -> begin + v.schema_url <- Pbrt.Decoder.string d; + end + | Some (3, pk) -> + Pbrt.Decoder.unexpected_payload "Message(resource_logs), field(3)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Logs_types.resource = v.resource; + Logs_types.scope_logs = v.scope_logs; + Logs_types.schema_url = v.schema_url; + } : Logs_types.resource_logs) + +let rec decode_logs_data d = + let v = default_logs_data_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.resource_logs <- List.rev v.resource_logs; + ); continue__ := false + | Some (1, Pbrt.Bytes) -> begin + v.resource_logs <- (decode_resource_logs (Pbrt.Decoder.nested d)) :: v.resource_logs; + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(logs_data), field(1)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Logs_types.resource_logs = v.resource_logs; + } : Logs_types.logs_data) + +let rec decode_log_record_flags d = + match Pbrt.Decoder.int_as_varint d with + | 0 -> (Logs_types.Log_record_flags_do_not_use:Logs_types.log_record_flags) + | 255 -> (Logs_types.Log_record_flags_trace_flags_mask:Logs_types.log_record_flags) + | _ -> Pbrt.Decoder.malformed_variant "log_record_flags" + +let rec encode_severity_number (v:Logs_types.severity_number) encoder = + match v with + | Logs_types.Severity_number_unspecified -> Pbrt.Encoder.int_as_varint (0) encoder + | Logs_types.Severity_number_trace -> Pbrt.Encoder.int_as_varint 1 encoder + | Logs_types.Severity_number_trace2 -> Pbrt.Encoder.int_as_varint 2 encoder + | Logs_types.Severity_number_trace3 -> Pbrt.Encoder.int_as_varint 3 encoder + | Logs_types.Severity_number_trace4 -> Pbrt.Encoder.int_as_varint 4 encoder + | Logs_types.Severity_number_debug -> Pbrt.Encoder.int_as_varint 5 encoder + | Logs_types.Severity_number_debug2 -> Pbrt.Encoder.int_as_varint 6 encoder + | Logs_types.Severity_number_debug3 -> Pbrt.Encoder.int_as_varint 7 encoder + | Logs_types.Severity_number_debug4 -> Pbrt.Encoder.int_as_varint 8 encoder + | Logs_types.Severity_number_info -> Pbrt.Encoder.int_as_varint 9 encoder + | Logs_types.Severity_number_info2 -> Pbrt.Encoder.int_as_varint 10 encoder + | Logs_types.Severity_number_info3 -> Pbrt.Encoder.int_as_varint 11 encoder + | Logs_types.Severity_number_info4 -> Pbrt.Encoder.int_as_varint 12 encoder + | Logs_types.Severity_number_warn -> Pbrt.Encoder.int_as_varint 13 encoder + | Logs_types.Severity_number_warn2 -> Pbrt.Encoder.int_as_varint 14 encoder + | Logs_types.Severity_number_warn3 -> Pbrt.Encoder.int_as_varint 15 encoder + | Logs_types.Severity_number_warn4 -> Pbrt.Encoder.int_as_varint 16 encoder + | Logs_types.Severity_number_error -> Pbrt.Encoder.int_as_varint 17 encoder + | Logs_types.Severity_number_error2 -> Pbrt.Encoder.int_as_varint 18 encoder + | Logs_types.Severity_number_error3 -> Pbrt.Encoder.int_as_varint 19 encoder + | Logs_types.Severity_number_error4 -> Pbrt.Encoder.int_as_varint 20 encoder + | Logs_types.Severity_number_fatal -> Pbrt.Encoder.int_as_varint 21 encoder + | Logs_types.Severity_number_fatal2 -> Pbrt.Encoder.int_as_varint 22 encoder + | Logs_types.Severity_number_fatal3 -> Pbrt.Encoder.int_as_varint 23 encoder + | Logs_types.Severity_number_fatal4 -> Pbrt.Encoder.int_as_varint 24 encoder + +let rec encode_log_record (v:Logs_types.log_record) encoder = + Pbrt.Encoder.key (1, Pbrt.Bits64) encoder; + Pbrt.Encoder.int64_as_bits64 v.Logs_types.time_unix_nano encoder; + Pbrt.Encoder.key (11, Pbrt.Bits64) encoder; + Pbrt.Encoder.int64_as_bits64 v.Logs_types.observed_time_unix_nano encoder; + Pbrt.Encoder.key (2, Pbrt.Varint) encoder; + encode_severity_number v.Logs_types.severity_number encoder; + Pbrt.Encoder.key (3, Pbrt.Bytes) encoder; + Pbrt.Encoder.string v.Logs_types.severity_text encoder; + begin match v.Logs_types.body with + | Some x -> + Pbrt.Encoder.key (5, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (Common_pb.encode_any_value x) encoder; + | None -> (); + end; + List.iter (fun x -> + Pbrt.Encoder.key (6, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (Common_pb.encode_key_value x) encoder; + ) v.Logs_types.attributes; + Pbrt.Encoder.key (7, Pbrt.Varint) encoder; + Pbrt.Encoder.int32_as_varint v.Logs_types.dropped_attributes_count encoder; + Pbrt.Encoder.key (8, Pbrt.Bits32) encoder; + Pbrt.Encoder.int32_as_bits32 v.Logs_types.flags encoder; + Pbrt.Encoder.key (9, Pbrt.Bytes) encoder; + Pbrt.Encoder.bytes v.Logs_types.trace_id encoder; + Pbrt.Encoder.key (10, Pbrt.Bytes) encoder; + Pbrt.Encoder.bytes v.Logs_types.span_id encoder; + () + +let rec encode_scope_logs (v:Logs_types.scope_logs) encoder = + begin match v.Logs_types.scope with + | Some x -> + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (Common_pb.encode_instrumentation_scope x) encoder; + | None -> (); + end; + List.iter (fun x -> + Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_log_record x) encoder; + ) v.Logs_types.log_records; + Pbrt.Encoder.key (3, Pbrt.Bytes) encoder; + Pbrt.Encoder.string v.Logs_types.schema_url encoder; + () + +let rec encode_resource_logs (v:Logs_types.resource_logs) encoder = + begin match v.Logs_types.resource with + | Some x -> + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (Resource_pb.encode_resource x) encoder; + | None -> (); + end; + List.iter (fun x -> + Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_scope_logs x) encoder; + ) v.Logs_types.scope_logs; + Pbrt.Encoder.key (3, Pbrt.Bytes) encoder; + Pbrt.Encoder.string v.Logs_types.schema_url encoder; + () + +let rec encode_logs_data (v:Logs_types.logs_data) encoder = + List.iter (fun x -> + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_resource_logs x) encoder; + ) v.Logs_types.resource_logs; + () + +let rec encode_log_record_flags (v:Logs_types.log_record_flags) encoder = + match v with + | Logs_types.Log_record_flags_do_not_use -> Pbrt.Encoder.int_as_varint (0) encoder + | Logs_types.Log_record_flags_trace_flags_mask -> Pbrt.Encoder.int_as_varint 255 encoder diff --git a/src/proto/logs_pb.mli b/src/proto/logs_pb.mli new file mode 100644 index 00000000..93e6d369 --- /dev/null +++ b/src/proto/logs_pb.mli @@ -0,0 +1,43 @@ +(** logs.proto Binary Encoding *) + + +(** {2 Protobuf Encoding} *) + +val encode_severity_number : Logs_types.severity_number -> Pbrt.Encoder.t -> unit +(** [encode_severity_number v encoder] encodes [v] with the given [encoder] *) + +val encode_log_record : Logs_types.log_record -> Pbrt.Encoder.t -> unit +(** [encode_log_record v encoder] encodes [v] with the given [encoder] *) + +val encode_scope_logs : Logs_types.scope_logs -> Pbrt.Encoder.t -> unit +(** [encode_scope_logs v encoder] encodes [v] with the given [encoder] *) + +val encode_resource_logs : Logs_types.resource_logs -> Pbrt.Encoder.t -> unit +(** [encode_resource_logs v encoder] encodes [v] with the given [encoder] *) + +val encode_logs_data : Logs_types.logs_data -> Pbrt.Encoder.t -> unit +(** [encode_logs_data v encoder] encodes [v] with the given [encoder] *) + +val encode_log_record_flags : Logs_types.log_record_flags -> Pbrt.Encoder.t -> unit +(** [encode_log_record_flags v encoder] encodes [v] with the given [encoder] *) + + +(** {2 Protobuf Decoding} *) + +val decode_severity_number : Pbrt.Decoder.t -> Logs_types.severity_number +(** [decode_severity_number decoder] decodes a [severity_number] value from [decoder] *) + +val decode_log_record : Pbrt.Decoder.t -> Logs_types.log_record +(** [decode_log_record decoder] decodes a [log_record] value from [decoder] *) + +val decode_scope_logs : Pbrt.Decoder.t -> Logs_types.scope_logs +(** [decode_scope_logs decoder] decodes a [scope_logs] value from [decoder] *) + +val decode_resource_logs : Pbrt.Decoder.t -> Logs_types.resource_logs +(** [decode_resource_logs decoder] decodes a [resource_logs] value from [decoder] *) + +val decode_logs_data : Pbrt.Decoder.t -> Logs_types.logs_data +(** [decode_logs_data decoder] decodes a [logs_data] value from [decoder] *) + +val decode_log_record_flags : Pbrt.Decoder.t -> Logs_types.log_record_flags +(** [decode_log_record_flags decoder] decodes a [log_record_flags] value from [decoder] *) diff --git a/src/proto/logs_pp.ml b/src/proto/logs_pp.ml new file mode 100644 index 00000000..408f01d9 --- /dev/null +++ b/src/proto/logs_pp.ml @@ -0,0 +1,71 @@ +[@@@ocaml.warning "-27-30-39"] + +let rec pp_severity_number fmt (v:Logs_types.severity_number) = + match v with + | Logs_types.Severity_number_unspecified -> Format.fprintf fmt "Severity_number_unspecified" + | Logs_types.Severity_number_trace -> Format.fprintf fmt "Severity_number_trace" + | Logs_types.Severity_number_trace2 -> Format.fprintf fmt "Severity_number_trace2" + | Logs_types.Severity_number_trace3 -> Format.fprintf fmt "Severity_number_trace3" + | Logs_types.Severity_number_trace4 -> Format.fprintf fmt "Severity_number_trace4" + | Logs_types.Severity_number_debug -> Format.fprintf fmt "Severity_number_debug" + | Logs_types.Severity_number_debug2 -> Format.fprintf fmt "Severity_number_debug2" + | Logs_types.Severity_number_debug3 -> Format.fprintf fmt "Severity_number_debug3" + | Logs_types.Severity_number_debug4 -> Format.fprintf fmt "Severity_number_debug4" + | Logs_types.Severity_number_info -> Format.fprintf fmt "Severity_number_info" + | Logs_types.Severity_number_info2 -> Format.fprintf fmt "Severity_number_info2" + | Logs_types.Severity_number_info3 -> Format.fprintf fmt "Severity_number_info3" + | Logs_types.Severity_number_info4 -> Format.fprintf fmt "Severity_number_info4" + | Logs_types.Severity_number_warn -> Format.fprintf fmt "Severity_number_warn" + | Logs_types.Severity_number_warn2 -> Format.fprintf fmt "Severity_number_warn2" + | Logs_types.Severity_number_warn3 -> Format.fprintf fmt "Severity_number_warn3" + | Logs_types.Severity_number_warn4 -> Format.fprintf fmt "Severity_number_warn4" + | Logs_types.Severity_number_error -> Format.fprintf fmt "Severity_number_error" + | Logs_types.Severity_number_error2 -> Format.fprintf fmt "Severity_number_error2" + | Logs_types.Severity_number_error3 -> Format.fprintf fmt "Severity_number_error3" + | Logs_types.Severity_number_error4 -> Format.fprintf fmt "Severity_number_error4" + | Logs_types.Severity_number_fatal -> Format.fprintf fmt "Severity_number_fatal" + | Logs_types.Severity_number_fatal2 -> Format.fprintf fmt "Severity_number_fatal2" + | Logs_types.Severity_number_fatal3 -> Format.fprintf fmt "Severity_number_fatal3" + | Logs_types.Severity_number_fatal4 -> Format.fprintf fmt "Severity_number_fatal4" + +let rec pp_log_record fmt (v:Logs_types.log_record) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Logs_types.time_unix_nano; + Pbrt.Pp.pp_record_field ~first:false "observed_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Logs_types.observed_time_unix_nano; + Pbrt.Pp.pp_record_field ~first:false "severity_number" pp_severity_number fmt v.Logs_types.severity_number; + Pbrt.Pp.pp_record_field ~first:false "severity_text" Pbrt.Pp.pp_string fmt v.Logs_types.severity_text; + Pbrt.Pp.pp_record_field ~first:false "body" (Pbrt.Pp.pp_option Common_pp.pp_any_value) fmt v.Logs_types.body; + Pbrt.Pp.pp_record_field ~first:false "attributes" (Pbrt.Pp.pp_list Common_pp.pp_key_value) fmt v.Logs_types.attributes; + Pbrt.Pp.pp_record_field ~first:false "dropped_attributes_count" Pbrt.Pp.pp_int32 fmt v.Logs_types.dropped_attributes_count; + Pbrt.Pp.pp_record_field ~first:false "flags" Pbrt.Pp.pp_int32 fmt v.Logs_types.flags; + Pbrt.Pp.pp_record_field ~first:false "trace_id" Pbrt.Pp.pp_bytes fmt v.Logs_types.trace_id; + Pbrt.Pp.pp_record_field ~first:false "span_id" Pbrt.Pp.pp_bytes fmt v.Logs_types.span_id; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_scope_logs fmt (v:Logs_types.scope_logs) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "scope" (Pbrt.Pp.pp_option Common_pp.pp_instrumentation_scope) fmt v.Logs_types.scope; + Pbrt.Pp.pp_record_field ~first:false "log_records" (Pbrt.Pp.pp_list pp_log_record) fmt v.Logs_types.log_records; + Pbrt.Pp.pp_record_field ~first:false "schema_url" Pbrt.Pp.pp_string fmt v.Logs_types.schema_url; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_resource_logs fmt (v:Logs_types.resource_logs) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "resource" (Pbrt.Pp.pp_option Resource_pp.pp_resource) fmt v.Logs_types.resource; + Pbrt.Pp.pp_record_field ~first:false "scope_logs" (Pbrt.Pp.pp_list pp_scope_logs) fmt v.Logs_types.scope_logs; + Pbrt.Pp.pp_record_field ~first:false "schema_url" Pbrt.Pp.pp_string fmt v.Logs_types.schema_url; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_logs_data fmt (v:Logs_types.logs_data) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "resource_logs" (Pbrt.Pp.pp_list pp_resource_logs) fmt v.Logs_types.resource_logs; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_log_record_flags fmt (v:Logs_types.log_record_flags) = + match v with + | Logs_types.Log_record_flags_do_not_use -> Format.fprintf fmt "Log_record_flags_do_not_use" + | Logs_types.Log_record_flags_trace_flags_mask -> Format.fprintf fmt "Log_record_flags_trace_flags_mask" diff --git a/src/proto/logs_pp.mli b/src/proto/logs_pp.mli new file mode 100644 index 00000000..ecbc28a2 --- /dev/null +++ b/src/proto/logs_pp.mli @@ -0,0 +1,23 @@ + +(** logs.proto Pretty Printing *) + + +(** {2 Formatters} *) + +val pp_severity_number : Format.formatter -> Logs_types.severity_number -> unit +(** [pp_severity_number v] formats v *) + +val pp_log_record : Format.formatter -> Logs_types.log_record -> unit +(** [pp_log_record v] formats v *) + +val pp_scope_logs : Format.formatter -> Logs_types.scope_logs -> unit +(** [pp_scope_logs v] formats v *) + +val pp_resource_logs : Format.formatter -> Logs_types.resource_logs -> unit +(** [pp_resource_logs v] formats v *) + +val pp_logs_data : Format.formatter -> Logs_types.logs_data -> unit +(** [pp_logs_data v] formats v *) + +val pp_log_record_flags : Format.formatter -> Logs_types.log_record_flags -> unit +(** [pp_log_record_flags v] formats v *) diff --git a/src/proto/logs_service_pb.ml b/src/proto/logs_service_pb.ml new file mode 100644 index 00000000..64fde20f --- /dev/null +++ b/src/proto/logs_service_pb.ml @@ -0,0 +1,112 @@ +[@@@ocaml.warning "-27-30-39"] + +type export_logs_service_request_mutable = { + mutable resource_logs : Logs_types.resource_logs list; +} + +let default_export_logs_service_request_mutable () : export_logs_service_request_mutable = { + resource_logs = []; +} + +type export_logs_partial_success_mutable = { + mutable rejected_log_records : int64; + mutable error_message : string; +} + +let default_export_logs_partial_success_mutable () : export_logs_partial_success_mutable = { + rejected_log_records = 0L; + error_message = ""; +} + +type export_logs_service_response_mutable = { + mutable partial_success : Logs_service_types.export_logs_partial_success option; +} + +let default_export_logs_service_response_mutable () : export_logs_service_response_mutable = { + partial_success = None; +} + + +let rec decode_export_logs_service_request d = + let v = default_export_logs_service_request_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.resource_logs <- List.rev v.resource_logs; + ); continue__ := false + | Some (1, Pbrt.Bytes) -> begin + v.resource_logs <- (Logs_pb.decode_resource_logs (Pbrt.Decoder.nested d)) :: v.resource_logs; + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(export_logs_service_request), field(1)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Logs_service_types.resource_logs = v.resource_logs; + } : Logs_service_types.export_logs_service_request) + +let rec decode_export_logs_partial_success d = + let v = default_export_logs_partial_success_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + ); continue__ := false + | Some (1, Pbrt.Varint) -> begin + v.rejected_log_records <- Pbrt.Decoder.int64_as_varint d; + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(export_logs_partial_success), field(1)" pk + | Some (2, Pbrt.Bytes) -> begin + v.error_message <- Pbrt.Decoder.string d; + end + | Some (2, pk) -> + Pbrt.Decoder.unexpected_payload "Message(export_logs_partial_success), field(2)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Logs_service_types.rejected_log_records = v.rejected_log_records; + Logs_service_types.error_message = v.error_message; + } : Logs_service_types.export_logs_partial_success) + +let rec decode_export_logs_service_response d = + let v = default_export_logs_service_response_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + ); continue__ := false + | Some (1, Pbrt.Bytes) -> begin + v.partial_success <- Some (decode_export_logs_partial_success (Pbrt.Decoder.nested d)); + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(export_logs_service_response), field(1)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Logs_service_types.partial_success = v.partial_success; + } : Logs_service_types.export_logs_service_response) + +let rec encode_export_logs_service_request (v:Logs_service_types.export_logs_service_request) encoder = + List.iter (fun x -> + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (Logs_pb.encode_resource_logs x) encoder; + ) v.Logs_service_types.resource_logs; + () + +let rec encode_export_logs_partial_success (v:Logs_service_types.export_logs_partial_success) encoder = + Pbrt.Encoder.key (1, Pbrt.Varint) encoder; + Pbrt.Encoder.int64_as_varint v.Logs_service_types.rejected_log_records encoder; + Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; + Pbrt.Encoder.string v.Logs_service_types.error_message encoder; + () + +let rec encode_export_logs_service_response (v:Logs_service_types.export_logs_service_response) encoder = + begin match v.Logs_service_types.partial_success with + | Some x -> + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_export_logs_partial_success x) encoder; + | None -> (); + end; + () diff --git a/src/proto/logs_service_pb.mli b/src/proto/logs_service_pb.mli new file mode 100644 index 00000000..db4d8c89 --- /dev/null +++ b/src/proto/logs_service_pb.mli @@ -0,0 +1,25 @@ +(** logs_service.proto Binary Encoding *) + + +(** {2 Protobuf Encoding} *) + +val encode_export_logs_service_request : Logs_service_types.export_logs_service_request -> Pbrt.Encoder.t -> unit +(** [encode_export_logs_service_request v encoder] encodes [v] with the given [encoder] *) + +val encode_export_logs_partial_success : Logs_service_types.export_logs_partial_success -> Pbrt.Encoder.t -> unit +(** [encode_export_logs_partial_success v encoder] encodes [v] with the given [encoder] *) + +val encode_export_logs_service_response : Logs_service_types.export_logs_service_response -> Pbrt.Encoder.t -> unit +(** [encode_export_logs_service_response v encoder] encodes [v] with the given [encoder] *) + + +(** {2 Protobuf Decoding} *) + +val decode_export_logs_service_request : Pbrt.Decoder.t -> Logs_service_types.export_logs_service_request +(** [decode_export_logs_service_request decoder] decodes a [export_logs_service_request] value from [decoder] *) + +val decode_export_logs_partial_success : Pbrt.Decoder.t -> Logs_service_types.export_logs_partial_success +(** [decode_export_logs_partial_success decoder] decodes a [export_logs_partial_success] value from [decoder] *) + +val decode_export_logs_service_response : Pbrt.Decoder.t -> Logs_service_types.export_logs_service_response +(** [decode_export_logs_service_response decoder] decodes a [export_logs_service_response] value from [decoder] *) diff --git a/src/proto/logs_service_pp.ml b/src/proto/logs_service_pp.ml new file mode 100644 index 00000000..19830e4c --- /dev/null +++ b/src/proto/logs_service_pp.ml @@ -0,0 +1,20 @@ +[@@@ocaml.warning "-27-30-39"] + +let rec pp_export_logs_service_request fmt (v:Logs_service_types.export_logs_service_request) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "resource_logs" (Pbrt.Pp.pp_list Logs_pp.pp_resource_logs) fmt v.Logs_service_types.resource_logs; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_export_logs_partial_success fmt (v:Logs_service_types.export_logs_partial_success) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "rejected_log_records" Pbrt.Pp.pp_int64 fmt v.Logs_service_types.rejected_log_records; + Pbrt.Pp.pp_record_field ~first:false "error_message" Pbrt.Pp.pp_string fmt v.Logs_service_types.error_message; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_export_logs_service_response fmt (v:Logs_service_types.export_logs_service_response) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "partial_success" (Pbrt.Pp.pp_option pp_export_logs_partial_success) fmt v.Logs_service_types.partial_success; + in + Pbrt.Pp.pp_brk pp_i fmt () diff --git a/src/proto/logs_service_pp.mli b/src/proto/logs_service_pp.mli new file mode 100644 index 00000000..31d4613a --- /dev/null +++ b/src/proto/logs_service_pp.mli @@ -0,0 +1,14 @@ + +(** logs_service.proto Pretty Printing *) + + +(** {2 Formatters} *) + +val pp_export_logs_service_request : Format.formatter -> Logs_service_types.export_logs_service_request -> unit +(** [pp_export_logs_service_request v] formats v *) + +val pp_export_logs_partial_success : Format.formatter -> Logs_service_types.export_logs_partial_success -> unit +(** [pp_export_logs_partial_success v] formats v *) + +val pp_export_logs_service_response : Format.formatter -> Logs_service_types.export_logs_service_response -> unit +(** [pp_export_logs_service_response v] formats v *) diff --git a/src/proto/logs_service_types.ml b/src/proto/logs_service_types.ml new file mode 100644 index 00000000..9bf19974 --- /dev/null +++ b/src/proto/logs_service_types.ml @@ -0,0 +1,35 @@ +[@@@ocaml.warning "-27-30-39"] + + +type export_logs_service_request = { + resource_logs : Logs_types.resource_logs list; +} + +type export_logs_partial_success = { + rejected_log_records : int64; + error_message : string; +} + +type export_logs_service_response = { + partial_success : export_logs_partial_success option; +} + +let rec default_export_logs_service_request + ?resource_logs:((resource_logs:Logs_types.resource_logs list) = []) + () : export_logs_service_request = { + resource_logs; +} + +let rec default_export_logs_partial_success + ?rejected_log_records:((rejected_log_records:int64) = 0L) + ?error_message:((error_message:string) = "") + () : export_logs_partial_success = { + rejected_log_records; + error_message; +} + +let rec default_export_logs_service_response + ?partial_success:((partial_success:export_logs_partial_success option) = None) + () : export_logs_service_response = { + partial_success; +} diff --git a/src/proto/logs_service_types.mli b/src/proto/logs_service_types.mli new file mode 100644 index 00000000..beef4fd3 --- /dev/null +++ b/src/proto/logs_service_types.mli @@ -0,0 +1,40 @@ +(** logs_service.proto Types *) + + + +(** {2 Types} *) + +type export_logs_service_request = { + resource_logs : Logs_types.resource_logs list; +} + +type export_logs_partial_success = { + rejected_log_records : int64; + error_message : string; +} + +type export_logs_service_response = { + partial_success : export_logs_partial_success option; +} + + +(** {2 Default values} *) + +val default_export_logs_service_request : + ?resource_logs:Logs_types.resource_logs list -> + unit -> + export_logs_service_request +(** [default_export_logs_service_request ()] is the default value for type [export_logs_service_request] *) + +val default_export_logs_partial_success : + ?rejected_log_records:int64 -> + ?error_message:string -> + unit -> + export_logs_partial_success +(** [default_export_logs_partial_success ()] is the default value for type [export_logs_partial_success] *) + +val default_export_logs_service_response : + ?partial_success:export_logs_partial_success option -> + unit -> + export_logs_service_response +(** [default_export_logs_service_response ()] is the default value for type [export_logs_service_response] *) diff --git a/src/proto/logs_types.ml b/src/proto/logs_types.ml new file mode 100644 index 00000000..4a383ff7 --- /dev/null +++ b/src/proto/logs_types.ml @@ -0,0 +1,116 @@ +[@@@ocaml.warning "-27-30-39"] + + +type severity_number = + | Severity_number_unspecified + | Severity_number_trace + | Severity_number_trace2 + | Severity_number_trace3 + | Severity_number_trace4 + | Severity_number_debug + | Severity_number_debug2 + | Severity_number_debug3 + | Severity_number_debug4 + | Severity_number_info + | Severity_number_info2 + | Severity_number_info3 + | Severity_number_info4 + | Severity_number_warn + | Severity_number_warn2 + | Severity_number_warn3 + | Severity_number_warn4 + | Severity_number_error + | Severity_number_error2 + | Severity_number_error3 + | Severity_number_error4 + | Severity_number_fatal + | Severity_number_fatal2 + | Severity_number_fatal3 + | Severity_number_fatal4 + +type log_record = { + time_unix_nano : int64; + observed_time_unix_nano : int64; + severity_number : severity_number; + severity_text : string; + body : Common_types.any_value option; + attributes : Common_types.key_value list; + dropped_attributes_count : int32; + flags : int32; + trace_id : bytes; + span_id : bytes; +} + +type scope_logs = { + scope : Common_types.instrumentation_scope option; + log_records : log_record list; + schema_url : string; +} + +type resource_logs = { + resource : Resource_types.resource option; + scope_logs : scope_logs list; + schema_url : string; +} + +type logs_data = { + resource_logs : resource_logs list; +} + +type log_record_flags = + | Log_record_flags_do_not_use + | Log_record_flags_trace_flags_mask + +let rec default_severity_number () = (Severity_number_unspecified:severity_number) + +let rec default_log_record + ?time_unix_nano:((time_unix_nano:int64) = 0L) + ?observed_time_unix_nano:((observed_time_unix_nano:int64) = 0L) + ?severity_number:((severity_number:severity_number) = default_severity_number ()) + ?severity_text:((severity_text:string) = "") + ?body:((body:Common_types.any_value option) = None) + ?attributes:((attributes:Common_types.key_value list) = []) + ?dropped_attributes_count:((dropped_attributes_count:int32) = 0l) + ?flags:((flags:int32) = 0l) + ?trace_id:((trace_id:bytes) = Bytes.create 0) + ?span_id:((span_id:bytes) = Bytes.create 0) + () : log_record = { + time_unix_nano; + observed_time_unix_nano; + severity_number; + severity_text; + body; + attributes; + dropped_attributes_count; + flags; + trace_id; + span_id; +} + +let rec default_scope_logs + ?scope:((scope:Common_types.instrumentation_scope option) = None) + ?log_records:((log_records:log_record list) = []) + ?schema_url:((schema_url:string) = "") + () : scope_logs = { + scope; + log_records; + schema_url; +} + +let rec default_resource_logs + ?resource:((resource:Resource_types.resource option) = None) + ?scope_logs:((scope_logs:scope_logs list) = []) + ?schema_url:((schema_url:string) = "") + () : resource_logs = { + resource; + scope_logs; + schema_url; +} + +let rec default_logs_data + ?resource_logs:((resource_logs:resource_logs list) = []) + () : logs_data = { + resource_logs; +} + +let rec default_log_record_flags () = (Log_record_flags_do_not_use:log_record_flags) diff --git a/src/proto/logs_types.mli b/src/proto/logs_types.mli new file mode 100644 index 00000000..7a9cc1a3 --- /dev/null +++ b/src/proto/logs_types.mli @@ -0,0 +1,111 @@ +(** logs.proto Types *) + + + +(** {2 Types} *) + +type severity_number = + | Severity_number_unspecified + | Severity_number_trace + | Severity_number_trace2 + | Severity_number_trace3 + | Severity_number_trace4 + | Severity_number_debug + | Severity_number_debug2 + | Severity_number_debug3 + | Severity_number_debug4 + | Severity_number_info + | Severity_number_info2 + | Severity_number_info3 + | Severity_number_info4 + | Severity_number_warn + | Severity_number_warn2 + | Severity_number_warn3 + | Severity_number_warn4 + | Severity_number_error + | Severity_number_error2 + | Severity_number_error3 + | Severity_number_error4 + | Severity_number_fatal + | Severity_number_fatal2 + | Severity_number_fatal3 + | Severity_number_fatal4 + +type log_record = { + time_unix_nano : int64; + observed_time_unix_nano : int64; + severity_number : severity_number; + severity_text : string; + body : Common_types.any_value option; + attributes : Common_types.key_value list; + dropped_attributes_count : int32; + flags : int32; + trace_id : bytes; + span_id : bytes; +} + +type scope_logs = { + scope : Common_types.instrumentation_scope option; + log_records : log_record list; + schema_url : string; +} + +type resource_logs = { + resource : Resource_types.resource option; + scope_logs : scope_logs list; + schema_url : string; +} + +type logs_data = { + resource_logs : resource_logs list; +} + +type log_record_flags = + | Log_record_flags_do_not_use + | Log_record_flags_trace_flags_mask + + +(** {2 Default values} *) + +val default_severity_number : unit -> severity_number +(** [default_severity_number ()] is the default value for type [severity_number] *) + +val default_log_record : + ?time_unix_nano:int64 -> + ?observed_time_unix_nano:int64 -> + ?severity_number:severity_number -> + ?severity_text:string -> + ?body:Common_types.any_value option -> + ?attributes:Common_types.key_value list -> + ?dropped_attributes_count:int32 -> + ?flags:int32 -> + ?trace_id:bytes -> + ?span_id:bytes -> + unit -> + log_record +(** [default_log_record ()] is the default value for type [log_record] *) + +val default_scope_logs : + ?scope:Common_types.instrumentation_scope option -> + ?log_records:log_record list -> + ?schema_url:string -> + unit -> + scope_logs +(** [default_scope_logs ()] is the default value for type [scope_logs] *) + +val default_resource_logs : + ?resource:Resource_types.resource option -> + ?scope_logs:scope_logs list -> + ?schema_url:string -> + unit -> + resource_logs +(** [default_resource_logs ()] is the default value for type [resource_logs] *) + +val default_logs_data : + ?resource_logs:resource_logs list -> + unit -> + logs_data +(** [default_logs_data ()] is the default value for type [logs_data] *) + +val default_log_record_flags : unit -> log_record_flags +(** [default_log_record_flags ()] is the default value for type [log_record_flags] *) diff --git a/src/proto/metrics_pb.ml b/src/proto/metrics_pb.ml new file mode 100644 index 00000000..0c4ed447 --- /dev/null +++ b/src/proto/metrics_pb.ml @@ -0,0 +1,1282 @@ +[@@@ocaml.warning "-27-30-39"] + +type summary_data_point_value_at_quantile_mutable = { + mutable quantile : float; + mutable value : float; +} + +let default_summary_data_point_value_at_quantile_mutable () : summary_data_point_value_at_quantile_mutable = { + quantile = 0.; + value = 0.; +} + +type summary_data_point_mutable = { + mutable attributes : Common_types.key_value list; + mutable start_time_unix_nano : int64; + mutable time_unix_nano : int64; + mutable count : int64; + mutable sum : float; + mutable quantile_values : Metrics_types.summary_data_point_value_at_quantile list; + mutable flags : int32; +} + +let default_summary_data_point_mutable () : summary_data_point_mutable = { + attributes = []; + start_time_unix_nano = 0L; + time_unix_nano = 0L; + count = 0L; + sum = 0.; + quantile_values = []; + flags = 0l; +} + +type summary_mutable = { + mutable data_points : Metrics_types.summary_data_point list; +} + +let default_summary_mutable () : summary_mutable = { + data_points = []; +} + +type exponential_histogram_data_point_buckets_mutable = { + mutable offset : int32; + mutable bucket_counts : int64 list; +} + +let default_exponential_histogram_data_point_buckets_mutable () : exponential_histogram_data_point_buckets_mutable = { + offset = 0l; + bucket_counts = []; +} + +type exemplar_mutable = { + mutable filtered_attributes : Common_types.key_value list; + mutable time_unix_nano : int64; + mutable value : Metrics_types.exemplar_value; + mutable span_id : bytes; + mutable trace_id : bytes; +} + +let default_exemplar_mutable () : exemplar_mutable = { + filtered_attributes = []; + time_unix_nano = 0L; + value = Metrics_types.As_int (0L); + span_id = Bytes.create 0; + trace_id = Bytes.create 0; +} + +type exponential_histogram_data_point_mutable = { + mutable attributes : Common_types.key_value list; + mutable start_time_unix_nano : int64; + mutable time_unix_nano : int64; + mutable count : int64; + mutable sum : float option; + mutable scale : int32; + mutable zero_count : int64; + mutable positive : Metrics_types.exponential_histogram_data_point_buckets option; + mutable negative : Metrics_types.exponential_histogram_data_point_buckets option; + mutable flags : int32; + mutable exemplars : Metrics_types.exemplar list; + mutable min : float option; + mutable max : float option; + mutable zero_threshold : float; +} + +let default_exponential_histogram_data_point_mutable () : exponential_histogram_data_point_mutable = { + attributes = []; + start_time_unix_nano = 0L; + time_unix_nano = 0L; + count = 0L; + sum = None; + scale = 0l; + zero_count = 0L; + positive = None; + negative = None; + flags = 0l; + exemplars = []; + min = None; + max = None; + zero_threshold = 0.; +} + +type exponential_histogram_mutable = { + mutable data_points : Metrics_types.exponential_histogram_data_point list; + mutable aggregation_temporality : Metrics_types.aggregation_temporality; +} + +let default_exponential_histogram_mutable () : exponential_histogram_mutable = { + data_points = []; + aggregation_temporality = Metrics_types.default_aggregation_temporality (); +} + +type histogram_data_point_mutable = { + mutable attributes : Common_types.key_value list; + mutable start_time_unix_nano : int64; + mutable time_unix_nano : int64; + mutable count : int64; + mutable sum : float option; + mutable bucket_counts : int64 list; + mutable explicit_bounds : float list; + mutable exemplars : Metrics_types.exemplar list; + mutable flags : int32; + mutable min : float option; + mutable max : float option; +} + +let default_histogram_data_point_mutable () : histogram_data_point_mutable = { + attributes = []; + start_time_unix_nano = 0L; + time_unix_nano = 0L; + count = 0L; + sum = None; + bucket_counts = []; + explicit_bounds = []; + exemplars = []; + flags = 0l; + min = None; + max = None; +} + +type histogram_mutable = { + mutable data_points : Metrics_types.histogram_data_point list; + mutable aggregation_temporality : Metrics_types.aggregation_temporality; +} + +let default_histogram_mutable () : histogram_mutable = { + data_points = []; + aggregation_temporality = Metrics_types.default_aggregation_temporality (); +} + +type number_data_point_mutable = { + mutable attributes : Common_types.key_value list; + mutable start_time_unix_nano : int64; + mutable time_unix_nano : int64; + mutable value : Metrics_types.number_data_point_value; + mutable exemplars : Metrics_types.exemplar list; + mutable flags : int32; +} + +let default_number_data_point_mutable () : number_data_point_mutable = { + attributes = []; + start_time_unix_nano = 0L; + time_unix_nano = 0L; + value = Metrics_types.As_int (0L); + exemplars = []; + flags = 0l; +} + +type sum_mutable = { + mutable data_points : Metrics_types.number_data_point list; + mutable aggregation_temporality : Metrics_types.aggregation_temporality; + mutable is_monotonic : bool; +} + +let default_sum_mutable () : sum_mutable = { + data_points = []; + aggregation_temporality = Metrics_types.default_aggregation_temporality (); + is_monotonic = false; +} + +type gauge_mutable = { + mutable data_points : Metrics_types.number_data_point list; +} + +let default_gauge_mutable () : gauge_mutable = { + data_points = []; +} + +type metric_mutable = { + mutable name : string; + mutable description : string; + mutable unit_ : string; + mutable data : Metrics_types.metric_data; +} + +let default_metric_mutable () : metric_mutable = { + name = ""; + description = ""; + unit_ = ""; + data = Metrics_types.Summary (Metrics_types.default_summary ()); +} + +type scope_metrics_mutable = { + mutable scope : Common_types.instrumentation_scope option; + mutable metrics : Metrics_types.metric list; + mutable schema_url : string; +} + +let default_scope_metrics_mutable () : scope_metrics_mutable = { + scope = None; + metrics = []; + schema_url = ""; +} + +type resource_metrics_mutable = { + mutable resource : Resource_types.resource option; + mutable scope_metrics : Metrics_types.scope_metrics list; + mutable schema_url : string; +} + +let default_resource_metrics_mutable () : resource_metrics_mutable = { + resource = None; + scope_metrics = []; + schema_url = ""; +} + +type metrics_data_mutable = { + mutable resource_metrics : Metrics_types.resource_metrics list; +} + +let default_metrics_data_mutable () : metrics_data_mutable = { + resource_metrics = []; +} + + +let rec decode_summary_data_point_value_at_quantile d = + let v = default_summary_data_point_value_at_quantile_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + ); continue__ := false + | Some (1, Pbrt.Bits64) -> begin + v.quantile <- Pbrt.Decoder.float_as_bits64 d; + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(summary_data_point_value_at_quantile), field(1)" pk + | Some (2, Pbrt.Bits64) -> begin + v.value <- Pbrt.Decoder.float_as_bits64 d; + end + | Some (2, pk) -> + Pbrt.Decoder.unexpected_payload "Message(summary_data_point_value_at_quantile), field(2)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Metrics_types.quantile = v.quantile; + Metrics_types.value = v.value; + } : Metrics_types.summary_data_point_value_at_quantile) + +let rec decode_summary_data_point d = + let v = default_summary_data_point_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.quantile_values <- List.rev v.quantile_values; + v.attributes <- List.rev v.attributes; + ); continue__ := false + | Some (7, Pbrt.Bytes) -> begin + v.attributes <- (Common_pb.decode_key_value (Pbrt.Decoder.nested d)) :: v.attributes; + end + | Some (7, pk) -> + Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(7)" pk + | Some (2, Pbrt.Bits64) -> begin + v.start_time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; + end + | Some (2, pk) -> + Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(2)" pk + | Some (3, Pbrt.Bits64) -> begin + v.time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; + end + | Some (3, pk) -> + Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(3)" pk + | Some (4, Pbrt.Bits64) -> begin + v.count <- Pbrt.Decoder.int64_as_bits64 d; + end + | Some (4, pk) -> + Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(4)" pk + | Some (5, Pbrt.Bits64) -> begin + v.sum <- Pbrt.Decoder.float_as_bits64 d; + end + | Some (5, pk) -> + Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(5)" pk + | Some (6, Pbrt.Bytes) -> begin + v.quantile_values <- (decode_summary_data_point_value_at_quantile (Pbrt.Decoder.nested d)) :: v.quantile_values; + end + | Some (6, pk) -> + Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(6)" pk + | Some (8, Pbrt.Varint) -> begin + v.flags <- Pbrt.Decoder.int32_as_varint d; + end + | Some (8, pk) -> + Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(8)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Metrics_types.attributes = v.attributes; + Metrics_types.start_time_unix_nano = v.start_time_unix_nano; + Metrics_types.time_unix_nano = v.time_unix_nano; + Metrics_types.count = v.count; + Metrics_types.sum = v.sum; + Metrics_types.quantile_values = v.quantile_values; + Metrics_types.flags = v.flags; + } : Metrics_types.summary_data_point) + +let rec decode_summary d = + let v = default_summary_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.data_points <- List.rev v.data_points; + ); continue__ := false + | Some (1, Pbrt.Bytes) -> begin + v.data_points <- (decode_summary_data_point (Pbrt.Decoder.nested d)) :: v.data_points; + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(summary), field(1)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Metrics_types.data_points = v.data_points; + } : Metrics_types.summary) + +let rec decode_exponential_histogram_data_point_buckets d = + let v = default_exponential_histogram_data_point_buckets_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.bucket_counts <- List.rev v.bucket_counts; + ); continue__ := false + | Some (1, Pbrt.Varint) -> begin + v.offset <- Pbrt.Decoder.int32_as_zigzag d; + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point_buckets), field(1)" pk + | Some (2, Pbrt.Bytes) -> begin + v.bucket_counts <- Pbrt.Decoder.packed_fold (fun l d -> (Pbrt.Decoder.int64_as_varint d)::l) [] d; + end + | Some (2, pk) -> + Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point_buckets), field(2)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Metrics_types.offset = v.offset; + Metrics_types.bucket_counts = v.bucket_counts; + } : Metrics_types.exponential_histogram_data_point_buckets) + +let rec decode_exemplar_value d = + let rec loop () = + let ret:Metrics_types.exemplar_value = match Pbrt.Decoder.key d with + | None -> Pbrt.Decoder.malformed_variant "exemplar_value" + | Some (6, _) -> (Metrics_types.As_int (Pbrt.Decoder.int64_as_bits64 d) : Metrics_types.exemplar_value) + | Some (3, _) -> (Metrics_types.As_double (Pbrt.Decoder.float_as_bits64 d) : Metrics_types.exemplar_value) + | Some (n, payload_kind) -> ( + Pbrt.Decoder.skip d payload_kind; + loop () + ) + in + ret + in + loop () + +and decode_exemplar d = + let v = default_exemplar_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.filtered_attributes <- List.rev v.filtered_attributes; + ); continue__ := false + | Some (7, Pbrt.Bytes) -> begin + v.filtered_attributes <- (Common_pb.decode_key_value (Pbrt.Decoder.nested d)) :: v.filtered_attributes; + end + | Some (7, pk) -> + Pbrt.Decoder.unexpected_payload "Message(exemplar), field(7)" pk + | Some (2, Pbrt.Bits64) -> begin + v.time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; + end + | Some (2, pk) -> + Pbrt.Decoder.unexpected_payload "Message(exemplar), field(2)" pk + | Some (6, Pbrt.Bits64) -> begin + v.value <- Metrics_types.As_int (Pbrt.Decoder.int64_as_bits64 d); + end + | Some (6, pk) -> + Pbrt.Decoder.unexpected_payload "Message(exemplar), field(6)" pk + | Some (3, Pbrt.Bits64) -> begin + v.value <- Metrics_types.As_double (Pbrt.Decoder.float_as_bits64 d); + end + | Some (3, pk) -> + Pbrt.Decoder.unexpected_payload "Message(exemplar), field(3)" pk + | Some (4, Pbrt.Bytes) -> begin + v.span_id <- Pbrt.Decoder.bytes d; + end + | Some (4, pk) -> + Pbrt.Decoder.unexpected_payload "Message(exemplar), field(4)" pk + | Some (5, Pbrt.Bytes) -> begin + v.trace_id <- Pbrt.Decoder.bytes d; + end + | Some (5, pk) -> + Pbrt.Decoder.unexpected_payload "Message(exemplar), field(5)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Metrics_types.filtered_attributes = v.filtered_attributes; + Metrics_types.time_unix_nano = v.time_unix_nano; + Metrics_types.value = v.value; + Metrics_types.span_id = v.span_id; + Metrics_types.trace_id = v.trace_id; + } : Metrics_types.exemplar) + +let rec decode_exponential_histogram_data_point d = + let v = default_exponential_histogram_data_point_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.exemplars <- List.rev v.exemplars; + v.attributes <- List.rev v.attributes; + ); continue__ := false + | Some (1, Pbrt.Bytes) -> begin + v.attributes <- (Common_pb.decode_key_value (Pbrt.Decoder.nested d)) :: v.attributes; + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(1)" pk + | Some (2, Pbrt.Bits64) -> begin + v.start_time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; + end + | Some (2, pk) -> + Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(2)" pk + | Some (3, Pbrt.Bits64) -> begin + v.time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; + end + | Some (3, pk) -> + Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(3)" pk + | Some (4, Pbrt.Bits64) -> begin + v.count <- Pbrt.Decoder.int64_as_bits64 d; + end + | Some (4, pk) -> + Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(4)" pk + | Some (5, Pbrt.Bits64) -> begin + v.sum <- Some (Pbrt.Decoder.float_as_bits64 d); + end + | Some (5, pk) -> + Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(5)" pk + | Some (6, Pbrt.Varint) -> begin + v.scale <- Pbrt.Decoder.int32_as_zigzag d; + end + | Some (6, pk) -> + Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(6)" pk + | Some (7, Pbrt.Bits64) -> begin + v.zero_count <- Pbrt.Decoder.int64_as_bits64 d; + end + | Some (7, pk) -> + Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(7)" pk + | Some (8, Pbrt.Bytes) -> begin + v.positive <- Some (decode_exponential_histogram_data_point_buckets (Pbrt.Decoder.nested d)); + end + | Some (8, pk) -> + Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(8)" pk + | Some (9, Pbrt.Bytes) -> begin + v.negative <- Some (decode_exponential_histogram_data_point_buckets (Pbrt.Decoder.nested d)); + end + | Some (9, pk) -> + Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(9)" pk + | Some (10, Pbrt.Varint) -> begin + v.flags <- Pbrt.Decoder.int32_as_varint d; + end + | Some (10, pk) -> + Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(10)" pk + | Some (11, Pbrt.Bytes) -> begin + v.exemplars <- (decode_exemplar (Pbrt.Decoder.nested d)) :: v.exemplars; + end + | Some (11, pk) -> + Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(11)" pk + | Some (12, Pbrt.Bits64) -> begin + v.min <- Some (Pbrt.Decoder.float_as_bits64 d); + end + | Some (12, pk) -> + Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(12)" pk + | Some (13, Pbrt.Bits64) -> begin + v.max <- Some (Pbrt.Decoder.float_as_bits64 d); + end + | Some (13, pk) -> + Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(13)" pk + | Some (14, Pbrt.Bits64) -> begin + v.zero_threshold <- Pbrt.Decoder.float_as_bits64 d; + end + | Some (14, pk) -> + Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(14)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Metrics_types.attributes = v.attributes; + Metrics_types.start_time_unix_nano = v.start_time_unix_nano; + Metrics_types.time_unix_nano = v.time_unix_nano; + Metrics_types.count = v.count; + Metrics_types.sum = v.sum; + Metrics_types.scale = v.scale; + Metrics_types.zero_count = v.zero_count; + Metrics_types.positive = v.positive; + Metrics_types.negative = v.negative; + Metrics_types.flags = v.flags; + Metrics_types.exemplars = v.exemplars; + Metrics_types.min = v.min; + Metrics_types.max = v.max; + Metrics_types.zero_threshold = v.zero_threshold; + } : Metrics_types.exponential_histogram_data_point) + +let rec decode_aggregation_temporality d = + match Pbrt.Decoder.int_as_varint d with + | 0 -> (Metrics_types.Aggregation_temporality_unspecified:Metrics_types.aggregation_temporality) + | 1 -> (Metrics_types.Aggregation_temporality_delta:Metrics_types.aggregation_temporality) + | 2 -> (Metrics_types.Aggregation_temporality_cumulative:Metrics_types.aggregation_temporality) + | _ -> Pbrt.Decoder.malformed_variant "aggregation_temporality" + +let rec decode_exponential_histogram d = + let v = default_exponential_histogram_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.data_points <- List.rev v.data_points; + ); continue__ := false + | Some (1, Pbrt.Bytes) -> begin + v.data_points <- (decode_exponential_histogram_data_point (Pbrt.Decoder.nested d)) :: v.data_points; + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(exponential_histogram), field(1)" pk + | Some (2, Pbrt.Varint) -> begin + v.aggregation_temporality <- decode_aggregation_temporality d; + end + | Some (2, pk) -> + Pbrt.Decoder.unexpected_payload "Message(exponential_histogram), field(2)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Metrics_types.data_points = v.data_points; + Metrics_types.aggregation_temporality = v.aggregation_temporality; + } : Metrics_types.exponential_histogram) + +let rec decode_histogram_data_point d = + let v = default_histogram_data_point_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.exemplars <- List.rev v.exemplars; + v.explicit_bounds <- List.rev v.explicit_bounds; + v.bucket_counts <- List.rev v.bucket_counts; + v.attributes <- List.rev v.attributes; + ); continue__ := false + | Some (9, Pbrt.Bytes) -> begin + v.attributes <- (Common_pb.decode_key_value (Pbrt.Decoder.nested d)) :: v.attributes; + end + | Some (9, pk) -> + Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(9)" pk + | Some (2, Pbrt.Bits64) -> begin + v.start_time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; + end + | Some (2, pk) -> + Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(2)" pk + | Some (3, Pbrt.Bits64) -> begin + v.time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; + end + | Some (3, pk) -> + Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(3)" pk + | Some (4, Pbrt.Bits64) -> begin + v.count <- Pbrt.Decoder.int64_as_bits64 d; + end + | Some (4, pk) -> + Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(4)" pk + | Some (5, Pbrt.Bits64) -> begin + v.sum <- Some (Pbrt.Decoder.float_as_bits64 d); + end + | Some (5, pk) -> + Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(5)" pk + | Some (6, Pbrt.Bytes) -> begin + v.bucket_counts <- Pbrt.Decoder.packed_fold (fun l d -> (Pbrt.Decoder.int64_as_bits64 d)::l) [] d; + end + | Some (6, pk) -> + Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(6)" pk + | Some (7, Pbrt.Bytes) -> begin + v.explicit_bounds <- Pbrt.Decoder.packed_fold (fun l d -> (Pbrt.Decoder.float_as_bits64 d)::l) [] d; + end + | Some (7, pk) -> + Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(7)" pk + | Some (8, Pbrt.Bytes) -> begin + v.exemplars <- (decode_exemplar (Pbrt.Decoder.nested d)) :: v.exemplars; + end + | Some (8, pk) -> + Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(8)" pk + | Some (10, Pbrt.Varint) -> begin + v.flags <- Pbrt.Decoder.int32_as_varint d; + end + | Some (10, pk) -> + Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(10)" pk + | Some (11, Pbrt.Bits64) -> begin + v.min <- Some (Pbrt.Decoder.float_as_bits64 d); + end + | Some (11, pk) -> + Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(11)" pk + | Some (12, Pbrt.Bits64) -> begin + v.max <- Some (Pbrt.Decoder.float_as_bits64 d); + end + | Some (12, pk) -> + Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(12)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Metrics_types.attributes = v.attributes; + Metrics_types.start_time_unix_nano = v.start_time_unix_nano; + Metrics_types.time_unix_nano = v.time_unix_nano; + Metrics_types.count = v.count; + Metrics_types.sum = v.sum; + Metrics_types.bucket_counts = v.bucket_counts; + Metrics_types.explicit_bounds = v.explicit_bounds; + Metrics_types.exemplars = v.exemplars; + Metrics_types.flags = v.flags; + Metrics_types.min = v.min; + Metrics_types.max = v.max; + } : Metrics_types.histogram_data_point) + +let rec decode_histogram d = + let v = default_histogram_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.data_points <- List.rev v.data_points; + ); continue__ := false + | Some (1, Pbrt.Bytes) -> begin + v.data_points <- (decode_histogram_data_point (Pbrt.Decoder.nested d)) :: v.data_points; + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(histogram), field(1)" pk + | Some (2, Pbrt.Varint) -> begin + v.aggregation_temporality <- decode_aggregation_temporality d; + end + | Some (2, pk) -> + Pbrt.Decoder.unexpected_payload "Message(histogram), field(2)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Metrics_types.data_points = v.data_points; + Metrics_types.aggregation_temporality = v.aggregation_temporality; + } : Metrics_types.histogram) + +let rec decode_number_data_point_value d = + let rec loop () = + let ret:Metrics_types.number_data_point_value = match Pbrt.Decoder.key d with + | None -> Pbrt.Decoder.malformed_variant "number_data_point_value" + | Some (6, _) -> (Metrics_types.As_int (Pbrt.Decoder.int64_as_bits64 d) : Metrics_types.number_data_point_value) + | Some (4, _) -> (Metrics_types.As_double (Pbrt.Decoder.float_as_bits64 d) : Metrics_types.number_data_point_value) + | Some (n, payload_kind) -> ( + Pbrt.Decoder.skip d payload_kind; + loop () + ) + in + ret + in + loop () + +and decode_number_data_point d = + let v = default_number_data_point_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.exemplars <- List.rev v.exemplars; + v.attributes <- List.rev v.attributes; + ); continue__ := false + | Some (7, Pbrt.Bytes) -> begin + v.attributes <- (Common_pb.decode_key_value (Pbrt.Decoder.nested d)) :: v.attributes; + end + | Some (7, pk) -> + Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(7)" pk + | Some (2, Pbrt.Bits64) -> begin + v.start_time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; + end + | Some (2, pk) -> + Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(2)" pk + | Some (3, Pbrt.Bits64) -> begin + v.time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; + end + | Some (3, pk) -> + Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(3)" pk + | Some (6, Pbrt.Bits64) -> begin + v.value <- Metrics_types.As_int (Pbrt.Decoder.int64_as_bits64 d); + end + | Some (6, pk) -> + Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(6)" pk + | Some (4, Pbrt.Bits64) -> begin + v.value <- Metrics_types.As_double (Pbrt.Decoder.float_as_bits64 d); + end + | Some (4, pk) -> + Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(4)" pk + | Some (5, Pbrt.Bytes) -> begin + v.exemplars <- (decode_exemplar (Pbrt.Decoder.nested d)) :: v.exemplars; + end + | Some (5, pk) -> + Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(5)" pk + | Some (8, Pbrt.Varint) -> begin + v.flags <- Pbrt.Decoder.int32_as_varint d; + end + | Some (8, pk) -> + Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(8)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Metrics_types.attributes = v.attributes; + Metrics_types.start_time_unix_nano = v.start_time_unix_nano; + Metrics_types.time_unix_nano = v.time_unix_nano; + Metrics_types.value = v.value; + Metrics_types.exemplars = v.exemplars; + Metrics_types.flags = v.flags; + } : Metrics_types.number_data_point) + +let rec decode_sum d = + let v = default_sum_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.data_points <- List.rev v.data_points; + ); continue__ := false + | Some (1, Pbrt.Bytes) -> begin + v.data_points <- (decode_number_data_point (Pbrt.Decoder.nested d)) :: v.data_points; + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(sum), field(1)" pk + | Some (2, Pbrt.Varint) -> begin + v.aggregation_temporality <- decode_aggregation_temporality d; + end + | Some (2, pk) -> + Pbrt.Decoder.unexpected_payload "Message(sum), field(2)" pk + | Some (3, Pbrt.Varint) -> begin + v.is_monotonic <- Pbrt.Decoder.bool d; + end + | Some (3, pk) -> + Pbrt.Decoder.unexpected_payload "Message(sum), field(3)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Metrics_types.data_points = v.data_points; + Metrics_types.aggregation_temporality = v.aggregation_temporality; + Metrics_types.is_monotonic = v.is_monotonic; + } : Metrics_types.sum) + +let rec decode_gauge d = + let v = default_gauge_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.data_points <- List.rev v.data_points; + ); continue__ := false + | Some (1, Pbrt.Bytes) -> begin + v.data_points <- (decode_number_data_point (Pbrt.Decoder.nested d)) :: v.data_points; + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(gauge), field(1)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Metrics_types.data_points = v.data_points; + } : Metrics_types.gauge) + +let rec decode_metric_data d = + let rec loop () = + let ret:Metrics_types.metric_data = match Pbrt.Decoder.key d with + | None -> Pbrt.Decoder.malformed_variant "metric_data" + | Some (11, _) -> (Metrics_types.Summary (decode_summary (Pbrt.Decoder.nested d)) : Metrics_types.metric_data) + | Some (10, _) -> (Metrics_types.Exponential_histogram (decode_exponential_histogram (Pbrt.Decoder.nested d)) : Metrics_types.metric_data) + | Some (9, _) -> (Metrics_types.Histogram (decode_histogram (Pbrt.Decoder.nested d)) : Metrics_types.metric_data) + | Some (7, _) -> (Metrics_types.Sum (decode_sum (Pbrt.Decoder.nested d)) : Metrics_types.metric_data) + | Some (5, _) -> (Metrics_types.Gauge (decode_gauge (Pbrt.Decoder.nested d)) : Metrics_types.metric_data) + | Some (n, payload_kind) -> ( + Pbrt.Decoder.skip d payload_kind; + loop () + ) + in + ret + in + loop () + +and decode_metric d = + let v = default_metric_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + ); continue__ := false + | Some (1, Pbrt.Bytes) -> begin + v.name <- Pbrt.Decoder.string d; + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(metric), field(1)" pk + | Some (2, Pbrt.Bytes) -> begin + v.description <- Pbrt.Decoder.string d; + end + | Some (2, pk) -> + Pbrt.Decoder.unexpected_payload "Message(metric), field(2)" pk + | Some (3, Pbrt.Bytes) -> begin + v.unit_ <- Pbrt.Decoder.string d; + end + | Some (3, pk) -> + Pbrt.Decoder.unexpected_payload "Message(metric), field(3)" pk + | Some (11, Pbrt.Bytes) -> begin + v.data <- Metrics_types.Summary (decode_summary (Pbrt.Decoder.nested d)); + end + | Some (11, pk) -> + Pbrt.Decoder.unexpected_payload "Message(metric), field(11)" pk + | Some (10, Pbrt.Bytes) -> begin + v.data <- Metrics_types.Exponential_histogram (decode_exponential_histogram (Pbrt.Decoder.nested d)); + end + | Some (10, pk) -> + Pbrt.Decoder.unexpected_payload "Message(metric), field(10)" pk + | Some (9, Pbrt.Bytes) -> begin + v.data <- Metrics_types.Histogram (decode_histogram (Pbrt.Decoder.nested d)); + end + | Some (9, pk) -> + Pbrt.Decoder.unexpected_payload "Message(metric), field(9)" pk + | Some (7, Pbrt.Bytes) -> begin + v.data <- Metrics_types.Sum (decode_sum (Pbrt.Decoder.nested d)); + end + | Some (7, pk) -> + Pbrt.Decoder.unexpected_payload "Message(metric), field(7)" pk + | Some (5, Pbrt.Bytes) -> begin + v.data <- Metrics_types.Gauge (decode_gauge (Pbrt.Decoder.nested d)); + end + | Some (5, pk) -> + Pbrt.Decoder.unexpected_payload "Message(metric), field(5)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Metrics_types.name = v.name; + Metrics_types.description = v.description; + Metrics_types.unit_ = v.unit_; + Metrics_types.data = v.data; + } : Metrics_types.metric) + +let rec decode_scope_metrics d = + let v = default_scope_metrics_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.metrics <- List.rev v.metrics; + ); continue__ := false + | Some (1, Pbrt.Bytes) -> begin + v.scope <- Some (Common_pb.decode_instrumentation_scope (Pbrt.Decoder.nested d)); + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(scope_metrics), field(1)" pk + | Some (2, Pbrt.Bytes) -> begin + v.metrics <- (decode_metric (Pbrt.Decoder.nested d)) :: v.metrics; + end + | Some (2, pk) -> + Pbrt.Decoder.unexpected_payload "Message(scope_metrics), field(2)" pk + | Some (3, Pbrt.Bytes) -> begin + v.schema_url <- Pbrt.Decoder.string d; + end + | Some (3, pk) -> + Pbrt.Decoder.unexpected_payload "Message(scope_metrics), field(3)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Metrics_types.scope = v.scope; + Metrics_types.metrics = v.metrics; + Metrics_types.schema_url = v.schema_url; + } : Metrics_types.scope_metrics) + +let rec decode_resource_metrics d = + let v = default_resource_metrics_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.scope_metrics <- List.rev v.scope_metrics; + ); continue__ := false + | Some (1, Pbrt.Bytes) -> begin + v.resource <- Some (Resource_pb.decode_resource (Pbrt.Decoder.nested d)); + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(resource_metrics), field(1)" pk + | Some (2, Pbrt.Bytes) -> begin + v.scope_metrics <- (decode_scope_metrics (Pbrt.Decoder.nested d)) :: v.scope_metrics; + end + | Some (2, pk) -> + Pbrt.Decoder.unexpected_payload "Message(resource_metrics), field(2)" pk + | Some (3, Pbrt.Bytes) -> begin + v.schema_url <- Pbrt.Decoder.string d; + end + | Some (3, pk) -> + Pbrt.Decoder.unexpected_payload "Message(resource_metrics), field(3)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Metrics_types.resource = v.resource; + Metrics_types.scope_metrics = v.scope_metrics; + Metrics_types.schema_url = v.schema_url; + } : Metrics_types.resource_metrics) + +let rec decode_metrics_data d = + let v = default_metrics_data_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.resource_metrics <- List.rev v.resource_metrics; + ); continue__ := false + | Some (1, Pbrt.Bytes) -> begin + v.resource_metrics <- (decode_resource_metrics (Pbrt.Decoder.nested d)) :: v.resource_metrics; + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(metrics_data), field(1)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Metrics_types.resource_metrics = v.resource_metrics; + } : Metrics_types.metrics_data) + +let rec decode_data_point_flags d = + match Pbrt.Decoder.int_as_varint d with + | 0 -> (Metrics_types.Data_point_flags_do_not_use:Metrics_types.data_point_flags) + | 1 -> (Metrics_types.Data_point_flags_no_recorded_value_mask:Metrics_types.data_point_flags) + | _ -> Pbrt.Decoder.malformed_variant "data_point_flags" + +let rec encode_summary_data_point_value_at_quantile (v:Metrics_types.summary_data_point_value_at_quantile) encoder = + Pbrt.Encoder.key (1, Pbrt.Bits64) encoder; + Pbrt.Encoder.float_as_bits64 v.Metrics_types.quantile encoder; + Pbrt.Encoder.key (2, Pbrt.Bits64) encoder; + Pbrt.Encoder.float_as_bits64 v.Metrics_types.value encoder; + () + +let rec encode_summary_data_point (v:Metrics_types.summary_data_point) encoder = + List.iter (fun x -> + Pbrt.Encoder.key (7, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (Common_pb.encode_key_value x) encoder; + ) v.Metrics_types.attributes; + Pbrt.Encoder.key (2, Pbrt.Bits64) encoder; + Pbrt.Encoder.int64_as_bits64 v.Metrics_types.start_time_unix_nano encoder; + Pbrt.Encoder.key (3, Pbrt.Bits64) encoder; + Pbrt.Encoder.int64_as_bits64 v.Metrics_types.time_unix_nano encoder; + Pbrt.Encoder.key (4, Pbrt.Bits64) encoder; + Pbrt.Encoder.int64_as_bits64 v.Metrics_types.count encoder; + Pbrt.Encoder.key (5, Pbrt.Bits64) encoder; + Pbrt.Encoder.float_as_bits64 v.Metrics_types.sum encoder; + List.iter (fun x -> + Pbrt.Encoder.key (6, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_summary_data_point_value_at_quantile x) encoder; + ) v.Metrics_types.quantile_values; + Pbrt.Encoder.key (8, Pbrt.Varint) encoder; + Pbrt.Encoder.int32_as_varint v.Metrics_types.flags encoder; + () + +let rec encode_summary (v:Metrics_types.summary) encoder = + List.iter (fun x -> + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_summary_data_point x) encoder; + ) v.Metrics_types.data_points; + () + +let rec encode_exponential_histogram_data_point_buckets (v:Metrics_types.exponential_histogram_data_point_buckets) encoder = + Pbrt.Encoder.key (1, Pbrt.Varint) encoder; + Pbrt.Encoder.int32_as_zigzag v.Metrics_types.offset encoder; + Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (fun encoder -> + List.iter (fun x -> + Pbrt.Encoder.int64_as_varint x encoder; + ) v.Metrics_types.bucket_counts; + ) encoder; + () + +let rec encode_exemplar_value (v:Metrics_types.exemplar_value) encoder = + begin match v with + | Metrics_types.As_int x -> + Pbrt.Encoder.key (6, Pbrt.Bits64) encoder; + Pbrt.Encoder.int64_as_bits64 x encoder; + | Metrics_types.As_double x -> + Pbrt.Encoder.key (3, Pbrt.Bits64) encoder; + Pbrt.Encoder.float_as_bits64 x encoder; + end + +and encode_exemplar (v:Metrics_types.exemplar) encoder = + List.iter (fun x -> + Pbrt.Encoder.key (7, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (Common_pb.encode_key_value x) encoder; + ) v.Metrics_types.filtered_attributes; + Pbrt.Encoder.key (2, Pbrt.Bits64) encoder; + Pbrt.Encoder.int64_as_bits64 v.Metrics_types.time_unix_nano encoder; + begin match v.Metrics_types.value with + | Metrics_types.As_int x -> + Pbrt.Encoder.key (6, Pbrt.Bits64) encoder; + Pbrt.Encoder.int64_as_bits64 x encoder; + | Metrics_types.As_double x -> + Pbrt.Encoder.key (3, Pbrt.Bits64) encoder; + Pbrt.Encoder.float_as_bits64 x encoder; + end; + Pbrt.Encoder.key (4, Pbrt.Bytes) encoder; + Pbrt.Encoder.bytes v.Metrics_types.span_id encoder; + Pbrt.Encoder.key (5, Pbrt.Bytes) encoder; + Pbrt.Encoder.bytes v.Metrics_types.trace_id encoder; + () + +let rec encode_exponential_histogram_data_point (v:Metrics_types.exponential_histogram_data_point) encoder = + List.iter (fun x -> + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (Common_pb.encode_key_value x) encoder; + ) v.Metrics_types.attributes; + Pbrt.Encoder.key (2, Pbrt.Bits64) encoder; + Pbrt.Encoder.int64_as_bits64 v.Metrics_types.start_time_unix_nano encoder; + Pbrt.Encoder.key (3, Pbrt.Bits64) encoder; + Pbrt.Encoder.int64_as_bits64 v.Metrics_types.time_unix_nano encoder; + Pbrt.Encoder.key (4, Pbrt.Bits64) encoder; + Pbrt.Encoder.int64_as_bits64 v.Metrics_types.count encoder; + begin match v.Metrics_types.sum with + | Some x -> + Pbrt.Encoder.key (5, Pbrt.Bits64) encoder; + Pbrt.Encoder.float_as_bits64 x encoder; + | None -> (); + end; + Pbrt.Encoder.key (6, Pbrt.Varint) encoder; + Pbrt.Encoder.int32_as_zigzag v.Metrics_types.scale encoder; + Pbrt.Encoder.key (7, Pbrt.Bits64) encoder; + Pbrt.Encoder.int64_as_bits64 v.Metrics_types.zero_count encoder; + begin match v.Metrics_types.positive with + | Some x -> + Pbrt.Encoder.key (8, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_exponential_histogram_data_point_buckets x) encoder; + | None -> (); + end; + begin match v.Metrics_types.negative with + | Some x -> + Pbrt.Encoder.key (9, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_exponential_histogram_data_point_buckets x) encoder; + | None -> (); + end; + Pbrt.Encoder.key (10, Pbrt.Varint) encoder; + Pbrt.Encoder.int32_as_varint v.Metrics_types.flags encoder; + List.iter (fun x -> + Pbrt.Encoder.key (11, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_exemplar x) encoder; + ) v.Metrics_types.exemplars; + begin match v.Metrics_types.min with + | Some x -> + Pbrt.Encoder.key (12, Pbrt.Bits64) encoder; + Pbrt.Encoder.float_as_bits64 x encoder; + | None -> (); + end; + begin match v.Metrics_types.max with + | Some x -> + Pbrt.Encoder.key (13, Pbrt.Bits64) encoder; + Pbrt.Encoder.float_as_bits64 x encoder; + | None -> (); + end; + Pbrt.Encoder.key (14, Pbrt.Bits64) encoder; + Pbrt.Encoder.float_as_bits64 v.Metrics_types.zero_threshold encoder; + () + +let rec encode_aggregation_temporality (v:Metrics_types.aggregation_temporality) encoder = + match v with + | Metrics_types.Aggregation_temporality_unspecified -> Pbrt.Encoder.int_as_varint (0) encoder + | Metrics_types.Aggregation_temporality_delta -> Pbrt.Encoder.int_as_varint 1 encoder + | Metrics_types.Aggregation_temporality_cumulative -> Pbrt.Encoder.int_as_varint 2 encoder + +let rec encode_exponential_histogram (v:Metrics_types.exponential_histogram) encoder = + List.iter (fun x -> + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_exponential_histogram_data_point x) encoder; + ) v.Metrics_types.data_points; + Pbrt.Encoder.key (2, Pbrt.Varint) encoder; + encode_aggregation_temporality v.Metrics_types.aggregation_temporality encoder; + () + +let rec encode_histogram_data_point (v:Metrics_types.histogram_data_point) encoder = + List.iter (fun x -> + Pbrt.Encoder.key (9, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (Common_pb.encode_key_value x) encoder; + ) v.Metrics_types.attributes; + Pbrt.Encoder.key (2, Pbrt.Bits64) encoder; + Pbrt.Encoder.int64_as_bits64 v.Metrics_types.start_time_unix_nano encoder; + Pbrt.Encoder.key (3, Pbrt.Bits64) encoder; + Pbrt.Encoder.int64_as_bits64 v.Metrics_types.time_unix_nano encoder; + Pbrt.Encoder.key (4, Pbrt.Bits64) encoder; + Pbrt.Encoder.int64_as_bits64 v.Metrics_types.count encoder; + begin match v.Metrics_types.sum with + | Some x -> + Pbrt.Encoder.key (5, Pbrt.Bits64) encoder; + Pbrt.Encoder.float_as_bits64 x encoder; + | None -> (); + end; + Pbrt.Encoder.key (6, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (fun encoder -> + List.iter (fun x -> + Pbrt.Encoder.int64_as_bits64 x encoder; + ) v.Metrics_types.bucket_counts; + ) encoder; + Pbrt.Encoder.key (7, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (fun encoder -> + List.iter (fun x -> + Pbrt.Encoder.float_as_bits64 x encoder; + ) v.Metrics_types.explicit_bounds; + ) encoder; + List.iter (fun x -> + Pbrt.Encoder.key (8, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_exemplar x) encoder; + ) v.Metrics_types.exemplars; + Pbrt.Encoder.key (10, Pbrt.Varint) encoder; + Pbrt.Encoder.int32_as_varint v.Metrics_types.flags encoder; + begin match v.Metrics_types.min with + | Some x -> + Pbrt.Encoder.key (11, Pbrt.Bits64) encoder; + Pbrt.Encoder.float_as_bits64 x encoder; + | None -> (); + end; + begin match v.Metrics_types.max with + | Some x -> + Pbrt.Encoder.key (12, Pbrt.Bits64) encoder; + Pbrt.Encoder.float_as_bits64 x encoder; + | None -> (); + end; + () + +let rec encode_histogram (v:Metrics_types.histogram) encoder = + List.iter (fun x -> + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_histogram_data_point x) encoder; + ) v.Metrics_types.data_points; + Pbrt.Encoder.key (2, Pbrt.Varint) encoder; + encode_aggregation_temporality v.Metrics_types.aggregation_temporality encoder; + () + +let rec encode_number_data_point_value (v:Metrics_types.number_data_point_value) encoder = + begin match v with + | Metrics_types.As_int x -> + Pbrt.Encoder.key (6, Pbrt.Bits64) encoder; + Pbrt.Encoder.int64_as_bits64 x encoder; + | Metrics_types.As_double x -> + Pbrt.Encoder.key (4, Pbrt.Bits64) encoder; + Pbrt.Encoder.float_as_bits64 x encoder; + end + +and encode_number_data_point (v:Metrics_types.number_data_point) encoder = + List.iter (fun x -> + Pbrt.Encoder.key (7, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (Common_pb.encode_key_value x) encoder; + ) v.Metrics_types.attributes; + Pbrt.Encoder.key (2, Pbrt.Bits64) encoder; + Pbrt.Encoder.int64_as_bits64 v.Metrics_types.start_time_unix_nano encoder; + Pbrt.Encoder.key (3, Pbrt.Bits64) encoder; + Pbrt.Encoder.int64_as_bits64 v.Metrics_types.time_unix_nano encoder; + begin match v.Metrics_types.value with + | Metrics_types.As_int x -> + Pbrt.Encoder.key (6, Pbrt.Bits64) encoder; + Pbrt.Encoder.int64_as_bits64 x encoder; + | Metrics_types.As_double x -> + Pbrt.Encoder.key (4, Pbrt.Bits64) encoder; + Pbrt.Encoder.float_as_bits64 x encoder; + end; + List.iter (fun x -> + Pbrt.Encoder.key (5, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_exemplar x) encoder; + ) v.Metrics_types.exemplars; + Pbrt.Encoder.key (8, Pbrt.Varint) encoder; + Pbrt.Encoder.int32_as_varint v.Metrics_types.flags encoder; + () + +let rec encode_sum (v:Metrics_types.sum) encoder = + List.iter (fun x -> + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_number_data_point x) encoder; + ) v.Metrics_types.data_points; + Pbrt.Encoder.key (2, Pbrt.Varint) encoder; + encode_aggregation_temporality v.Metrics_types.aggregation_temporality encoder; + Pbrt.Encoder.key (3, Pbrt.Varint) encoder; + Pbrt.Encoder.bool v.Metrics_types.is_monotonic encoder; + () + +let rec encode_gauge (v:Metrics_types.gauge) encoder = + List.iter (fun x -> + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_number_data_point x) encoder; + ) v.Metrics_types.data_points; + () + +let rec encode_metric_data (v:Metrics_types.metric_data) encoder = + begin match v with + | Metrics_types.Summary x -> + Pbrt.Encoder.key (11, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_summary x) encoder; + | Metrics_types.Exponential_histogram x -> + Pbrt.Encoder.key (10, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_exponential_histogram x) encoder; + | Metrics_types.Histogram x -> + Pbrt.Encoder.key (9, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_histogram x) encoder; + | Metrics_types.Sum x -> + Pbrt.Encoder.key (7, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_sum x) encoder; + | Metrics_types.Gauge x -> + Pbrt.Encoder.key (5, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_gauge x) encoder; + end + +and encode_metric (v:Metrics_types.metric) encoder = + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.string v.Metrics_types.name encoder; + Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; + Pbrt.Encoder.string v.Metrics_types.description encoder; + Pbrt.Encoder.key (3, Pbrt.Bytes) encoder; + Pbrt.Encoder.string v.Metrics_types.unit_ encoder; + begin match v.Metrics_types.data with + | Metrics_types.Summary x -> + Pbrt.Encoder.key (11, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_summary x) encoder; + | Metrics_types.Exponential_histogram x -> + Pbrt.Encoder.key (10, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_exponential_histogram x) encoder; + | Metrics_types.Histogram x -> + Pbrt.Encoder.key (9, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_histogram x) encoder; + | Metrics_types.Sum x -> + Pbrt.Encoder.key (7, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_sum x) encoder; + | Metrics_types.Gauge x -> + Pbrt.Encoder.key (5, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_gauge x) encoder; + end; + () + +let rec encode_scope_metrics (v:Metrics_types.scope_metrics) encoder = + begin match v.Metrics_types.scope with + | Some x -> + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (Common_pb.encode_instrumentation_scope x) encoder; + | None -> (); + end; + List.iter (fun x -> + Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_metric x) encoder; + ) v.Metrics_types.metrics; + Pbrt.Encoder.key (3, Pbrt.Bytes) encoder; + Pbrt.Encoder.string v.Metrics_types.schema_url encoder; + () + +let rec encode_resource_metrics (v:Metrics_types.resource_metrics) encoder = + begin match v.Metrics_types.resource with + | Some x -> + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (Resource_pb.encode_resource x) encoder; + | None -> (); + end; + List.iter (fun x -> + Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_scope_metrics x) encoder; + ) v.Metrics_types.scope_metrics; + Pbrt.Encoder.key (3, Pbrt.Bytes) encoder; + Pbrt.Encoder.string v.Metrics_types.schema_url encoder; + () + +let rec encode_metrics_data (v:Metrics_types.metrics_data) encoder = + List.iter (fun x -> + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_resource_metrics x) encoder; + ) v.Metrics_types.resource_metrics; + () + +let rec encode_data_point_flags (v:Metrics_types.data_point_flags) encoder = + match v with + | Metrics_types.Data_point_flags_do_not_use -> Pbrt.Encoder.int_as_varint (0) encoder + | Metrics_types.Data_point_flags_no_recorded_value_mask -> Pbrt.Encoder.int_as_varint 1 encoder diff --git a/src/proto/metrics_pb.mli b/src/proto/metrics_pb.mli new file mode 100644 index 00000000..8184e069 --- /dev/null +++ b/src/proto/metrics_pb.mli @@ -0,0 +1,133 @@ +(** metrics.proto Binary Encoding *) + + +(** {2 Protobuf Encoding} *) + +val encode_summary_data_point_value_at_quantile : Metrics_types.summary_data_point_value_at_quantile -> Pbrt.Encoder.t -> unit +(** [encode_summary_data_point_value_at_quantile v encoder] encodes [v] with the given [encoder] *) + +val encode_summary_data_point : Metrics_types.summary_data_point -> Pbrt.Encoder.t -> unit +(** [encode_summary_data_point v encoder] encodes [v] with the given [encoder] *) + +val encode_summary : Metrics_types.summary -> Pbrt.Encoder.t -> unit +(** [encode_summary v encoder] encodes [v] with the given [encoder] *) + +val encode_exponential_histogram_data_point_buckets : Metrics_types.exponential_histogram_data_point_buckets -> Pbrt.Encoder.t -> unit +(** [encode_exponential_histogram_data_point_buckets v encoder] encodes [v] with the given [encoder] *) + +val encode_exemplar_value : Metrics_types.exemplar_value -> Pbrt.Encoder.t -> unit +(** [encode_exemplar_value v encoder] encodes [v] with the given [encoder] *) + +val encode_exemplar : Metrics_types.exemplar -> Pbrt.Encoder.t -> unit +(** [encode_exemplar v encoder] encodes [v] with the given [encoder] *) + +val encode_exponential_histogram_data_point : Metrics_types.exponential_histogram_data_point -> Pbrt.Encoder.t -> unit +(** [encode_exponential_histogram_data_point v encoder] encodes [v] with the given [encoder] *) + +val encode_aggregation_temporality : Metrics_types.aggregation_temporality -> Pbrt.Encoder.t -> unit +(** [encode_aggregation_temporality v encoder] encodes [v] with the given [encoder] *) + +val encode_exponential_histogram : Metrics_types.exponential_histogram -> Pbrt.Encoder.t -> unit +(** [encode_exponential_histogram v encoder] encodes [v] with the given [encoder] *) + +val encode_histogram_data_point : Metrics_types.histogram_data_point -> Pbrt.Encoder.t -> unit +(** [encode_histogram_data_point v encoder] encodes [v] with the given [encoder] *) + +val encode_histogram : Metrics_types.histogram -> Pbrt.Encoder.t -> unit +(** [encode_histogram v encoder] encodes [v] with the given [encoder] *) + +val encode_number_data_point_value : Metrics_types.number_data_point_value -> Pbrt.Encoder.t -> unit +(** [encode_number_data_point_value v encoder] encodes [v] with the given [encoder] *) + +val encode_number_data_point : Metrics_types.number_data_point -> Pbrt.Encoder.t -> unit +(** [encode_number_data_point v encoder] encodes [v] with the given [encoder] *) + +val encode_sum : Metrics_types.sum -> Pbrt.Encoder.t -> unit +(** [encode_sum v encoder] encodes [v] with the given [encoder] *) + +val encode_gauge : Metrics_types.gauge -> Pbrt.Encoder.t -> unit +(** [encode_gauge v encoder] encodes [v] with the given [encoder] *) + +val encode_metric_data : Metrics_types.metric_data -> Pbrt.Encoder.t -> unit +(** [encode_metric_data v encoder] encodes [v] with the given [encoder] *) + +val encode_metric : Metrics_types.metric -> Pbrt.Encoder.t -> unit +(** [encode_metric v encoder] encodes [v] with the given [encoder] *) + +val encode_scope_metrics : Metrics_types.scope_metrics -> Pbrt.Encoder.t -> unit +(** [encode_scope_metrics v encoder] encodes [v] with the given [encoder] *) + +val encode_resource_metrics : Metrics_types.resource_metrics -> Pbrt.Encoder.t -> unit +(** [encode_resource_metrics v encoder] encodes [v] with the given [encoder] *) + +val encode_metrics_data : Metrics_types.metrics_data -> Pbrt.Encoder.t -> unit +(** [encode_metrics_data v encoder] encodes [v] with the given [encoder] *) + +val encode_data_point_flags : Metrics_types.data_point_flags -> Pbrt.Encoder.t -> unit +(** [encode_data_point_flags v encoder] encodes [v] with the given [encoder] *) + + +(** {2 Protobuf Decoding} *) + +val decode_summary_data_point_value_at_quantile : Pbrt.Decoder.t -> Metrics_types.summary_data_point_value_at_quantile +(** [decode_summary_data_point_value_at_quantile decoder] decodes a [summary_data_point_value_at_quantile] value from [decoder] *) + +val decode_summary_data_point : Pbrt.Decoder.t -> Metrics_types.summary_data_point +(** [decode_summary_data_point decoder] decodes a [summary_data_point] value from [decoder] *) + +val decode_summary : Pbrt.Decoder.t -> Metrics_types.summary +(** [decode_summary decoder] decodes a [summary] value from [decoder] *) + +val decode_exponential_histogram_data_point_buckets : Pbrt.Decoder.t -> Metrics_types.exponential_histogram_data_point_buckets +(** [decode_exponential_histogram_data_point_buckets decoder] decodes a [exponential_histogram_data_point_buckets] value from [decoder] *) + +val decode_exemplar_value : Pbrt.Decoder.t -> Metrics_types.exemplar_value +(** [decode_exemplar_value decoder] decodes a [exemplar_value] value from [decoder] *) + +val decode_exemplar : Pbrt.Decoder.t -> Metrics_types.exemplar +(** [decode_exemplar decoder] decodes a [exemplar] value from [decoder] *) + +val decode_exponential_histogram_data_point : Pbrt.Decoder.t -> Metrics_types.exponential_histogram_data_point +(** [decode_exponential_histogram_data_point decoder] decodes a [exponential_histogram_data_point] value from [decoder] *) + +val decode_aggregation_temporality : Pbrt.Decoder.t -> Metrics_types.aggregation_temporality +(** [decode_aggregation_temporality decoder] decodes a [aggregation_temporality] value from [decoder] *) + +val decode_exponential_histogram : Pbrt.Decoder.t -> Metrics_types.exponential_histogram +(** [decode_exponential_histogram decoder] decodes a [exponential_histogram] value from [decoder] *) + +val decode_histogram_data_point : Pbrt.Decoder.t -> Metrics_types.histogram_data_point +(** [decode_histogram_data_point decoder] decodes a [histogram_data_point] value from [decoder] *) + +val decode_histogram : Pbrt.Decoder.t -> Metrics_types.histogram +(** [decode_histogram decoder] decodes a [histogram] value from [decoder] *) + +val decode_number_data_point_value : Pbrt.Decoder.t -> Metrics_types.number_data_point_value +(** [decode_number_data_point_value decoder] decodes a [number_data_point_value] value from [decoder] *) + +val decode_number_data_point : Pbrt.Decoder.t -> Metrics_types.number_data_point +(** [decode_number_data_point decoder] decodes a [number_data_point] value from [decoder] *) + +val decode_sum : Pbrt.Decoder.t -> Metrics_types.sum +(** [decode_sum decoder] decodes a [sum] value from [decoder] *) + +val decode_gauge : Pbrt.Decoder.t -> Metrics_types.gauge +(** [decode_gauge decoder] decodes a [gauge] value from [decoder] *) + +val decode_metric_data : Pbrt.Decoder.t -> Metrics_types.metric_data +(** [decode_metric_data decoder] decodes a [metric_data] value from [decoder] *) + +val decode_metric : Pbrt.Decoder.t -> Metrics_types.metric +(** [decode_metric decoder] decodes a [metric] value from [decoder] *) + +val decode_scope_metrics : Pbrt.Decoder.t -> Metrics_types.scope_metrics +(** [decode_scope_metrics decoder] decodes a [scope_metrics] value from [decoder] *) + +val decode_resource_metrics : Pbrt.Decoder.t -> Metrics_types.resource_metrics +(** [decode_resource_metrics decoder] decodes a [resource_metrics] value from [decoder] *) + +val decode_metrics_data : Pbrt.Decoder.t -> Metrics_types.metrics_data +(** [decode_metrics_data decoder] decodes a [metrics_data] value from [decoder] *) + +val decode_data_point_flags : Pbrt.Decoder.t -> Metrics_types.data_point_flags +(** [decode_data_point_flags decoder] decodes a [data_point_flags] value from [decoder] *) diff --git a/src/proto/metrics_pp.ml b/src/proto/metrics_pp.ml new file mode 100644 index 00000000..974c2f7e --- /dev/null +++ b/src/proto/metrics_pp.ml @@ -0,0 +1,177 @@ +[@@@ocaml.warning "-27-30-39"] + +let rec pp_summary_data_point_value_at_quantile fmt (v:Metrics_types.summary_data_point_value_at_quantile) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "quantile" Pbrt.Pp.pp_float fmt v.Metrics_types.quantile; + Pbrt.Pp.pp_record_field ~first:false "value" Pbrt.Pp.pp_float fmt v.Metrics_types.value; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_summary_data_point fmt (v:Metrics_types.summary_data_point) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "attributes" (Pbrt.Pp.pp_list Common_pp.pp_key_value) fmt v.Metrics_types.attributes; + Pbrt.Pp.pp_record_field ~first:false "start_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Metrics_types.start_time_unix_nano; + Pbrt.Pp.pp_record_field ~first:false "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Metrics_types.time_unix_nano; + Pbrt.Pp.pp_record_field ~first:false "count" Pbrt.Pp.pp_int64 fmt v.Metrics_types.count; + Pbrt.Pp.pp_record_field ~first:false "sum" Pbrt.Pp.pp_float fmt v.Metrics_types.sum; + Pbrt.Pp.pp_record_field ~first:false "quantile_values" (Pbrt.Pp.pp_list pp_summary_data_point_value_at_quantile) fmt v.Metrics_types.quantile_values; + Pbrt.Pp.pp_record_field ~first:false "flags" Pbrt.Pp.pp_int32 fmt v.Metrics_types.flags; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_summary fmt (v:Metrics_types.summary) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "data_points" (Pbrt.Pp.pp_list pp_summary_data_point) fmt v.Metrics_types.data_points; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_exponential_histogram_data_point_buckets fmt (v:Metrics_types.exponential_histogram_data_point_buckets) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "offset" Pbrt.Pp.pp_int32 fmt v.Metrics_types.offset; + Pbrt.Pp.pp_record_field ~first:false "bucket_counts" (Pbrt.Pp.pp_list Pbrt.Pp.pp_int64) fmt v.Metrics_types.bucket_counts; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_exemplar_value fmt (v:Metrics_types.exemplar_value) = + match v with + | Metrics_types.As_int x -> Format.fprintf fmt "@[As_int(@,%a)@]" Pbrt.Pp.pp_int64 x + | Metrics_types.As_double x -> Format.fprintf fmt "@[As_double(@,%a)@]" Pbrt.Pp.pp_float x + +and pp_exemplar fmt (v:Metrics_types.exemplar) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "filtered_attributes" (Pbrt.Pp.pp_list Common_pp.pp_key_value) fmt v.Metrics_types.filtered_attributes; + Pbrt.Pp.pp_record_field ~first:false "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Metrics_types.time_unix_nano; + Pbrt.Pp.pp_record_field ~first:false "value" pp_exemplar_value fmt v.Metrics_types.value; + Pbrt.Pp.pp_record_field ~first:false "span_id" Pbrt.Pp.pp_bytes fmt v.Metrics_types.span_id; + Pbrt.Pp.pp_record_field ~first:false "trace_id" Pbrt.Pp.pp_bytes fmt v.Metrics_types.trace_id; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_exponential_histogram_data_point fmt (v:Metrics_types.exponential_histogram_data_point) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "attributes" (Pbrt.Pp.pp_list Common_pp.pp_key_value) fmt v.Metrics_types.attributes; + Pbrt.Pp.pp_record_field ~first:false "start_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Metrics_types.start_time_unix_nano; + Pbrt.Pp.pp_record_field ~first:false "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Metrics_types.time_unix_nano; + Pbrt.Pp.pp_record_field ~first:false "count" Pbrt.Pp.pp_int64 fmt v.Metrics_types.count; + Pbrt.Pp.pp_record_field ~first:false "sum" (Pbrt.Pp.pp_option Pbrt.Pp.pp_float) fmt v.Metrics_types.sum; + Pbrt.Pp.pp_record_field ~first:false "scale" Pbrt.Pp.pp_int32 fmt v.Metrics_types.scale; + Pbrt.Pp.pp_record_field ~first:false "zero_count" Pbrt.Pp.pp_int64 fmt v.Metrics_types.zero_count; + Pbrt.Pp.pp_record_field ~first:false "positive" (Pbrt.Pp.pp_option pp_exponential_histogram_data_point_buckets) fmt v.Metrics_types.positive; + Pbrt.Pp.pp_record_field ~first:false "negative" (Pbrt.Pp.pp_option pp_exponential_histogram_data_point_buckets) fmt v.Metrics_types.negative; + Pbrt.Pp.pp_record_field ~first:false "flags" Pbrt.Pp.pp_int32 fmt v.Metrics_types.flags; + Pbrt.Pp.pp_record_field ~first:false "exemplars" (Pbrt.Pp.pp_list pp_exemplar) fmt v.Metrics_types.exemplars; + Pbrt.Pp.pp_record_field ~first:false "min" (Pbrt.Pp.pp_option Pbrt.Pp.pp_float) fmt v.Metrics_types.min; + Pbrt.Pp.pp_record_field ~first:false "max" (Pbrt.Pp.pp_option Pbrt.Pp.pp_float) fmt v.Metrics_types.max; + Pbrt.Pp.pp_record_field ~first:false "zero_threshold" Pbrt.Pp.pp_float fmt v.Metrics_types.zero_threshold; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_aggregation_temporality fmt (v:Metrics_types.aggregation_temporality) = + match v with + | Metrics_types.Aggregation_temporality_unspecified -> Format.fprintf fmt "Aggregation_temporality_unspecified" + | Metrics_types.Aggregation_temporality_delta -> Format.fprintf fmt "Aggregation_temporality_delta" + | Metrics_types.Aggregation_temporality_cumulative -> Format.fprintf fmt "Aggregation_temporality_cumulative" + +let rec pp_exponential_histogram fmt (v:Metrics_types.exponential_histogram) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "data_points" (Pbrt.Pp.pp_list pp_exponential_histogram_data_point) fmt v.Metrics_types.data_points; + Pbrt.Pp.pp_record_field ~first:false "aggregation_temporality" pp_aggregation_temporality fmt v.Metrics_types.aggregation_temporality; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_histogram_data_point fmt (v:Metrics_types.histogram_data_point) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "attributes" (Pbrt.Pp.pp_list Common_pp.pp_key_value) fmt v.Metrics_types.attributes; + Pbrt.Pp.pp_record_field ~first:false "start_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Metrics_types.start_time_unix_nano; + Pbrt.Pp.pp_record_field ~first:false "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Metrics_types.time_unix_nano; + Pbrt.Pp.pp_record_field ~first:false "count" Pbrt.Pp.pp_int64 fmt v.Metrics_types.count; + Pbrt.Pp.pp_record_field ~first:false "sum" (Pbrt.Pp.pp_option Pbrt.Pp.pp_float) fmt v.Metrics_types.sum; + Pbrt.Pp.pp_record_field ~first:false "bucket_counts" (Pbrt.Pp.pp_list Pbrt.Pp.pp_int64) fmt v.Metrics_types.bucket_counts; + Pbrt.Pp.pp_record_field ~first:false "explicit_bounds" (Pbrt.Pp.pp_list Pbrt.Pp.pp_float) fmt v.Metrics_types.explicit_bounds; + Pbrt.Pp.pp_record_field ~first:false "exemplars" (Pbrt.Pp.pp_list pp_exemplar) fmt v.Metrics_types.exemplars; + Pbrt.Pp.pp_record_field ~first:false "flags" Pbrt.Pp.pp_int32 fmt v.Metrics_types.flags; + Pbrt.Pp.pp_record_field ~first:false "min" (Pbrt.Pp.pp_option Pbrt.Pp.pp_float) fmt v.Metrics_types.min; + Pbrt.Pp.pp_record_field ~first:false "max" (Pbrt.Pp.pp_option Pbrt.Pp.pp_float) fmt v.Metrics_types.max; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_histogram fmt (v:Metrics_types.histogram) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "data_points" (Pbrt.Pp.pp_list pp_histogram_data_point) fmt v.Metrics_types.data_points; + Pbrt.Pp.pp_record_field ~first:false "aggregation_temporality" pp_aggregation_temporality fmt v.Metrics_types.aggregation_temporality; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_number_data_point_value fmt (v:Metrics_types.number_data_point_value) = + match v with + | Metrics_types.As_int x -> Format.fprintf fmt "@[As_int(@,%a)@]" Pbrt.Pp.pp_int64 x + | Metrics_types.As_double x -> Format.fprintf fmt "@[As_double(@,%a)@]" Pbrt.Pp.pp_float x + +and pp_number_data_point fmt (v:Metrics_types.number_data_point) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "attributes" (Pbrt.Pp.pp_list Common_pp.pp_key_value) fmt v.Metrics_types.attributes; + Pbrt.Pp.pp_record_field ~first:false "start_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Metrics_types.start_time_unix_nano; + Pbrt.Pp.pp_record_field ~first:false "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Metrics_types.time_unix_nano; + Pbrt.Pp.pp_record_field ~first:false "value" pp_number_data_point_value fmt v.Metrics_types.value; + Pbrt.Pp.pp_record_field ~first:false "exemplars" (Pbrt.Pp.pp_list pp_exemplar) fmt v.Metrics_types.exemplars; + Pbrt.Pp.pp_record_field ~first:false "flags" Pbrt.Pp.pp_int32 fmt v.Metrics_types.flags; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_sum fmt (v:Metrics_types.sum) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "data_points" (Pbrt.Pp.pp_list pp_number_data_point) fmt v.Metrics_types.data_points; + Pbrt.Pp.pp_record_field ~first:false "aggregation_temporality" pp_aggregation_temporality fmt v.Metrics_types.aggregation_temporality; + Pbrt.Pp.pp_record_field ~first:false "is_monotonic" Pbrt.Pp.pp_bool fmt v.Metrics_types.is_monotonic; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_gauge fmt (v:Metrics_types.gauge) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "data_points" (Pbrt.Pp.pp_list pp_number_data_point) fmt v.Metrics_types.data_points; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_metric_data fmt (v:Metrics_types.metric_data) = + match v with + | Metrics_types.Summary x -> Format.fprintf fmt "@[Summary(@,%a)@]" pp_summary x + | Metrics_types.Exponential_histogram x -> Format.fprintf fmt "@[Exponential_histogram(@,%a)@]" pp_exponential_histogram x + | Metrics_types.Histogram x -> Format.fprintf fmt "@[Histogram(@,%a)@]" pp_histogram x + | Metrics_types.Sum x -> Format.fprintf fmt "@[Sum(@,%a)@]" pp_sum x + | Metrics_types.Gauge x -> Format.fprintf fmt "@[Gauge(@,%a)@]" pp_gauge x + +and pp_metric fmt (v:Metrics_types.metric) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "name" Pbrt.Pp.pp_string fmt v.Metrics_types.name; + Pbrt.Pp.pp_record_field ~first:false "description" Pbrt.Pp.pp_string fmt v.Metrics_types.description; + Pbrt.Pp.pp_record_field ~first:false "unit_" Pbrt.Pp.pp_string fmt v.Metrics_types.unit_; + Pbrt.Pp.pp_record_field ~first:false "data" pp_metric_data fmt v.Metrics_types.data; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_scope_metrics fmt (v:Metrics_types.scope_metrics) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "scope" (Pbrt.Pp.pp_option Common_pp.pp_instrumentation_scope) fmt v.Metrics_types.scope; + Pbrt.Pp.pp_record_field ~first:false "metrics" (Pbrt.Pp.pp_list pp_metric) fmt v.Metrics_types.metrics; + Pbrt.Pp.pp_record_field ~first:false "schema_url" Pbrt.Pp.pp_string fmt v.Metrics_types.schema_url; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_resource_metrics fmt (v:Metrics_types.resource_metrics) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "resource" (Pbrt.Pp.pp_option Resource_pp.pp_resource) fmt v.Metrics_types.resource; + Pbrt.Pp.pp_record_field ~first:false "scope_metrics" (Pbrt.Pp.pp_list pp_scope_metrics) fmt v.Metrics_types.scope_metrics; + Pbrt.Pp.pp_record_field ~first:false "schema_url" Pbrt.Pp.pp_string fmt v.Metrics_types.schema_url; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_metrics_data fmt (v:Metrics_types.metrics_data) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "resource_metrics" (Pbrt.Pp.pp_list pp_resource_metrics) fmt v.Metrics_types.resource_metrics; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_data_point_flags fmt (v:Metrics_types.data_point_flags) = + match v with + | Metrics_types.Data_point_flags_do_not_use -> Format.fprintf fmt "Data_point_flags_do_not_use" + | Metrics_types.Data_point_flags_no_recorded_value_mask -> Format.fprintf fmt "Data_point_flags_no_recorded_value_mask" diff --git a/src/proto/metrics_pp.mli b/src/proto/metrics_pp.mli new file mode 100644 index 00000000..7ee4b6fc --- /dev/null +++ b/src/proto/metrics_pp.mli @@ -0,0 +1,68 @@ + +(** metrics.proto Pretty Printing *) + + +(** {2 Formatters} *) + +val pp_summary_data_point_value_at_quantile : Format.formatter -> Metrics_types.summary_data_point_value_at_quantile -> unit +(** [pp_summary_data_point_value_at_quantile v] formats v *) + +val pp_summary_data_point : Format.formatter -> Metrics_types.summary_data_point -> unit +(** [pp_summary_data_point v] formats v *) + +val pp_summary : Format.formatter -> Metrics_types.summary -> unit +(** [pp_summary v] formats v *) + +val pp_exponential_histogram_data_point_buckets : Format.formatter -> Metrics_types.exponential_histogram_data_point_buckets -> unit +(** [pp_exponential_histogram_data_point_buckets v] formats v *) + +val pp_exemplar_value : Format.formatter -> Metrics_types.exemplar_value -> unit +(** [pp_exemplar_value v] formats v *) + +val pp_exemplar : Format.formatter -> Metrics_types.exemplar -> unit +(** [pp_exemplar v] formats v *) + +val pp_exponential_histogram_data_point : Format.formatter -> Metrics_types.exponential_histogram_data_point -> unit +(** [pp_exponential_histogram_data_point v] formats v *) + +val pp_aggregation_temporality : Format.formatter -> Metrics_types.aggregation_temporality -> unit +(** [pp_aggregation_temporality v] formats v *) + +val pp_exponential_histogram : Format.formatter -> Metrics_types.exponential_histogram -> unit +(** [pp_exponential_histogram v] formats v *) + +val pp_histogram_data_point : Format.formatter -> Metrics_types.histogram_data_point -> unit +(** [pp_histogram_data_point v] formats v *) + +val pp_histogram : Format.formatter -> Metrics_types.histogram -> unit +(** [pp_histogram v] formats v *) + +val pp_number_data_point_value : Format.formatter -> Metrics_types.number_data_point_value -> unit +(** [pp_number_data_point_value v] formats v *) + +val pp_number_data_point : Format.formatter -> Metrics_types.number_data_point -> unit +(** [pp_number_data_point v] formats v *) + +val pp_sum : Format.formatter -> Metrics_types.sum -> unit +(** [pp_sum v] formats v *) + +val pp_gauge : Format.formatter -> Metrics_types.gauge -> unit +(** [pp_gauge v] formats v *) + +val pp_metric_data : Format.formatter -> Metrics_types.metric_data -> unit +(** [pp_metric_data v] formats v *) + +val pp_metric : Format.formatter -> Metrics_types.metric -> unit +(** [pp_metric v] formats v *) + +val pp_scope_metrics : Format.formatter -> Metrics_types.scope_metrics -> unit +(** [pp_scope_metrics v] formats v *) + +val pp_resource_metrics : Format.formatter -> Metrics_types.resource_metrics -> unit +(** [pp_resource_metrics v] formats v *) + +val pp_metrics_data : Format.formatter -> Metrics_types.metrics_data -> unit +(** [pp_metrics_data v] formats v *) + +val pp_data_point_flags : Format.formatter -> Metrics_types.data_point_flags -> unit +(** [pp_data_point_flags v] formats v *) diff --git a/src/proto/metrics_service_pb.ml b/src/proto/metrics_service_pb.ml new file mode 100644 index 00000000..dd839d9b --- /dev/null +++ b/src/proto/metrics_service_pb.ml @@ -0,0 +1,112 @@ +[@@@ocaml.warning "-27-30-39"] + +type export_metrics_service_request_mutable = { + mutable resource_metrics : Metrics_types.resource_metrics list; +} + +let default_export_metrics_service_request_mutable () : export_metrics_service_request_mutable = { + resource_metrics = []; +} + +type export_metrics_partial_success_mutable = { + mutable rejected_data_points : int64; + mutable error_message : string; +} + +let default_export_metrics_partial_success_mutable () : export_metrics_partial_success_mutable = { + rejected_data_points = 0L; + error_message = ""; +} + +type export_metrics_service_response_mutable = { + mutable partial_success : Metrics_service_types.export_metrics_partial_success option; +} + +let default_export_metrics_service_response_mutable () : export_metrics_service_response_mutable = { + partial_success = None; +} + + +let rec decode_export_metrics_service_request d = + let v = default_export_metrics_service_request_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.resource_metrics <- List.rev v.resource_metrics; + ); continue__ := false + | Some (1, Pbrt.Bytes) -> begin + v.resource_metrics <- (Metrics_pb.decode_resource_metrics (Pbrt.Decoder.nested d)) :: v.resource_metrics; + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(export_metrics_service_request), field(1)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Metrics_service_types.resource_metrics = v.resource_metrics; + } : Metrics_service_types.export_metrics_service_request) + +let rec decode_export_metrics_partial_success d = + let v = default_export_metrics_partial_success_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + ); continue__ := false + | Some (1, Pbrt.Varint) -> begin + v.rejected_data_points <- Pbrt.Decoder.int64_as_varint d; + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(export_metrics_partial_success), field(1)" pk + | Some (2, Pbrt.Bytes) -> begin + v.error_message <- Pbrt.Decoder.string d; + end + | Some (2, pk) -> + Pbrt.Decoder.unexpected_payload "Message(export_metrics_partial_success), field(2)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Metrics_service_types.rejected_data_points = v.rejected_data_points; + Metrics_service_types.error_message = v.error_message; + } : Metrics_service_types.export_metrics_partial_success) + +let rec decode_export_metrics_service_response d = + let v = default_export_metrics_service_response_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + ); continue__ := false + | Some (1, Pbrt.Bytes) -> begin + v.partial_success <- Some (decode_export_metrics_partial_success (Pbrt.Decoder.nested d)); + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(export_metrics_service_response), field(1)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Metrics_service_types.partial_success = v.partial_success; + } : Metrics_service_types.export_metrics_service_response) + +let rec encode_export_metrics_service_request (v:Metrics_service_types.export_metrics_service_request) encoder = + List.iter (fun x -> + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (Metrics_pb.encode_resource_metrics x) encoder; + ) v.Metrics_service_types.resource_metrics; + () + +let rec encode_export_metrics_partial_success (v:Metrics_service_types.export_metrics_partial_success) encoder = + Pbrt.Encoder.key (1, Pbrt.Varint) encoder; + Pbrt.Encoder.int64_as_varint v.Metrics_service_types.rejected_data_points encoder; + Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; + Pbrt.Encoder.string v.Metrics_service_types.error_message encoder; + () + +let rec encode_export_metrics_service_response (v:Metrics_service_types.export_metrics_service_response) encoder = + begin match v.Metrics_service_types.partial_success with + | Some x -> + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_export_metrics_partial_success x) encoder; + | None -> (); + end; + () diff --git a/src/proto/metrics_service_pb.mli b/src/proto/metrics_service_pb.mli new file mode 100644 index 00000000..ed839b04 --- /dev/null +++ b/src/proto/metrics_service_pb.mli @@ -0,0 +1,25 @@ +(** metrics_service.proto Binary Encoding *) + + +(** {2 Protobuf Encoding} *) + +val encode_export_metrics_service_request : Metrics_service_types.export_metrics_service_request -> Pbrt.Encoder.t -> unit +(** [encode_export_metrics_service_request v encoder] encodes [v] with the given [encoder] *) + +val encode_export_metrics_partial_success : Metrics_service_types.export_metrics_partial_success -> Pbrt.Encoder.t -> unit +(** [encode_export_metrics_partial_success v encoder] encodes [v] with the given [encoder] *) + +val encode_export_metrics_service_response : Metrics_service_types.export_metrics_service_response -> Pbrt.Encoder.t -> unit +(** [encode_export_metrics_service_response v encoder] encodes [v] with the given [encoder] *) + + +(** {2 Protobuf Decoding} *) + +val decode_export_metrics_service_request : Pbrt.Decoder.t -> Metrics_service_types.export_metrics_service_request +(** [decode_export_metrics_service_request decoder] decodes a [export_metrics_service_request] value from [decoder] *) + +val decode_export_metrics_partial_success : Pbrt.Decoder.t -> Metrics_service_types.export_metrics_partial_success +(** [decode_export_metrics_partial_success decoder] decodes a [export_metrics_partial_success] value from [decoder] *) + +val decode_export_metrics_service_response : Pbrt.Decoder.t -> Metrics_service_types.export_metrics_service_response +(** [decode_export_metrics_service_response decoder] decodes a [export_metrics_service_response] value from [decoder] *) diff --git a/src/proto/metrics_service_pp.ml b/src/proto/metrics_service_pp.ml new file mode 100644 index 00000000..bb0f7a3b --- /dev/null +++ b/src/proto/metrics_service_pp.ml @@ -0,0 +1,20 @@ +[@@@ocaml.warning "-27-30-39"] + +let rec pp_export_metrics_service_request fmt (v:Metrics_service_types.export_metrics_service_request) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "resource_metrics" (Pbrt.Pp.pp_list Metrics_pp.pp_resource_metrics) fmt v.Metrics_service_types.resource_metrics; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_export_metrics_partial_success fmt (v:Metrics_service_types.export_metrics_partial_success) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "rejected_data_points" Pbrt.Pp.pp_int64 fmt v.Metrics_service_types.rejected_data_points; + Pbrt.Pp.pp_record_field ~first:false "error_message" Pbrt.Pp.pp_string fmt v.Metrics_service_types.error_message; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_export_metrics_service_response fmt (v:Metrics_service_types.export_metrics_service_response) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "partial_success" (Pbrt.Pp.pp_option pp_export_metrics_partial_success) fmt v.Metrics_service_types.partial_success; + in + Pbrt.Pp.pp_brk pp_i fmt () diff --git a/src/proto/metrics_service_pp.mli b/src/proto/metrics_service_pp.mli new file mode 100644 index 00000000..c9b5ed6f --- /dev/null +++ b/src/proto/metrics_service_pp.mli @@ -0,0 +1,14 @@ + +(** metrics_service.proto Pretty Printing *) + + +(** {2 Formatters} *) + +val pp_export_metrics_service_request : Format.formatter -> Metrics_service_types.export_metrics_service_request -> unit +(** [pp_export_metrics_service_request v] formats v *) + +val pp_export_metrics_partial_success : Format.formatter -> Metrics_service_types.export_metrics_partial_success -> unit +(** [pp_export_metrics_partial_success v] formats v *) + +val pp_export_metrics_service_response : Format.formatter -> Metrics_service_types.export_metrics_service_response -> unit +(** [pp_export_metrics_service_response v] formats v *) diff --git a/src/proto/metrics_service_types.ml b/src/proto/metrics_service_types.ml new file mode 100644 index 00000000..8b252a24 --- /dev/null +++ b/src/proto/metrics_service_types.ml @@ -0,0 +1,35 @@ +[@@@ocaml.warning "-27-30-39"] + + +type export_metrics_service_request = { + resource_metrics : Metrics_types.resource_metrics list; +} + +type export_metrics_partial_success = { + rejected_data_points : int64; + error_message : string; +} + +type export_metrics_service_response = { + partial_success : export_metrics_partial_success option; +} + +let rec default_export_metrics_service_request + ?resource_metrics:((resource_metrics:Metrics_types.resource_metrics list) = []) + () : export_metrics_service_request = { + resource_metrics; +} + +let rec default_export_metrics_partial_success + ?rejected_data_points:((rejected_data_points:int64) = 0L) + ?error_message:((error_message:string) = "") + () : export_metrics_partial_success = { + rejected_data_points; + error_message; +} + +let rec default_export_metrics_service_response + ?partial_success:((partial_success:export_metrics_partial_success option) = None) + () : export_metrics_service_response = { + partial_success; +} diff --git a/src/proto/metrics_service_types.mli b/src/proto/metrics_service_types.mli new file mode 100644 index 00000000..cbcddfed --- /dev/null +++ b/src/proto/metrics_service_types.mli @@ -0,0 +1,40 @@ +(** metrics_service.proto Types *) + + + +(** {2 Types} *) + +type export_metrics_service_request = { + resource_metrics : Metrics_types.resource_metrics list; +} + +type export_metrics_partial_success = { + rejected_data_points : int64; + error_message : string; +} + +type export_metrics_service_response = { + partial_success : export_metrics_partial_success option; +} + + +(** {2 Default values} *) + +val default_export_metrics_service_request : + ?resource_metrics:Metrics_types.resource_metrics list -> + unit -> + export_metrics_service_request +(** [default_export_metrics_service_request ()] is the default value for type [export_metrics_service_request] *) + +val default_export_metrics_partial_success : + ?rejected_data_points:int64 -> + ?error_message:string -> + unit -> + export_metrics_partial_success +(** [default_export_metrics_partial_success ()] is the default value for type [export_metrics_partial_success] *) + +val default_export_metrics_service_response : + ?partial_success:export_metrics_partial_success option -> + unit -> + export_metrics_service_response +(** [default_export_metrics_service_response ()] is the default value for type [export_metrics_service_response] *) diff --git a/src/proto/metrics_types.ml b/src/proto/metrics_types.ml new file mode 100644 index 00000000..d238843c --- /dev/null +++ b/src/proto/metrics_types.ml @@ -0,0 +1,349 @@ +[@@@ocaml.warning "-27-30-39"] + + +type summary_data_point_value_at_quantile = { + quantile : float; + value : float; +} + +type summary_data_point = { + attributes : Common_types.key_value list; + start_time_unix_nano : int64; + time_unix_nano : int64; + count : int64; + sum : float; + quantile_values : summary_data_point_value_at_quantile list; + flags : int32; +} + +type summary = { + data_points : summary_data_point list; +} + +type exponential_histogram_data_point_buckets = { + offset : int32; + bucket_counts : int64 list; +} + +type exemplar_value = + | As_int of int64 + | As_double of float + +and exemplar = { + filtered_attributes : Common_types.key_value list; + time_unix_nano : int64; + value : exemplar_value; + span_id : bytes; + trace_id : bytes; +} + +type exponential_histogram_data_point = { + attributes : Common_types.key_value list; + start_time_unix_nano : int64; + time_unix_nano : int64; + count : int64; + sum : float option; + scale : int32; + zero_count : int64; + positive : exponential_histogram_data_point_buckets option; + negative : exponential_histogram_data_point_buckets option; + flags : int32; + exemplars : exemplar list; + min : float option; + max : float option; + zero_threshold : float; +} + +type aggregation_temporality = + | Aggregation_temporality_unspecified + | Aggregation_temporality_delta + | Aggregation_temporality_cumulative + +type exponential_histogram = { + data_points : exponential_histogram_data_point list; + aggregation_temporality : aggregation_temporality; +} + +type histogram_data_point = { + attributes : Common_types.key_value list; + start_time_unix_nano : int64; + time_unix_nano : int64; + count : int64; + sum : float option; + bucket_counts : int64 list; + explicit_bounds : float list; + exemplars : exemplar list; + flags : int32; + min : float option; + max : float option; +} + +type histogram = { + data_points : histogram_data_point list; + aggregation_temporality : aggregation_temporality; +} + +type number_data_point_value = + | As_int of int64 + | As_double of float + +and number_data_point = { + attributes : Common_types.key_value list; + start_time_unix_nano : int64; + time_unix_nano : int64; + value : number_data_point_value; + exemplars : exemplar list; + flags : int32; +} + +type sum = { + data_points : number_data_point list; + aggregation_temporality : aggregation_temporality; + is_monotonic : bool; +} + +type gauge = { + data_points : number_data_point list; +} + +type metric_data = + | Summary of summary + | Exponential_histogram of exponential_histogram + | Histogram of histogram + | Sum of sum + | Gauge of gauge + +and metric = { + name : string; + description : string; + unit_ : string; + data : metric_data; +} + +type scope_metrics = { + scope : Common_types.instrumentation_scope option; + metrics : metric list; + schema_url : string; +} + +type resource_metrics = { + resource : Resource_types.resource option; + scope_metrics : scope_metrics list; + schema_url : string; +} + +type metrics_data = { + resource_metrics : resource_metrics list; +} + +type data_point_flags = + | Data_point_flags_do_not_use + | Data_point_flags_no_recorded_value_mask + +let rec default_summary_data_point_value_at_quantile + ?quantile:((quantile:float) = 0.) + ?value:((value:float) = 0.) + () : summary_data_point_value_at_quantile = { + quantile; + value; +} + +let rec default_summary_data_point + ?attributes:((attributes:Common_types.key_value list) = []) + ?start_time_unix_nano:((start_time_unix_nano:int64) = 0L) + ?time_unix_nano:((time_unix_nano:int64) = 0L) + ?count:((count:int64) = 0L) + ?sum:((sum:float) = 0.) + ?quantile_values:((quantile_values:summary_data_point_value_at_quantile list) = []) + ?flags:((flags:int32) = 0l) + () : summary_data_point = { + attributes; + start_time_unix_nano; + time_unix_nano; + count; + sum; + quantile_values; + flags; +} + +let rec default_summary + ?data_points:((data_points:summary_data_point list) = []) + () : summary = { + data_points; +} + +let rec default_exponential_histogram_data_point_buckets + ?offset:((offset:int32) = 0l) + ?bucket_counts:((bucket_counts:int64 list) = []) + () : exponential_histogram_data_point_buckets = { + offset; + bucket_counts; +} + +let rec default_exemplar_value () : exemplar_value = As_int (0L) + +and default_exemplar + ?filtered_attributes:((filtered_attributes:Common_types.key_value list) = []) + ?time_unix_nano:((time_unix_nano:int64) = 0L) + ?value:((value:exemplar_value) = As_int (0L)) + ?span_id:((span_id:bytes) = Bytes.create 0) + ?trace_id:((trace_id:bytes) = Bytes.create 0) + () : exemplar = { + filtered_attributes; + time_unix_nano; + value; + span_id; + trace_id; +} + +let rec default_exponential_histogram_data_point + ?attributes:((attributes:Common_types.key_value list) = []) + ?start_time_unix_nano:((start_time_unix_nano:int64) = 0L) + ?time_unix_nano:((time_unix_nano:int64) = 0L) + ?count:((count:int64) = 0L) + ?sum:((sum:float option) = None) + ?scale:((scale:int32) = 0l) + ?zero_count:((zero_count:int64) = 0L) + ?positive:((positive:exponential_histogram_data_point_buckets option) = None) + ?negative:((negative:exponential_histogram_data_point_buckets option) = None) + ?flags:((flags:int32) = 0l) + ?exemplars:((exemplars:exemplar list) = []) + ?min:((min:float option) = None) + ?max:((max:float option) = None) + ?zero_threshold:((zero_threshold:float) = 0.) + () : exponential_histogram_data_point = { + attributes; + start_time_unix_nano; + time_unix_nano; + count; + sum; + scale; + zero_count; + positive; + negative; + flags; + exemplars; + min; + max; + zero_threshold; +} + +let rec default_aggregation_temporality () = (Aggregation_temporality_unspecified:aggregation_temporality) + +let rec default_exponential_histogram + ?data_points:((data_points:exponential_histogram_data_point list) = []) + ?aggregation_temporality:((aggregation_temporality:aggregation_temporality) = default_aggregation_temporality ()) + () : exponential_histogram = { + data_points; + aggregation_temporality; +} + +let rec default_histogram_data_point + ?attributes:((attributes:Common_types.key_value list) = []) + ?start_time_unix_nano:((start_time_unix_nano:int64) = 0L) + ?time_unix_nano:((time_unix_nano:int64) = 0L) + ?count:((count:int64) = 0L) + ?sum:((sum:float option) = None) + ?bucket_counts:((bucket_counts:int64 list) = []) + ?explicit_bounds:((explicit_bounds:float list) = []) + ?exemplars:((exemplars:exemplar list) = []) + ?flags:((flags:int32) = 0l) + ?min:((min:float option) = None) + ?max:((max:float option) = None) + () : histogram_data_point = { + attributes; + start_time_unix_nano; + time_unix_nano; + count; + sum; + bucket_counts; + explicit_bounds; + exemplars; + flags; + min; + max; +} + +let rec default_histogram + ?data_points:((data_points:histogram_data_point list) = []) + ?aggregation_temporality:((aggregation_temporality:aggregation_temporality) = default_aggregation_temporality ()) + () : histogram = { + data_points; + aggregation_temporality; +} + +let rec default_number_data_point_value () : number_data_point_value = As_int (0L) + +and default_number_data_point + ?attributes:((attributes:Common_types.key_value list) = []) + ?start_time_unix_nano:((start_time_unix_nano:int64) = 0L) + ?time_unix_nano:((time_unix_nano:int64) = 0L) + ?value:((value:number_data_point_value) = As_int (0L)) + ?exemplars:((exemplars:exemplar list) = []) + ?flags:((flags:int32) = 0l) + () : number_data_point = { + attributes; + start_time_unix_nano; + time_unix_nano; + value; + exemplars; + flags; +} + +let rec default_sum + ?data_points:((data_points:number_data_point list) = []) + ?aggregation_temporality:((aggregation_temporality:aggregation_temporality) = default_aggregation_temporality ()) + ?is_monotonic:((is_monotonic:bool) = false) + () : sum = { + data_points; + aggregation_temporality; + is_monotonic; +} + +let rec default_gauge + ?data_points:((data_points:number_data_point list) = []) + () : gauge = { + data_points; +} + +let rec default_metric_data () : metric_data = Summary (default_summary ()) + +and default_metric + ?name:((name:string) = "") + ?description:((description:string) = "") + ?unit_:((unit_:string) = "") + ?data:((data:metric_data) = Summary (default_summary ())) + () : metric = { + name; + description; + unit_; + data; +} + +let rec default_scope_metrics + ?scope:((scope:Common_types.instrumentation_scope option) = None) + ?metrics:((metrics:metric list) = []) + ?schema_url:((schema_url:string) = "") + () : scope_metrics = { + scope; + metrics; + schema_url; +} + +let rec default_resource_metrics + ?resource:((resource:Resource_types.resource option) = None) + ?scope_metrics:((scope_metrics:scope_metrics list) = []) + ?schema_url:((schema_url:string) = "") + () : resource_metrics = { + resource; + scope_metrics; + schema_url; +} + +let rec default_metrics_data + ?resource_metrics:((resource_metrics:resource_metrics list) = []) + () : metrics_data = { + resource_metrics; +} + +let rec default_data_point_flags () = (Data_point_flags_do_not_use:data_point_flags) diff --git a/src/proto/metrics_types.mli b/src/proto/metrics_types.mli new file mode 100644 index 00000000..17471582 --- /dev/null +++ b/src/proto/metrics_types.mli @@ -0,0 +1,309 @@ +(** metrics.proto Types *) + + + +(** {2 Types} *) + +type summary_data_point_value_at_quantile = { + quantile : float; + value : float; +} + +type summary_data_point = { + attributes : Common_types.key_value list; + start_time_unix_nano : int64; + time_unix_nano : int64; + count : int64; + sum : float; + quantile_values : summary_data_point_value_at_quantile list; + flags : int32; +} + +type summary = { + data_points : summary_data_point list; +} + +type exponential_histogram_data_point_buckets = { + offset : int32; + bucket_counts : int64 list; +} + +type exemplar_value = + | As_int of int64 + | As_double of float + +and exemplar = { + filtered_attributes : Common_types.key_value list; + time_unix_nano : int64; + value : exemplar_value; + span_id : bytes; + trace_id : bytes; +} + +type exponential_histogram_data_point = { + attributes : Common_types.key_value list; + start_time_unix_nano : int64; + time_unix_nano : int64; + count : int64; + sum : float option; + scale : int32; + zero_count : int64; + positive : exponential_histogram_data_point_buckets option; + negative : exponential_histogram_data_point_buckets option; + flags : int32; + exemplars : exemplar list; + min : float option; + max : float option; + zero_threshold : float; +} + +type aggregation_temporality = + | Aggregation_temporality_unspecified + | Aggregation_temporality_delta + | Aggregation_temporality_cumulative + +type exponential_histogram = { + data_points : exponential_histogram_data_point list; + aggregation_temporality : aggregation_temporality; +} + +type histogram_data_point = { + attributes : Common_types.key_value list; + start_time_unix_nano : int64; + time_unix_nano : int64; + count : int64; + sum : float option; + bucket_counts : int64 list; + explicit_bounds : float list; + exemplars : exemplar list; + flags : int32; + min : float option; + max : float option; +} + +type histogram = { + data_points : histogram_data_point list; + aggregation_temporality : aggregation_temporality; +} + +type number_data_point_value = + | As_int of int64 + | As_double of float + +and number_data_point = { + attributes : Common_types.key_value list; + start_time_unix_nano : int64; + time_unix_nano : int64; + value : number_data_point_value; + exemplars : exemplar list; + flags : int32; +} + +type sum = { + data_points : number_data_point list; + aggregation_temporality : aggregation_temporality; + is_monotonic : bool; +} + +type gauge = { + data_points : number_data_point list; +} + +type metric_data = + | Summary of summary + | Exponential_histogram of exponential_histogram + | Histogram of histogram + | Sum of sum + | Gauge of gauge + +and metric = { + name : string; + description : string; + unit_ : string; + data : metric_data; +} + +type scope_metrics = { + scope : Common_types.instrumentation_scope option; + metrics : metric list; + schema_url : string; +} + +type resource_metrics = { + resource : Resource_types.resource option; + scope_metrics : scope_metrics list; + schema_url : string; +} + +type metrics_data = { + resource_metrics : resource_metrics list; +} + +type data_point_flags = + | Data_point_flags_do_not_use + | Data_point_flags_no_recorded_value_mask + + +(** {2 Default values} *) + +val default_summary_data_point_value_at_quantile : + ?quantile:float -> + ?value:float -> + unit -> + summary_data_point_value_at_quantile +(** [default_summary_data_point_value_at_quantile ()] is the default value for type [summary_data_point_value_at_quantile] *) + +val default_summary_data_point : + ?attributes:Common_types.key_value list -> + ?start_time_unix_nano:int64 -> + ?time_unix_nano:int64 -> + ?count:int64 -> + ?sum:float -> + ?quantile_values:summary_data_point_value_at_quantile list -> + ?flags:int32 -> + unit -> + summary_data_point +(** [default_summary_data_point ()] is the default value for type [summary_data_point] *) + +val default_summary : + ?data_points:summary_data_point list -> + unit -> + summary +(** [default_summary ()] is the default value for type [summary] *) + +val default_exponential_histogram_data_point_buckets : + ?offset:int32 -> + ?bucket_counts:int64 list -> + unit -> + exponential_histogram_data_point_buckets +(** [default_exponential_histogram_data_point_buckets ()] is the default value for type [exponential_histogram_data_point_buckets] *) + +val default_exemplar_value : unit -> exemplar_value +(** [default_exemplar_value ()] is the default value for type [exemplar_value] *) + +val default_exemplar : + ?filtered_attributes:Common_types.key_value list -> + ?time_unix_nano:int64 -> + ?value:exemplar_value -> + ?span_id:bytes -> + ?trace_id:bytes -> + unit -> + exemplar +(** [default_exemplar ()] is the default value for type [exemplar] *) + +val default_exponential_histogram_data_point : + ?attributes:Common_types.key_value list -> + ?start_time_unix_nano:int64 -> + ?time_unix_nano:int64 -> + ?count:int64 -> + ?sum:float option -> + ?scale:int32 -> + ?zero_count:int64 -> + ?positive:exponential_histogram_data_point_buckets option -> + ?negative:exponential_histogram_data_point_buckets option -> + ?flags:int32 -> + ?exemplars:exemplar list -> + ?min:float option -> + ?max:float option -> + ?zero_threshold:float -> + unit -> + exponential_histogram_data_point +(** [default_exponential_histogram_data_point ()] is the default value for type [exponential_histogram_data_point] *) + +val default_aggregation_temporality : unit -> aggregation_temporality +(** [default_aggregation_temporality ()] is the default value for type [aggregation_temporality] *) + +val default_exponential_histogram : + ?data_points:exponential_histogram_data_point list -> + ?aggregation_temporality:aggregation_temporality -> + unit -> + exponential_histogram +(** [default_exponential_histogram ()] is the default value for type [exponential_histogram] *) + +val default_histogram_data_point : + ?attributes:Common_types.key_value list -> + ?start_time_unix_nano:int64 -> + ?time_unix_nano:int64 -> + ?count:int64 -> + ?sum:float option -> + ?bucket_counts:int64 list -> + ?explicit_bounds:float list -> + ?exemplars:exemplar list -> + ?flags:int32 -> + ?min:float option -> + ?max:float option -> + unit -> + histogram_data_point +(** [default_histogram_data_point ()] is the default value for type [histogram_data_point] *) + +val default_histogram : + ?data_points:histogram_data_point list -> + ?aggregation_temporality:aggregation_temporality -> + unit -> + histogram +(** [default_histogram ()] is the default value for type [histogram] *) + +val default_number_data_point_value : unit -> number_data_point_value +(** [default_number_data_point_value ()] is the default value for type [number_data_point_value] *) + +val default_number_data_point : + ?attributes:Common_types.key_value list -> + ?start_time_unix_nano:int64 -> + ?time_unix_nano:int64 -> + ?value:number_data_point_value -> + ?exemplars:exemplar list -> + ?flags:int32 -> + unit -> + number_data_point +(** [default_number_data_point ()] is the default value for type [number_data_point] *) + +val default_sum : + ?data_points:number_data_point list -> + ?aggregation_temporality:aggregation_temporality -> + ?is_monotonic:bool -> + unit -> + sum +(** [default_sum ()] is the default value for type [sum] *) + +val default_gauge : + ?data_points:number_data_point list -> + unit -> + gauge +(** [default_gauge ()] is the default value for type [gauge] *) + +val default_metric_data : unit -> metric_data +(** [default_metric_data ()] is the default value for type [metric_data] *) + +val default_metric : + ?name:string -> + ?description:string -> + ?unit_:string -> + ?data:metric_data -> + unit -> + metric +(** [default_metric ()] is the default value for type [metric] *) + +val default_scope_metrics : + ?scope:Common_types.instrumentation_scope option -> + ?metrics:metric list -> + ?schema_url:string -> + unit -> + scope_metrics +(** [default_scope_metrics ()] is the default value for type [scope_metrics] *) + +val default_resource_metrics : + ?resource:Resource_types.resource option -> + ?scope_metrics:scope_metrics list -> + ?schema_url:string -> + unit -> + resource_metrics +(** [default_resource_metrics ()] is the default value for type [resource_metrics] *) + +val default_metrics_data : + ?resource_metrics:resource_metrics list -> + unit -> + metrics_data +(** [default_metrics_data ()] is the default value for type [metrics_data] *) + +val default_data_point_flags : unit -> data_point_flags +(** [default_data_point_flags ()] is the default value for type [data_point_flags] *) diff --git a/src/proto/resource_pb.ml b/src/proto/resource_pb.ml new file mode 100644 index 00000000..ac8a051f --- /dev/null +++ b/src/proto/resource_pb.ml @@ -0,0 +1,46 @@ +[@@@ocaml.warning "-27-30-39"] + +type resource_mutable = { + mutable attributes : Common_types.key_value list; + mutable dropped_attributes_count : int32; +} + +let default_resource_mutable () : resource_mutable = { + attributes = []; + dropped_attributes_count = 0l; +} + + +let rec decode_resource d = + let v = default_resource_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.attributes <- List.rev v.attributes; + ); continue__ := false + | Some (1, Pbrt.Bytes) -> begin + v.attributes <- (Common_pb.decode_key_value (Pbrt.Decoder.nested d)) :: v.attributes; + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(resource), field(1)" pk + | Some (2, Pbrt.Varint) -> begin + v.dropped_attributes_count <- Pbrt.Decoder.int32_as_varint d; + end + | Some (2, pk) -> + Pbrt.Decoder.unexpected_payload "Message(resource), field(2)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Resource_types.attributes = v.attributes; + Resource_types.dropped_attributes_count = v.dropped_attributes_count; + } : Resource_types.resource) + +let rec encode_resource (v:Resource_types.resource) encoder = + List.iter (fun x -> + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (Common_pb.encode_key_value x) encoder; + ) v.Resource_types.attributes; + Pbrt.Encoder.key (2, Pbrt.Varint) encoder; + Pbrt.Encoder.int32_as_varint v.Resource_types.dropped_attributes_count encoder; + () diff --git a/src/proto/resource_pb.mli b/src/proto/resource_pb.mli new file mode 100644 index 00000000..81136cbe --- /dev/null +++ b/src/proto/resource_pb.mli @@ -0,0 +1,13 @@ +(** resource.proto Binary Encoding *) + + +(** {2 Protobuf Encoding} *) + +val encode_resource : Resource_types.resource -> Pbrt.Encoder.t -> unit +(** [encode_resource v encoder] encodes [v] with the given [encoder] *) + + +(** {2 Protobuf Decoding} *) + +val decode_resource : Pbrt.Decoder.t -> Resource_types.resource +(** [decode_resource decoder] decodes a [resource] value from [decoder] *) diff --git a/src/proto/resource_pp.ml b/src/proto/resource_pp.ml new file mode 100644 index 00000000..299fcdfc --- /dev/null +++ b/src/proto/resource_pp.ml @@ -0,0 +1,8 @@ +[@@@ocaml.warning "-27-30-39"] + +let rec pp_resource fmt (v:Resource_types.resource) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "attributes" (Pbrt.Pp.pp_list Common_pp.pp_key_value) fmt v.Resource_types.attributes; + Pbrt.Pp.pp_record_field ~first:false "dropped_attributes_count" Pbrt.Pp.pp_int32 fmt v.Resource_types.dropped_attributes_count; + in + Pbrt.Pp.pp_brk pp_i fmt () diff --git a/src/proto/resource_pp.mli b/src/proto/resource_pp.mli new file mode 100644 index 00000000..f18aa338 --- /dev/null +++ b/src/proto/resource_pp.mli @@ -0,0 +1,8 @@ + +(** resource.proto Pretty Printing *) + + +(** {2 Formatters} *) + +val pp_resource : Format.formatter -> Resource_types.resource -> unit +(** [pp_resource v] formats v *) diff --git a/src/proto/resource_types.ml b/src/proto/resource_types.ml new file mode 100644 index 00000000..74b42266 --- /dev/null +++ b/src/proto/resource_types.ml @@ -0,0 +1,15 @@ +[@@@ocaml.warning "-27-30-39"] + + +type resource = { + attributes : Common_types.key_value list; + dropped_attributes_count : int32; +} + +let rec default_resource + ?attributes:((attributes:Common_types.key_value list) = []) + ?dropped_attributes_count:((dropped_attributes_count:int32) = 0l) + () : resource = { + attributes; + dropped_attributes_count; +} diff --git a/src/proto/resource_types.mli b/src/proto/resource_types.mli new file mode 100644 index 00000000..ff01acd2 --- /dev/null +++ b/src/proto/resource_types.mli @@ -0,0 +1,20 @@ +(** resource.proto Types *) + + + +(** {2 Types} *) + +type resource = { + attributes : Common_types.key_value list; + dropped_attributes_count : int32; +} + + +(** {2 Default values} *) + +val default_resource : + ?attributes:Common_types.key_value list -> + ?dropped_attributes_count:int32 -> + unit -> + resource +(** [default_resource ()] is the default value for type [resource] *) diff --git a/src/proto/status.proto b/src/proto/status.proto new file mode 100644 index 00000000..9812db51 --- /dev/null +++ b/src/proto/status.proto @@ -0,0 +1,10 @@ + +syntax = "proto3"; + +// from https://pkg.go.dev/google.golang.org/genproto/googleapis/rpc/status?utm_source=godoc#Status + +message Status { + int32 code = 1; + bytes message = 2; + repeated bytes details = 3; +} diff --git a/src/proto/status_pb.ml b/src/proto/status_pb.ml new file mode 100644 index 00000000..3fba0000 --- /dev/null +++ b/src/proto/status_pb.ml @@ -0,0 +1,56 @@ +[@@@ocaml.warning "-27-30-39"] + +type status_mutable = { + mutable code : int32; + mutable message : bytes; + mutable details : bytes list; +} + +let default_status_mutable () : status_mutable = { + code = 0l; + message = Bytes.create 0; + details = []; +} + + +let rec decode_status d = + let v = default_status_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.details <- List.rev v.details; + ); continue__ := false + | Some (1, Pbrt.Varint) -> begin + v.code <- Pbrt.Decoder.int32_as_varint d; + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(status), field(1)" pk + | Some (2, Pbrt.Bytes) -> begin + v.message <- Pbrt.Decoder.bytes d; + end + | Some (2, pk) -> + Pbrt.Decoder.unexpected_payload "Message(status), field(2)" pk + | Some (3, Pbrt.Bytes) -> begin + v.details <- (Pbrt.Decoder.bytes d) :: v.details; + end + | Some (3, pk) -> + Pbrt.Decoder.unexpected_payload "Message(status), field(3)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Status_types.code = v.code; + Status_types.message = v.message; + Status_types.details = v.details; + } : Status_types.status) + +let rec encode_status (v:Status_types.status) encoder = + Pbrt.Encoder.key (1, Pbrt.Varint) encoder; + Pbrt.Encoder.int32_as_varint v.Status_types.code encoder; + Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; + Pbrt.Encoder.bytes v.Status_types.message encoder; + List.iter (fun x -> + Pbrt.Encoder.key (3, Pbrt.Bytes) encoder; + Pbrt.Encoder.bytes x encoder; + ) v.Status_types.details; + () diff --git a/src/proto/status_pb.mli b/src/proto/status_pb.mli new file mode 100644 index 00000000..e6bcfaed --- /dev/null +++ b/src/proto/status_pb.mli @@ -0,0 +1,13 @@ +(** status.proto Binary Encoding *) + + +(** {2 Protobuf Encoding} *) + +val encode_status : Status_types.status -> Pbrt.Encoder.t -> unit +(** [encode_status v encoder] encodes [v] with the given [encoder] *) + + +(** {2 Protobuf Decoding} *) + +val decode_status : Pbrt.Decoder.t -> Status_types.status +(** [decode_status decoder] decodes a [status] value from [decoder] *) diff --git a/src/proto/status_pp.ml b/src/proto/status_pp.ml new file mode 100644 index 00000000..c5df29d9 --- /dev/null +++ b/src/proto/status_pp.ml @@ -0,0 +1,9 @@ +[@@@ocaml.warning "-27-30-39"] + +let rec pp_status fmt (v:Status_types.status) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "code" Pbrt.Pp.pp_int32 fmt v.Status_types.code; + Pbrt.Pp.pp_record_field ~first:false "message" Pbrt.Pp.pp_bytes fmt v.Status_types.message; + Pbrt.Pp.pp_record_field ~first:false "details" (Pbrt.Pp.pp_list Pbrt.Pp.pp_bytes) fmt v.Status_types.details; + in + Pbrt.Pp.pp_brk pp_i fmt () diff --git a/src/proto/status_pp.mli b/src/proto/status_pp.mli new file mode 100644 index 00000000..3333057d --- /dev/null +++ b/src/proto/status_pp.mli @@ -0,0 +1,8 @@ + +(** status.proto Pretty Printing *) + + +(** {2 Formatters} *) + +val pp_status : Format.formatter -> Status_types.status -> unit +(** [pp_status v] formats v *) diff --git a/src/proto/status_types.ml b/src/proto/status_types.ml new file mode 100644 index 00000000..14af622b --- /dev/null +++ b/src/proto/status_types.ml @@ -0,0 +1,18 @@ +[@@@ocaml.warning "-27-30-39"] + + +type status = { + code : int32; + message : bytes; + details : bytes list; +} + +let rec default_status + ?code:((code:int32) = 0l) + ?message:((message:bytes) = Bytes.create 0) + ?details:((details:bytes list) = []) + () : status = { + code; + message; + details; +} diff --git a/src/proto/status_types.mli b/src/proto/status_types.mli new file mode 100644 index 00000000..9947bc58 --- /dev/null +++ b/src/proto/status_types.mli @@ -0,0 +1,22 @@ +(** status.proto Types *) + + + +(** {2 Types} *) + +type status = { + code : int32; + message : bytes; + details : bytes list; +} + + +(** {2 Default values} *) + +val default_status : + ?code:int32 -> + ?message:bytes -> + ?details:bytes list -> + unit -> + status +(** [default_status ()] is the default value for type [status] *) diff --git a/src/proto/trace_pb.ml b/src/proto/trace_pb.ml new file mode 100644 index 00000000..1d2acfd9 --- /dev/null +++ b/src/proto/trace_pb.ml @@ -0,0 +1,547 @@ +[@@@ocaml.warning "-27-30-39"] + +type span_event_mutable = { + mutable time_unix_nano : int64; + mutable name : string; + mutable attributes : Common_types.key_value list; + mutable dropped_attributes_count : int32; +} + +let default_span_event_mutable () : span_event_mutable = { + time_unix_nano = 0L; + name = ""; + attributes = []; + dropped_attributes_count = 0l; +} + +type span_link_mutable = { + mutable trace_id : bytes; + mutable span_id : bytes; + mutable trace_state : string; + mutable attributes : Common_types.key_value list; + mutable dropped_attributes_count : int32; +} + +let default_span_link_mutable () : span_link_mutable = { + trace_id = Bytes.create 0; + span_id = Bytes.create 0; + trace_state = ""; + attributes = []; + dropped_attributes_count = 0l; +} + +type status_mutable = { + mutable message : string; + mutable code : Trace_types.status_status_code; +} + +let default_status_mutable () : status_mutable = { + message = ""; + code = Trace_types.default_status_status_code (); +} + +type span_mutable = { + mutable trace_id : bytes; + mutable span_id : bytes; + mutable trace_state : string; + mutable parent_span_id : bytes; + mutable name : string; + mutable kind : Trace_types.span_span_kind; + mutable start_time_unix_nano : int64; + mutable end_time_unix_nano : int64; + mutable attributes : Common_types.key_value list; + mutable dropped_attributes_count : int32; + mutable events : Trace_types.span_event list; + mutable dropped_events_count : int32; + mutable links : Trace_types.span_link list; + mutable dropped_links_count : int32; + mutable status : Trace_types.status option; +} + +let default_span_mutable () : span_mutable = { + trace_id = Bytes.create 0; + span_id = Bytes.create 0; + trace_state = ""; + parent_span_id = Bytes.create 0; + name = ""; + kind = Trace_types.default_span_span_kind (); + start_time_unix_nano = 0L; + end_time_unix_nano = 0L; + attributes = []; + dropped_attributes_count = 0l; + events = []; + dropped_events_count = 0l; + links = []; + dropped_links_count = 0l; + status = None; +} + +type scope_spans_mutable = { + mutable scope : Common_types.instrumentation_scope option; + mutable spans : Trace_types.span list; + mutable schema_url : string; +} + +let default_scope_spans_mutable () : scope_spans_mutable = { + scope = None; + spans = []; + schema_url = ""; +} + +type resource_spans_mutable = { + mutable resource : Resource_types.resource option; + mutable scope_spans : Trace_types.scope_spans list; + mutable schema_url : string; +} + +let default_resource_spans_mutable () : resource_spans_mutable = { + resource = None; + scope_spans = []; + schema_url = ""; +} + +type traces_data_mutable = { + mutable resource_spans : Trace_types.resource_spans list; +} + +let default_traces_data_mutable () : traces_data_mutable = { + resource_spans = []; +} + + +let rec decode_span_span_kind d = + match Pbrt.Decoder.int_as_varint d with + | 0 -> (Trace_types.Span_kind_unspecified:Trace_types.span_span_kind) + | 1 -> (Trace_types.Span_kind_internal:Trace_types.span_span_kind) + | 2 -> (Trace_types.Span_kind_server:Trace_types.span_span_kind) + | 3 -> (Trace_types.Span_kind_client:Trace_types.span_span_kind) + | 4 -> (Trace_types.Span_kind_producer:Trace_types.span_span_kind) + | 5 -> (Trace_types.Span_kind_consumer:Trace_types.span_span_kind) + | _ -> Pbrt.Decoder.malformed_variant "span_span_kind" + +let rec decode_span_event d = + let v = default_span_event_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.attributes <- List.rev v.attributes; + ); continue__ := false + | Some (1, Pbrt.Bits64) -> begin + v.time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(span_event), field(1)" pk + | Some (2, Pbrt.Bytes) -> begin + v.name <- Pbrt.Decoder.string d; + end + | Some (2, pk) -> + Pbrt.Decoder.unexpected_payload "Message(span_event), field(2)" pk + | Some (3, Pbrt.Bytes) -> begin + v.attributes <- (Common_pb.decode_key_value (Pbrt.Decoder.nested d)) :: v.attributes; + end + | Some (3, pk) -> + Pbrt.Decoder.unexpected_payload "Message(span_event), field(3)" pk + | Some (4, Pbrt.Varint) -> begin + v.dropped_attributes_count <- Pbrt.Decoder.int32_as_varint d; + end + | Some (4, pk) -> + Pbrt.Decoder.unexpected_payload "Message(span_event), field(4)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Trace_types.time_unix_nano = v.time_unix_nano; + Trace_types.name = v.name; + Trace_types.attributes = v.attributes; + Trace_types.dropped_attributes_count = v.dropped_attributes_count; + } : Trace_types.span_event) + +let rec decode_span_link d = + let v = default_span_link_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.attributes <- List.rev v.attributes; + ); continue__ := false + | Some (1, Pbrt.Bytes) -> begin + v.trace_id <- Pbrt.Decoder.bytes d; + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(span_link), field(1)" pk + | Some (2, Pbrt.Bytes) -> begin + v.span_id <- Pbrt.Decoder.bytes d; + end + | Some (2, pk) -> + Pbrt.Decoder.unexpected_payload "Message(span_link), field(2)" pk + | Some (3, Pbrt.Bytes) -> begin + v.trace_state <- Pbrt.Decoder.string d; + end + | Some (3, pk) -> + Pbrt.Decoder.unexpected_payload "Message(span_link), field(3)" pk + | Some (4, Pbrt.Bytes) -> begin + v.attributes <- (Common_pb.decode_key_value (Pbrt.Decoder.nested d)) :: v.attributes; + end + | Some (4, pk) -> + Pbrt.Decoder.unexpected_payload "Message(span_link), field(4)" pk + | Some (5, Pbrt.Varint) -> begin + v.dropped_attributes_count <- Pbrt.Decoder.int32_as_varint d; + end + | Some (5, pk) -> + Pbrt.Decoder.unexpected_payload "Message(span_link), field(5)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Trace_types.trace_id = v.trace_id; + Trace_types.span_id = v.span_id; + Trace_types.trace_state = v.trace_state; + Trace_types.attributes = v.attributes; + Trace_types.dropped_attributes_count = v.dropped_attributes_count; + } : Trace_types.span_link) + +let rec decode_status_status_code d = + match Pbrt.Decoder.int_as_varint d with + | 0 -> (Trace_types.Status_code_unset:Trace_types.status_status_code) + | 1 -> (Trace_types.Status_code_ok:Trace_types.status_status_code) + | 2 -> (Trace_types.Status_code_error:Trace_types.status_status_code) + | _ -> Pbrt.Decoder.malformed_variant "status_status_code" + +let rec decode_status d = + let v = default_status_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + ); continue__ := false + | Some (2, Pbrt.Bytes) -> begin + v.message <- Pbrt.Decoder.string d; + end + | Some (2, pk) -> + Pbrt.Decoder.unexpected_payload "Message(status), field(2)" pk + | Some (3, Pbrt.Varint) -> begin + v.code <- decode_status_status_code d; + end + | Some (3, pk) -> + Pbrt.Decoder.unexpected_payload "Message(status), field(3)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Trace_types.message = v.message; + Trace_types.code = v.code; + } : Trace_types.status) + +let rec decode_span d = + let v = default_span_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.links <- List.rev v.links; + v.events <- List.rev v.events; + v.attributes <- List.rev v.attributes; + ); continue__ := false + | Some (1, Pbrt.Bytes) -> begin + v.trace_id <- Pbrt.Decoder.bytes d; + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(span), field(1)" pk + | Some (2, Pbrt.Bytes) -> begin + v.span_id <- Pbrt.Decoder.bytes d; + end + | Some (2, pk) -> + Pbrt.Decoder.unexpected_payload "Message(span), field(2)" pk + | Some (3, Pbrt.Bytes) -> begin + v.trace_state <- Pbrt.Decoder.string d; + end + | Some (3, pk) -> + Pbrt.Decoder.unexpected_payload "Message(span), field(3)" pk + | Some (4, Pbrt.Bytes) -> begin + v.parent_span_id <- Pbrt.Decoder.bytes d; + end + | Some (4, pk) -> + Pbrt.Decoder.unexpected_payload "Message(span), field(4)" pk + | Some (5, Pbrt.Bytes) -> begin + v.name <- Pbrt.Decoder.string d; + end + | Some (5, pk) -> + Pbrt.Decoder.unexpected_payload "Message(span), field(5)" pk + | Some (6, Pbrt.Varint) -> begin + v.kind <- decode_span_span_kind d; + end + | Some (6, pk) -> + Pbrt.Decoder.unexpected_payload "Message(span), field(6)" pk + | Some (7, Pbrt.Bits64) -> begin + v.start_time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; + end + | Some (7, pk) -> + Pbrt.Decoder.unexpected_payload "Message(span), field(7)" pk + | Some (8, Pbrt.Bits64) -> begin + v.end_time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; + end + | Some (8, pk) -> + Pbrt.Decoder.unexpected_payload "Message(span), field(8)" pk + | Some (9, Pbrt.Bytes) -> begin + v.attributes <- (Common_pb.decode_key_value (Pbrt.Decoder.nested d)) :: v.attributes; + end + | Some (9, pk) -> + Pbrt.Decoder.unexpected_payload "Message(span), field(9)" pk + | Some (10, Pbrt.Varint) -> begin + v.dropped_attributes_count <- Pbrt.Decoder.int32_as_varint d; + end + | Some (10, pk) -> + Pbrt.Decoder.unexpected_payload "Message(span), field(10)" pk + | Some (11, Pbrt.Bytes) -> begin + v.events <- (decode_span_event (Pbrt.Decoder.nested d)) :: v.events; + end + | Some (11, pk) -> + Pbrt.Decoder.unexpected_payload "Message(span), field(11)" pk + | Some (12, Pbrt.Varint) -> begin + v.dropped_events_count <- Pbrt.Decoder.int32_as_varint d; + end + | Some (12, pk) -> + Pbrt.Decoder.unexpected_payload "Message(span), field(12)" pk + | Some (13, Pbrt.Bytes) -> begin + v.links <- (decode_span_link (Pbrt.Decoder.nested d)) :: v.links; + end + | Some (13, pk) -> + Pbrt.Decoder.unexpected_payload "Message(span), field(13)" pk + | Some (14, Pbrt.Varint) -> begin + v.dropped_links_count <- Pbrt.Decoder.int32_as_varint d; + end + | Some (14, pk) -> + Pbrt.Decoder.unexpected_payload "Message(span), field(14)" pk + | Some (15, Pbrt.Bytes) -> begin + v.status <- Some (decode_status (Pbrt.Decoder.nested d)); + end + | Some (15, pk) -> + Pbrt.Decoder.unexpected_payload "Message(span), field(15)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Trace_types.trace_id = v.trace_id; + Trace_types.span_id = v.span_id; + Trace_types.trace_state = v.trace_state; + Trace_types.parent_span_id = v.parent_span_id; + Trace_types.name = v.name; + Trace_types.kind = v.kind; + Trace_types.start_time_unix_nano = v.start_time_unix_nano; + Trace_types.end_time_unix_nano = v.end_time_unix_nano; + Trace_types.attributes = v.attributes; + Trace_types.dropped_attributes_count = v.dropped_attributes_count; + Trace_types.events = v.events; + Trace_types.dropped_events_count = v.dropped_events_count; + Trace_types.links = v.links; + Trace_types.dropped_links_count = v.dropped_links_count; + Trace_types.status = v.status; + } : Trace_types.span) + +let rec decode_scope_spans d = + let v = default_scope_spans_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.spans <- List.rev v.spans; + ); continue__ := false + | Some (1, Pbrt.Bytes) -> begin + v.scope <- Some (Common_pb.decode_instrumentation_scope (Pbrt.Decoder.nested d)); + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(scope_spans), field(1)" pk + | Some (2, Pbrt.Bytes) -> begin + v.spans <- (decode_span (Pbrt.Decoder.nested d)) :: v.spans; + end + | Some (2, pk) -> + Pbrt.Decoder.unexpected_payload "Message(scope_spans), field(2)" pk + | Some (3, Pbrt.Bytes) -> begin + v.schema_url <- Pbrt.Decoder.string d; + end + | Some (3, pk) -> + Pbrt.Decoder.unexpected_payload "Message(scope_spans), field(3)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Trace_types.scope = v.scope; + Trace_types.spans = v.spans; + Trace_types.schema_url = v.schema_url; + } : Trace_types.scope_spans) + +let rec decode_resource_spans d = + let v = default_resource_spans_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.scope_spans <- List.rev v.scope_spans; + ); continue__ := false + | Some (1, Pbrt.Bytes) -> begin + v.resource <- Some (Resource_pb.decode_resource (Pbrt.Decoder.nested d)); + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(resource_spans), field(1)" pk + | Some (2, Pbrt.Bytes) -> begin + v.scope_spans <- (decode_scope_spans (Pbrt.Decoder.nested d)) :: v.scope_spans; + end + | Some (2, pk) -> + Pbrt.Decoder.unexpected_payload "Message(resource_spans), field(2)" pk + | Some (3, Pbrt.Bytes) -> begin + v.schema_url <- Pbrt.Decoder.string d; + end + | Some (3, pk) -> + Pbrt.Decoder.unexpected_payload "Message(resource_spans), field(3)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Trace_types.resource = v.resource; + Trace_types.scope_spans = v.scope_spans; + Trace_types.schema_url = v.schema_url; + } : Trace_types.resource_spans) + +let rec decode_traces_data d = + let v = default_traces_data_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.resource_spans <- List.rev v.resource_spans; + ); continue__ := false + | Some (1, Pbrt.Bytes) -> begin + v.resource_spans <- (decode_resource_spans (Pbrt.Decoder.nested d)) :: v.resource_spans; + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(traces_data), field(1)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Trace_types.resource_spans = v.resource_spans; + } : Trace_types.traces_data) + +let rec encode_span_span_kind (v:Trace_types.span_span_kind) encoder = + match v with + | Trace_types.Span_kind_unspecified -> Pbrt.Encoder.int_as_varint (0) encoder + | Trace_types.Span_kind_internal -> Pbrt.Encoder.int_as_varint 1 encoder + | Trace_types.Span_kind_server -> Pbrt.Encoder.int_as_varint 2 encoder + | Trace_types.Span_kind_client -> Pbrt.Encoder.int_as_varint 3 encoder + | Trace_types.Span_kind_producer -> Pbrt.Encoder.int_as_varint 4 encoder + | Trace_types.Span_kind_consumer -> Pbrt.Encoder.int_as_varint 5 encoder + +let rec encode_span_event (v:Trace_types.span_event) encoder = + Pbrt.Encoder.key (1, Pbrt.Bits64) encoder; + Pbrt.Encoder.int64_as_bits64 v.Trace_types.time_unix_nano encoder; + Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; + Pbrt.Encoder.string v.Trace_types.name encoder; + List.iter (fun x -> + Pbrt.Encoder.key (3, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (Common_pb.encode_key_value x) encoder; + ) v.Trace_types.attributes; + Pbrt.Encoder.key (4, Pbrt.Varint) encoder; + Pbrt.Encoder.int32_as_varint v.Trace_types.dropped_attributes_count encoder; + () + +let rec encode_span_link (v:Trace_types.span_link) encoder = + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.bytes v.Trace_types.trace_id encoder; + Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; + Pbrt.Encoder.bytes v.Trace_types.span_id encoder; + Pbrt.Encoder.key (3, Pbrt.Bytes) encoder; + Pbrt.Encoder.string v.Trace_types.trace_state encoder; + List.iter (fun x -> + Pbrt.Encoder.key (4, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (Common_pb.encode_key_value x) encoder; + ) v.Trace_types.attributes; + Pbrt.Encoder.key (5, Pbrt.Varint) encoder; + Pbrt.Encoder.int32_as_varint v.Trace_types.dropped_attributes_count encoder; + () + +let rec encode_status_status_code (v:Trace_types.status_status_code) encoder = + match v with + | Trace_types.Status_code_unset -> Pbrt.Encoder.int_as_varint (0) encoder + | Trace_types.Status_code_ok -> Pbrt.Encoder.int_as_varint 1 encoder + | Trace_types.Status_code_error -> Pbrt.Encoder.int_as_varint 2 encoder + +let rec encode_status (v:Trace_types.status) encoder = + Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; + Pbrt.Encoder.string v.Trace_types.message encoder; + Pbrt.Encoder.key (3, Pbrt.Varint) encoder; + encode_status_status_code v.Trace_types.code encoder; + () + +let rec encode_span (v:Trace_types.span) encoder = + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.bytes v.Trace_types.trace_id encoder; + Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; + Pbrt.Encoder.bytes v.Trace_types.span_id encoder; + Pbrt.Encoder.key (3, Pbrt.Bytes) encoder; + Pbrt.Encoder.string v.Trace_types.trace_state encoder; + Pbrt.Encoder.key (4, Pbrt.Bytes) encoder; + Pbrt.Encoder.bytes v.Trace_types.parent_span_id encoder; + Pbrt.Encoder.key (5, Pbrt.Bytes) encoder; + Pbrt.Encoder.string v.Trace_types.name encoder; + Pbrt.Encoder.key (6, Pbrt.Varint) encoder; + encode_span_span_kind v.Trace_types.kind encoder; + Pbrt.Encoder.key (7, Pbrt.Bits64) encoder; + Pbrt.Encoder.int64_as_bits64 v.Trace_types.start_time_unix_nano encoder; + Pbrt.Encoder.key (8, Pbrt.Bits64) encoder; + Pbrt.Encoder.int64_as_bits64 v.Trace_types.end_time_unix_nano encoder; + List.iter (fun x -> + Pbrt.Encoder.key (9, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (Common_pb.encode_key_value x) encoder; + ) v.Trace_types.attributes; + Pbrt.Encoder.key (10, Pbrt.Varint) encoder; + Pbrt.Encoder.int32_as_varint v.Trace_types.dropped_attributes_count encoder; + List.iter (fun x -> + Pbrt.Encoder.key (11, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_span_event x) encoder; + ) v.Trace_types.events; + Pbrt.Encoder.key (12, Pbrt.Varint) encoder; + Pbrt.Encoder.int32_as_varint v.Trace_types.dropped_events_count encoder; + List.iter (fun x -> + Pbrt.Encoder.key (13, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_span_link x) encoder; + ) v.Trace_types.links; + Pbrt.Encoder.key (14, Pbrt.Varint) encoder; + Pbrt.Encoder.int32_as_varint v.Trace_types.dropped_links_count encoder; + begin match v.Trace_types.status with + | Some x -> + Pbrt.Encoder.key (15, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_status x) encoder; + | None -> (); + end; + () + +let rec encode_scope_spans (v:Trace_types.scope_spans) encoder = + begin match v.Trace_types.scope with + | Some x -> + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (Common_pb.encode_instrumentation_scope x) encoder; + | None -> (); + end; + List.iter (fun x -> + Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_span x) encoder; + ) v.Trace_types.spans; + Pbrt.Encoder.key (3, Pbrt.Bytes) encoder; + Pbrt.Encoder.string v.Trace_types.schema_url encoder; + () + +let rec encode_resource_spans (v:Trace_types.resource_spans) encoder = + begin match v.Trace_types.resource with + | Some x -> + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (Resource_pb.encode_resource x) encoder; + | None -> (); + end; + List.iter (fun x -> + Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_scope_spans x) encoder; + ) v.Trace_types.scope_spans; + Pbrt.Encoder.key (3, Pbrt.Bytes) encoder; + Pbrt.Encoder.string v.Trace_types.schema_url encoder; + () + +let rec encode_traces_data (v:Trace_types.traces_data) encoder = + List.iter (fun x -> + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_resource_spans x) encoder; + ) v.Trace_types.resource_spans; + () diff --git a/src/proto/trace_pb.mli b/src/proto/trace_pb.mli new file mode 100644 index 00000000..8e93dba6 --- /dev/null +++ b/src/proto/trace_pb.mli @@ -0,0 +1,61 @@ +(** trace.proto Binary Encoding *) + + +(** {2 Protobuf Encoding} *) + +val encode_span_span_kind : Trace_types.span_span_kind -> Pbrt.Encoder.t -> unit +(** [encode_span_span_kind v encoder] encodes [v] with the given [encoder] *) + +val encode_span_event : Trace_types.span_event -> Pbrt.Encoder.t -> unit +(** [encode_span_event v encoder] encodes [v] with the given [encoder] *) + +val encode_span_link : Trace_types.span_link -> Pbrt.Encoder.t -> unit +(** [encode_span_link v encoder] encodes [v] with the given [encoder] *) + +val encode_status_status_code : Trace_types.status_status_code -> Pbrt.Encoder.t -> unit +(** [encode_status_status_code v encoder] encodes [v] with the given [encoder] *) + +val encode_status : Trace_types.status -> Pbrt.Encoder.t -> unit +(** [encode_status v encoder] encodes [v] with the given [encoder] *) + +val encode_span : Trace_types.span -> Pbrt.Encoder.t -> unit +(** [encode_span v encoder] encodes [v] with the given [encoder] *) + +val encode_scope_spans : Trace_types.scope_spans -> Pbrt.Encoder.t -> unit +(** [encode_scope_spans v encoder] encodes [v] with the given [encoder] *) + +val encode_resource_spans : Trace_types.resource_spans -> Pbrt.Encoder.t -> unit +(** [encode_resource_spans v encoder] encodes [v] with the given [encoder] *) + +val encode_traces_data : Trace_types.traces_data -> Pbrt.Encoder.t -> unit +(** [encode_traces_data v encoder] encodes [v] with the given [encoder] *) + + +(** {2 Protobuf Decoding} *) + +val decode_span_span_kind : Pbrt.Decoder.t -> Trace_types.span_span_kind +(** [decode_span_span_kind decoder] decodes a [span_span_kind] value from [decoder] *) + +val decode_span_event : Pbrt.Decoder.t -> Trace_types.span_event +(** [decode_span_event decoder] decodes a [span_event] value from [decoder] *) + +val decode_span_link : Pbrt.Decoder.t -> Trace_types.span_link +(** [decode_span_link decoder] decodes a [span_link] value from [decoder] *) + +val decode_status_status_code : Pbrt.Decoder.t -> Trace_types.status_status_code +(** [decode_status_status_code decoder] decodes a [status_status_code] value from [decoder] *) + +val decode_status : Pbrt.Decoder.t -> Trace_types.status +(** [decode_status decoder] decodes a [status] value from [decoder] *) + +val decode_span : Pbrt.Decoder.t -> Trace_types.span +(** [decode_span decoder] decodes a [span] value from [decoder] *) + +val decode_scope_spans : Pbrt.Decoder.t -> Trace_types.scope_spans +(** [decode_scope_spans decoder] decodes a [scope_spans] value from [decoder] *) + +val decode_resource_spans : Pbrt.Decoder.t -> Trace_types.resource_spans +(** [decode_resource_spans decoder] decodes a [resource_spans] value from [decoder] *) + +val decode_traces_data : Pbrt.Decoder.t -> Trace_types.traces_data +(** [decode_traces_data decoder] decodes a [traces_data] value from [decoder] *) diff --git a/src/proto/trace_pp.ml b/src/proto/trace_pp.ml new file mode 100644 index 00000000..97faa78b --- /dev/null +++ b/src/proto/trace_pp.ml @@ -0,0 +1,84 @@ +[@@@ocaml.warning "-27-30-39"] + +let rec pp_span_span_kind fmt (v:Trace_types.span_span_kind) = + match v with + | Trace_types.Span_kind_unspecified -> Format.fprintf fmt "Span_kind_unspecified" + | Trace_types.Span_kind_internal -> Format.fprintf fmt "Span_kind_internal" + | Trace_types.Span_kind_server -> Format.fprintf fmt "Span_kind_server" + | Trace_types.Span_kind_client -> Format.fprintf fmt "Span_kind_client" + | Trace_types.Span_kind_producer -> Format.fprintf fmt "Span_kind_producer" + | Trace_types.Span_kind_consumer -> Format.fprintf fmt "Span_kind_consumer" + +let rec pp_span_event fmt (v:Trace_types.span_event) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Trace_types.time_unix_nano; + Pbrt.Pp.pp_record_field ~first:false "name" Pbrt.Pp.pp_string fmt v.Trace_types.name; + Pbrt.Pp.pp_record_field ~first:false "attributes" (Pbrt.Pp.pp_list Common_pp.pp_key_value) fmt v.Trace_types.attributes; + Pbrt.Pp.pp_record_field ~first:false "dropped_attributes_count" Pbrt.Pp.pp_int32 fmt v.Trace_types.dropped_attributes_count; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_span_link fmt (v:Trace_types.span_link) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "trace_id" Pbrt.Pp.pp_bytes fmt v.Trace_types.trace_id; + Pbrt.Pp.pp_record_field ~first:false "span_id" Pbrt.Pp.pp_bytes fmt v.Trace_types.span_id; + Pbrt.Pp.pp_record_field ~first:false "trace_state" Pbrt.Pp.pp_string fmt v.Trace_types.trace_state; + Pbrt.Pp.pp_record_field ~first:false "attributes" (Pbrt.Pp.pp_list Common_pp.pp_key_value) fmt v.Trace_types.attributes; + Pbrt.Pp.pp_record_field ~first:false "dropped_attributes_count" Pbrt.Pp.pp_int32 fmt v.Trace_types.dropped_attributes_count; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_status_status_code fmt (v:Trace_types.status_status_code) = + match v with + | Trace_types.Status_code_unset -> Format.fprintf fmt "Status_code_unset" + | Trace_types.Status_code_ok -> Format.fprintf fmt "Status_code_ok" + | Trace_types.Status_code_error -> Format.fprintf fmt "Status_code_error" + +let rec pp_status fmt (v:Trace_types.status) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "message" Pbrt.Pp.pp_string fmt v.Trace_types.message; + Pbrt.Pp.pp_record_field ~first:false "code" pp_status_status_code fmt v.Trace_types.code; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_span fmt (v:Trace_types.span) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "trace_id" Pbrt.Pp.pp_bytes fmt v.Trace_types.trace_id; + Pbrt.Pp.pp_record_field ~first:false "span_id" Pbrt.Pp.pp_bytes fmt v.Trace_types.span_id; + Pbrt.Pp.pp_record_field ~first:false "trace_state" Pbrt.Pp.pp_string fmt v.Trace_types.trace_state; + Pbrt.Pp.pp_record_field ~first:false "parent_span_id" Pbrt.Pp.pp_bytes fmt v.Trace_types.parent_span_id; + Pbrt.Pp.pp_record_field ~first:false "name" Pbrt.Pp.pp_string fmt v.Trace_types.name; + Pbrt.Pp.pp_record_field ~first:false "kind" pp_span_span_kind fmt v.Trace_types.kind; + Pbrt.Pp.pp_record_field ~first:false "start_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Trace_types.start_time_unix_nano; + Pbrt.Pp.pp_record_field ~first:false "end_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Trace_types.end_time_unix_nano; + Pbrt.Pp.pp_record_field ~first:false "attributes" (Pbrt.Pp.pp_list Common_pp.pp_key_value) fmt v.Trace_types.attributes; + Pbrt.Pp.pp_record_field ~first:false "dropped_attributes_count" Pbrt.Pp.pp_int32 fmt v.Trace_types.dropped_attributes_count; + Pbrt.Pp.pp_record_field ~first:false "events" (Pbrt.Pp.pp_list pp_span_event) fmt v.Trace_types.events; + Pbrt.Pp.pp_record_field ~first:false "dropped_events_count" Pbrt.Pp.pp_int32 fmt v.Trace_types.dropped_events_count; + Pbrt.Pp.pp_record_field ~first:false "links" (Pbrt.Pp.pp_list pp_span_link) fmt v.Trace_types.links; + Pbrt.Pp.pp_record_field ~first:false "dropped_links_count" Pbrt.Pp.pp_int32 fmt v.Trace_types.dropped_links_count; + Pbrt.Pp.pp_record_field ~first:false "status" (Pbrt.Pp.pp_option pp_status) fmt v.Trace_types.status; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_scope_spans fmt (v:Trace_types.scope_spans) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "scope" (Pbrt.Pp.pp_option Common_pp.pp_instrumentation_scope) fmt v.Trace_types.scope; + Pbrt.Pp.pp_record_field ~first:false "spans" (Pbrt.Pp.pp_list pp_span) fmt v.Trace_types.spans; + Pbrt.Pp.pp_record_field ~first:false "schema_url" Pbrt.Pp.pp_string fmt v.Trace_types.schema_url; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_resource_spans fmt (v:Trace_types.resource_spans) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "resource" (Pbrt.Pp.pp_option Resource_pp.pp_resource) fmt v.Trace_types.resource; + Pbrt.Pp.pp_record_field ~first:false "scope_spans" (Pbrt.Pp.pp_list pp_scope_spans) fmt v.Trace_types.scope_spans; + Pbrt.Pp.pp_record_field ~first:false "schema_url" Pbrt.Pp.pp_string fmt v.Trace_types.schema_url; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_traces_data fmt (v:Trace_types.traces_data) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "resource_spans" (Pbrt.Pp.pp_list pp_resource_spans) fmt v.Trace_types.resource_spans; + in + Pbrt.Pp.pp_brk pp_i fmt () diff --git a/src/proto/trace_pp.mli b/src/proto/trace_pp.mli new file mode 100644 index 00000000..ea7ffdc9 --- /dev/null +++ b/src/proto/trace_pp.mli @@ -0,0 +1,32 @@ + +(** trace.proto Pretty Printing *) + + +(** {2 Formatters} *) + +val pp_span_span_kind : Format.formatter -> Trace_types.span_span_kind -> unit +(** [pp_span_span_kind v] formats v *) + +val pp_span_event : Format.formatter -> Trace_types.span_event -> unit +(** [pp_span_event v] formats v *) + +val pp_span_link : Format.formatter -> Trace_types.span_link -> unit +(** [pp_span_link v] formats v *) + +val pp_status_status_code : Format.formatter -> Trace_types.status_status_code -> unit +(** [pp_status_status_code v] formats v *) + +val pp_status : Format.formatter -> Trace_types.status -> unit +(** [pp_status v] formats v *) + +val pp_span : Format.formatter -> Trace_types.span -> unit +(** [pp_span v] formats v *) + +val pp_scope_spans : Format.formatter -> Trace_types.scope_spans -> unit +(** [pp_scope_spans v] formats v *) + +val pp_resource_spans : Format.formatter -> Trace_types.resource_spans -> unit +(** [pp_resource_spans v] formats v *) + +val pp_traces_data : Format.formatter -> Trace_types.traces_data -> unit +(** [pp_traces_data v] formats v *) diff --git a/src/proto/trace_service_pb.ml b/src/proto/trace_service_pb.ml new file mode 100644 index 00000000..68733bcf --- /dev/null +++ b/src/proto/trace_service_pb.ml @@ -0,0 +1,112 @@ +[@@@ocaml.warning "-27-30-39"] + +type export_trace_service_request_mutable = { + mutable resource_spans : Trace_types.resource_spans list; +} + +let default_export_trace_service_request_mutable () : export_trace_service_request_mutable = { + resource_spans = []; +} + +type export_trace_partial_success_mutable = { + mutable rejected_spans : int64; + mutable error_message : string; +} + +let default_export_trace_partial_success_mutable () : export_trace_partial_success_mutable = { + rejected_spans = 0L; + error_message = ""; +} + +type export_trace_service_response_mutable = { + mutable partial_success : Trace_service_types.export_trace_partial_success option; +} + +let default_export_trace_service_response_mutable () : export_trace_service_response_mutable = { + partial_success = None; +} + + +let rec decode_export_trace_service_request d = + let v = default_export_trace_service_request_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.resource_spans <- List.rev v.resource_spans; + ); continue__ := false + | Some (1, Pbrt.Bytes) -> begin + v.resource_spans <- (Trace_pb.decode_resource_spans (Pbrt.Decoder.nested d)) :: v.resource_spans; + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(export_trace_service_request), field(1)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Trace_service_types.resource_spans = v.resource_spans; + } : Trace_service_types.export_trace_service_request) + +let rec decode_export_trace_partial_success d = + let v = default_export_trace_partial_success_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + ); continue__ := false + | Some (1, Pbrt.Varint) -> begin + v.rejected_spans <- Pbrt.Decoder.int64_as_varint d; + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(export_trace_partial_success), field(1)" pk + | Some (2, Pbrt.Bytes) -> begin + v.error_message <- Pbrt.Decoder.string d; + end + | Some (2, pk) -> + Pbrt.Decoder.unexpected_payload "Message(export_trace_partial_success), field(2)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Trace_service_types.rejected_spans = v.rejected_spans; + Trace_service_types.error_message = v.error_message; + } : Trace_service_types.export_trace_partial_success) + +let rec decode_export_trace_service_response d = + let v = default_export_trace_service_response_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + ); continue__ := false + | Some (1, Pbrt.Bytes) -> begin + v.partial_success <- Some (decode_export_trace_partial_success (Pbrt.Decoder.nested d)); + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(export_trace_service_response), field(1)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Trace_service_types.partial_success = v.partial_success; + } : Trace_service_types.export_trace_service_response) + +let rec encode_export_trace_service_request (v:Trace_service_types.export_trace_service_request) encoder = + List.iter (fun x -> + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (Trace_pb.encode_resource_spans x) encoder; + ) v.Trace_service_types.resource_spans; + () + +let rec encode_export_trace_partial_success (v:Trace_service_types.export_trace_partial_success) encoder = + Pbrt.Encoder.key (1, Pbrt.Varint) encoder; + Pbrt.Encoder.int64_as_varint v.Trace_service_types.rejected_spans encoder; + Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; + Pbrt.Encoder.string v.Trace_service_types.error_message encoder; + () + +let rec encode_export_trace_service_response (v:Trace_service_types.export_trace_service_response) encoder = + begin match v.Trace_service_types.partial_success with + | Some x -> + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_export_trace_partial_success x) encoder; + | None -> (); + end; + () diff --git a/src/proto/trace_service_pb.mli b/src/proto/trace_service_pb.mli new file mode 100644 index 00000000..afd94a31 --- /dev/null +++ b/src/proto/trace_service_pb.mli @@ -0,0 +1,25 @@ +(** trace_service.proto Binary Encoding *) + + +(** {2 Protobuf Encoding} *) + +val encode_export_trace_service_request : Trace_service_types.export_trace_service_request -> Pbrt.Encoder.t -> unit +(** [encode_export_trace_service_request v encoder] encodes [v] with the given [encoder] *) + +val encode_export_trace_partial_success : Trace_service_types.export_trace_partial_success -> Pbrt.Encoder.t -> unit +(** [encode_export_trace_partial_success v encoder] encodes [v] with the given [encoder] *) + +val encode_export_trace_service_response : Trace_service_types.export_trace_service_response -> Pbrt.Encoder.t -> unit +(** [encode_export_trace_service_response v encoder] encodes [v] with the given [encoder] *) + + +(** {2 Protobuf Decoding} *) + +val decode_export_trace_service_request : Pbrt.Decoder.t -> Trace_service_types.export_trace_service_request +(** [decode_export_trace_service_request decoder] decodes a [export_trace_service_request] value from [decoder] *) + +val decode_export_trace_partial_success : Pbrt.Decoder.t -> Trace_service_types.export_trace_partial_success +(** [decode_export_trace_partial_success decoder] decodes a [export_trace_partial_success] value from [decoder] *) + +val decode_export_trace_service_response : Pbrt.Decoder.t -> Trace_service_types.export_trace_service_response +(** [decode_export_trace_service_response decoder] decodes a [export_trace_service_response] value from [decoder] *) diff --git a/src/proto/trace_service_pp.ml b/src/proto/trace_service_pp.ml new file mode 100644 index 00000000..edc069f2 --- /dev/null +++ b/src/proto/trace_service_pp.ml @@ -0,0 +1,20 @@ +[@@@ocaml.warning "-27-30-39"] + +let rec pp_export_trace_service_request fmt (v:Trace_service_types.export_trace_service_request) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "resource_spans" (Pbrt.Pp.pp_list Trace_pp.pp_resource_spans) fmt v.Trace_service_types.resource_spans; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_export_trace_partial_success fmt (v:Trace_service_types.export_trace_partial_success) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "rejected_spans" Pbrt.Pp.pp_int64 fmt v.Trace_service_types.rejected_spans; + Pbrt.Pp.pp_record_field ~first:false "error_message" Pbrt.Pp.pp_string fmt v.Trace_service_types.error_message; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_export_trace_service_response fmt (v:Trace_service_types.export_trace_service_response) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "partial_success" (Pbrt.Pp.pp_option pp_export_trace_partial_success) fmt v.Trace_service_types.partial_success; + in + Pbrt.Pp.pp_brk pp_i fmt () diff --git a/src/proto/trace_service_pp.mli b/src/proto/trace_service_pp.mli new file mode 100644 index 00000000..63b19223 --- /dev/null +++ b/src/proto/trace_service_pp.mli @@ -0,0 +1,14 @@ + +(** trace_service.proto Pretty Printing *) + + +(** {2 Formatters} *) + +val pp_export_trace_service_request : Format.formatter -> Trace_service_types.export_trace_service_request -> unit +(** [pp_export_trace_service_request v] formats v *) + +val pp_export_trace_partial_success : Format.formatter -> Trace_service_types.export_trace_partial_success -> unit +(** [pp_export_trace_partial_success v] formats v *) + +val pp_export_trace_service_response : Format.formatter -> Trace_service_types.export_trace_service_response -> unit +(** [pp_export_trace_service_response v] formats v *) diff --git a/src/proto/trace_service_types.ml b/src/proto/trace_service_types.ml new file mode 100644 index 00000000..6476d53c --- /dev/null +++ b/src/proto/trace_service_types.ml @@ -0,0 +1,35 @@ +[@@@ocaml.warning "-27-30-39"] + + +type export_trace_service_request = { + resource_spans : Trace_types.resource_spans list; +} + +type export_trace_partial_success = { + rejected_spans : int64; + error_message : string; +} + +type export_trace_service_response = { + partial_success : export_trace_partial_success option; +} + +let rec default_export_trace_service_request + ?resource_spans:((resource_spans:Trace_types.resource_spans list) = []) + () : export_trace_service_request = { + resource_spans; +} + +let rec default_export_trace_partial_success + ?rejected_spans:((rejected_spans:int64) = 0L) + ?error_message:((error_message:string) = "") + () : export_trace_partial_success = { + rejected_spans; + error_message; +} + +let rec default_export_trace_service_response + ?partial_success:((partial_success:export_trace_partial_success option) = None) + () : export_trace_service_response = { + partial_success; +} diff --git a/src/proto/trace_service_types.mli b/src/proto/trace_service_types.mli new file mode 100644 index 00000000..e7480e77 --- /dev/null +++ b/src/proto/trace_service_types.mli @@ -0,0 +1,40 @@ +(** trace_service.proto Types *) + + + +(** {2 Types} *) + +type export_trace_service_request = { + resource_spans : Trace_types.resource_spans list; +} + +type export_trace_partial_success = { + rejected_spans : int64; + error_message : string; +} + +type export_trace_service_response = { + partial_success : export_trace_partial_success option; +} + + +(** {2 Default values} *) + +val default_export_trace_service_request : + ?resource_spans:Trace_types.resource_spans list -> + unit -> + export_trace_service_request +(** [default_export_trace_service_request ()] is the default value for type [export_trace_service_request] *) + +val default_export_trace_partial_success : + ?rejected_spans:int64 -> + ?error_message:string -> + unit -> + export_trace_partial_success +(** [default_export_trace_partial_success ()] is the default value for type [export_trace_partial_success] *) + +val default_export_trace_service_response : + ?partial_success:export_trace_partial_success option -> + unit -> + export_trace_service_response +(** [default_export_trace_service_response ()] is the default value for type [export_trace_service_response] *) diff --git a/src/proto/trace_types.ml b/src/proto/trace_types.ml new file mode 100644 index 00000000..3e51df35 --- /dev/null +++ b/src/proto/trace_types.ml @@ -0,0 +1,167 @@ +[@@@ocaml.warning "-27-30-39"] + + +type span_span_kind = + | Span_kind_unspecified + | Span_kind_internal + | Span_kind_server + | Span_kind_client + | Span_kind_producer + | Span_kind_consumer + +type span_event = { + time_unix_nano : int64; + name : string; + attributes : Common_types.key_value list; + dropped_attributes_count : int32; +} + +type span_link = { + trace_id : bytes; + span_id : bytes; + trace_state : string; + attributes : Common_types.key_value list; + dropped_attributes_count : int32; +} + +type status_status_code = + | Status_code_unset + | Status_code_ok + | Status_code_error + +type status = { + message : string; + code : status_status_code; +} + +type span = { + trace_id : bytes; + span_id : bytes; + trace_state : string; + parent_span_id : bytes; + name : string; + kind : span_span_kind; + start_time_unix_nano : int64; + end_time_unix_nano : int64; + attributes : Common_types.key_value list; + dropped_attributes_count : int32; + events : span_event list; + dropped_events_count : int32; + links : span_link list; + dropped_links_count : int32; + status : status option; +} + +type scope_spans = { + scope : Common_types.instrumentation_scope option; + spans : span list; + schema_url : string; +} + +type resource_spans = { + resource : Resource_types.resource option; + scope_spans : scope_spans list; + schema_url : string; +} + +type traces_data = { + resource_spans : resource_spans list; +} + +let rec default_span_span_kind () = (Span_kind_unspecified:span_span_kind) + +let rec default_span_event + ?time_unix_nano:((time_unix_nano:int64) = 0L) + ?name:((name:string) = "") + ?attributes:((attributes:Common_types.key_value list) = []) + ?dropped_attributes_count:((dropped_attributes_count:int32) = 0l) + () : span_event = { + time_unix_nano; + name; + attributes; + dropped_attributes_count; +} + +let rec default_span_link + ?trace_id:((trace_id:bytes) = Bytes.create 0) + ?span_id:((span_id:bytes) = Bytes.create 0) + ?trace_state:((trace_state:string) = "") + ?attributes:((attributes:Common_types.key_value list) = []) + ?dropped_attributes_count:((dropped_attributes_count:int32) = 0l) + () : span_link = { + trace_id; + span_id; + trace_state; + attributes; + dropped_attributes_count; +} + +let rec default_status_status_code () = (Status_code_unset:status_status_code) + +let rec default_status + ?message:((message:string) = "") + ?code:((code:status_status_code) = default_status_status_code ()) + () : status = { + message; + code; +} + +let rec default_span + ?trace_id:((trace_id:bytes) = Bytes.create 0) + ?span_id:((span_id:bytes) = Bytes.create 0) + ?trace_state:((trace_state:string) = "") + ?parent_span_id:((parent_span_id:bytes) = Bytes.create 0) + ?name:((name:string) = "") + ?kind:((kind:span_span_kind) = default_span_span_kind ()) + ?start_time_unix_nano:((start_time_unix_nano:int64) = 0L) + ?end_time_unix_nano:((end_time_unix_nano:int64) = 0L) + ?attributes:((attributes:Common_types.key_value list) = []) + ?dropped_attributes_count:((dropped_attributes_count:int32) = 0l) + ?events:((events:span_event list) = []) + ?dropped_events_count:((dropped_events_count:int32) = 0l) + ?links:((links:span_link list) = []) + ?dropped_links_count:((dropped_links_count:int32) = 0l) + ?status:((status:status option) = None) + () : span = { + trace_id; + span_id; + trace_state; + parent_span_id; + name; + kind; + start_time_unix_nano; + end_time_unix_nano; + attributes; + dropped_attributes_count; + events; + dropped_events_count; + links; + dropped_links_count; + status; +} + +let rec default_scope_spans + ?scope:((scope:Common_types.instrumentation_scope option) = None) + ?spans:((spans:span list) = []) + ?schema_url:((schema_url:string) = "") + () : scope_spans = { + scope; + spans; + schema_url; +} + +let rec default_resource_spans + ?resource:((resource:Resource_types.resource option) = None) + ?scope_spans:((scope_spans:scope_spans list) = []) + ?schema_url:((schema_url:string) = "") + () : resource_spans = { + resource; + scope_spans; + schema_url; +} + +let rec default_traces_data + ?resource_spans:((resource_spans:resource_spans list) = []) + () : traces_data = { + resource_spans; +} diff --git a/src/proto/trace_types.mli b/src/proto/trace_types.mli new file mode 100644 index 00000000..ef7ac6dc --- /dev/null +++ b/src/proto/trace_types.mli @@ -0,0 +1,149 @@ +(** trace.proto Types *) + + + +(** {2 Types} *) + +type span_span_kind = + | Span_kind_unspecified + | Span_kind_internal + | Span_kind_server + | Span_kind_client + | Span_kind_producer + | Span_kind_consumer + +type span_event = { + time_unix_nano : int64; + name : string; + attributes : Common_types.key_value list; + dropped_attributes_count : int32; +} + +type span_link = { + trace_id : bytes; + span_id : bytes; + trace_state : string; + attributes : Common_types.key_value list; + dropped_attributes_count : int32; +} + +type status_status_code = + | Status_code_unset + | Status_code_ok + | Status_code_error + +type status = { + message : string; + code : status_status_code; +} + +type span = { + trace_id : bytes; + span_id : bytes; + trace_state : string; + parent_span_id : bytes; + name : string; + kind : span_span_kind; + start_time_unix_nano : int64; + end_time_unix_nano : int64; + attributes : Common_types.key_value list; + dropped_attributes_count : int32; + events : span_event list; + dropped_events_count : int32; + links : span_link list; + dropped_links_count : int32; + status : status option; +} + +type scope_spans = { + scope : Common_types.instrumentation_scope option; + spans : span list; + schema_url : string; +} + +type resource_spans = { + resource : Resource_types.resource option; + scope_spans : scope_spans list; + schema_url : string; +} + +type traces_data = { + resource_spans : resource_spans list; +} + + +(** {2 Default values} *) + +val default_span_span_kind : unit -> span_span_kind +(** [default_span_span_kind ()] is the default value for type [span_span_kind] *) + +val default_span_event : + ?time_unix_nano:int64 -> + ?name:string -> + ?attributes:Common_types.key_value list -> + ?dropped_attributes_count:int32 -> + unit -> + span_event +(** [default_span_event ()] is the default value for type [span_event] *) + +val default_span_link : + ?trace_id:bytes -> + ?span_id:bytes -> + ?trace_state:string -> + ?attributes:Common_types.key_value list -> + ?dropped_attributes_count:int32 -> + unit -> + span_link +(** [default_span_link ()] is the default value for type [span_link] *) + +val default_status_status_code : unit -> status_status_code +(** [default_status_status_code ()] is the default value for type [status_status_code] *) + +val default_status : + ?message:string -> + ?code:status_status_code -> + unit -> + status +(** [default_status ()] is the default value for type [status] *) + +val default_span : + ?trace_id:bytes -> + ?span_id:bytes -> + ?trace_state:string -> + ?parent_span_id:bytes -> + ?name:string -> + ?kind:span_span_kind -> + ?start_time_unix_nano:int64 -> + ?end_time_unix_nano:int64 -> + ?attributes:Common_types.key_value list -> + ?dropped_attributes_count:int32 -> + ?events:span_event list -> + ?dropped_events_count:int32 -> + ?links:span_link list -> + ?dropped_links_count:int32 -> + ?status:status option -> + unit -> + span +(** [default_span ()] is the default value for type [span] *) + +val default_scope_spans : + ?scope:Common_types.instrumentation_scope option -> + ?spans:span list -> + ?schema_url:string -> + unit -> + scope_spans +(** [default_scope_spans ()] is the default value for type [scope_spans] *) + +val default_resource_spans : + ?resource:Resource_types.resource option -> + ?scope_spans:scope_spans list -> + ?schema_url:string -> + unit -> + resource_spans +(** [default_resource_spans ()] is the default value for type [resource_spans] *) + +val default_traces_data : + ?resource_spans:resource_spans list -> + unit -> + traces_data +(** [default_traces_data ()] is the default value for type [traces_data] *) From 16b385985608ada3f71406be573ff2aaae5512c5 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Wed, 8 Nov 2023 12:01:32 -0500 Subject: [PATCH 5/9] ocamlformat --- src/proto/.ocamlformat-ignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/proto/.ocamlformat-ignore diff --git a/src/proto/.ocamlformat-ignore b/src/proto/.ocamlformat-ignore new file mode 100644 index 00000000..72e8ffc0 --- /dev/null +++ b/src/proto/.ocamlformat-ignore @@ -0,0 +1 @@ +* From 65e9af609174469b5beb53846c546d327a7e2488 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Wed, 8 Nov 2023 12:01:50 -0500 Subject: [PATCH 6/9] format --- src/proto/dune | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/proto/dune b/src/proto/dune index a87df75d..b786b70e 100644 --- a/src/proto/dune +++ b/src/proto/dune @@ -1,4 +1,3 @@ - (library (name opentelemetry_proto) (public_name opentelemetry.proto) @@ -123,4 +122,3 @@ (action (run ocaml-protoc %{file} -I %{project_root}/vendor/opentelemetry-proto/ -ml_out . -pp -binary))) - From 705d541c3f5371b5c85f99fa90b6b3792cf45266 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Wed, 8 Nov 2023 12:11:32 -0500 Subject: [PATCH 7/9] chore: use protoc 2.4 in CI --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ff924cff..bed4addf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,7 +40,7 @@ jobs: - run: opam exec -- dune build @install -p opentelemetry,opentelemetry-lwt,opentelemetry-client-ocurl,opentelemetry-cohttp-lwt,opentelemetry-client-cohttp-lwt - - run: opam pin ocaml-protoc 2.3 -y + - run: opam pin ocaml-protoc 2.4 -y - run: opam exec -- dune build @lint From 9c096411a2bd2144c6f3af34193ee865d74fb885 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Tue, 14 Nov 2023 22:42:39 -0500 Subject: [PATCH 8/9] debug git diff --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bed4addf..47f93677 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -45,7 +45,7 @@ jobs: - run: opam exec -- dune build @lint # check that nothing changed - - run: git diff --quiet --exit-code + - run: git diff --exit-code - run: opam exec -- dune build @runtest if: ${{ matrix.os == 'ubuntu-latest' }} From 794527ebbdab69b3f2b9d4cfcc7300446c0e7aa1 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Tue, 14 Nov 2023 23:43:20 -0500 Subject: [PATCH 9/9] fix: regenerate code with a non-pinned ocaml-protoc --- src/proto/common_pb.ml | 116 ++-- src/proto/common_pb.mli | 12 +- src/proto/common_pp.ml | 24 +- src/proto/common_pp.mli | 7 +- src/proto/common_types.ml | 34 +- src/proto/common_types.mli | 32 +- src/proto/logs_pp.mli | 1 - src/proto/logs_service_pp.mli | 1 - src/proto/metrics_pb.ml | 1028 +++++++++++++++--------------- src/proto/metrics_pb.mli | 96 +-- src/proto/metrics_pp.ml | 124 ++-- src/proto/metrics_pp.mli | 49 +- src/proto/metrics_service_pp.mli | 1 - src/proto/metrics_types.ml | 274 ++++---- src/proto/metrics_types.mli | 236 +++---- src/proto/resource_pp.mli | 1 - src/proto/status_pp.mli | 1 - src/proto/trace_pp.mli | 1 - src/proto/trace_service_pp.mli | 1 - 19 files changed, 1015 insertions(+), 1024 deletions(-) diff --git a/src/proto/common_pb.ml b/src/proto/common_pb.ml index cc2f7034..07425f0f 100644 --- a/src/proto/common_pb.ml +++ b/src/proto/common_pb.ml @@ -1,5 +1,13 @@ [@@@ocaml.warning "-27-30-39"] +type array_value_mutable = { + mutable values : Common_types.any_value list; +} + +let default_array_value_mutable () : array_value_mutable = { + values = []; +} + type key_value_list_mutable = { mutable values : Common_types.key_value list; } @@ -18,14 +26,6 @@ let default_key_value_mutable () : key_value_mutable = { value = None; } -type array_value_mutable = { - mutable values : Common_types.any_value list; -} - -let default_array_value_mutable () : array_value_mutable = { - values = []; -} - type instrumentation_scope_mutable = { mutable name : string; mutable version : string; @@ -45,13 +45,13 @@ let rec decode_any_value d = let rec loop () = let ret:Common_types.any_value = match Pbrt.Decoder.key d with | None -> Pbrt.Decoder.malformed_variant "any_value" - | Some (7, _) -> (Common_types.Bytes_value (Pbrt.Decoder.bytes d) : Common_types.any_value) - | Some (6, _) -> (Common_types.Kvlist_value (decode_key_value_list (Pbrt.Decoder.nested d)) : Common_types.any_value) - | Some (5, _) -> (Common_types.Array_value (decode_array_value (Pbrt.Decoder.nested d)) : Common_types.any_value) - | Some (4, _) -> (Common_types.Double_value (Pbrt.Decoder.float_as_bits64 d) : Common_types.any_value) - | Some (3, _) -> (Common_types.Int_value (Pbrt.Decoder.int64_as_varint d) : Common_types.any_value) - | Some (2, _) -> (Common_types.Bool_value (Pbrt.Decoder.bool d) : Common_types.any_value) | Some (1, _) -> (Common_types.String_value (Pbrt.Decoder.string d) : Common_types.any_value) + | Some (2, _) -> (Common_types.Bool_value (Pbrt.Decoder.bool d) : Common_types.any_value) + | Some (3, _) -> (Common_types.Int_value (Pbrt.Decoder.int64_as_varint d) : Common_types.any_value) + | Some (4, _) -> (Common_types.Double_value (Pbrt.Decoder.float_as_bits64 d) : Common_types.any_value) + | Some (5, _) -> (Common_types.Array_value (decode_array_value (Pbrt.Decoder.nested d)) : Common_types.any_value) + | Some (6, _) -> (Common_types.Kvlist_value (decode_key_value_list (Pbrt.Decoder.nested d)) : Common_types.any_value) + | Some (7, _) -> (Common_types.Bytes_value (Pbrt.Decoder.bytes d) : Common_types.any_value) | Some (n, payload_kind) -> ( Pbrt.Decoder.skip d payload_kind; loop () @@ -61,6 +61,25 @@ let rec decode_any_value d = in loop () +and decode_array_value d = + let v = default_array_value_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.values <- List.rev v.values; + ); continue__ := false + | Some (1, Pbrt.Bytes) -> begin + v.values <- (decode_any_value (Pbrt.Decoder.nested d)) :: v.values; + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(array_value), field(1)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Common_types.values = v.values; + } : Common_types.array_value) + and decode_key_value_list d = let v = default_key_value_list_mutable () in let continue__= ref true in @@ -104,25 +123,6 @@ and decode_key_value d = Common_types.value = v.value; } : Common_types.key_value) -and decode_array_value d = - let v = default_array_value_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.values <- List.rev v.values; - ); continue__ := false - | Some (1, Pbrt.Bytes) -> begin - v.values <- (decode_any_value (Pbrt.Decoder.nested d)) :: v.values; - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(array_value), field(1)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Common_types.values = v.values; - } : Common_types.array_value) - let rec decode_instrumentation_scope d = let v = default_instrumentation_scope_mutable () in let continue__= ref true in @@ -162,29 +162,36 @@ let rec decode_instrumentation_scope d = let rec encode_any_value (v:Common_types.any_value) encoder = begin match v with - | Common_types.Bytes_value x -> - Pbrt.Encoder.key (7, Pbrt.Bytes) encoder; - Pbrt.Encoder.bytes x encoder; - | Common_types.Kvlist_value x -> - Pbrt.Encoder.key (6, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_key_value_list x) encoder; - | Common_types.Array_value x -> - Pbrt.Encoder.key (5, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_array_value x) encoder; - | Common_types.Double_value x -> - Pbrt.Encoder.key (4, Pbrt.Bits64) encoder; - Pbrt.Encoder.float_as_bits64 x encoder; - | Common_types.Int_value x -> - Pbrt.Encoder.key (3, Pbrt.Varint) encoder; - Pbrt.Encoder.int64_as_varint x encoder; - | Common_types.Bool_value x -> - Pbrt.Encoder.key (2, Pbrt.Varint) encoder; - Pbrt.Encoder.bool x encoder; | Common_types.String_value x -> Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; Pbrt.Encoder.string x encoder; + | Common_types.Bool_value x -> + Pbrt.Encoder.key (2, Pbrt.Varint) encoder; + Pbrt.Encoder.bool x encoder; + | Common_types.Int_value x -> + Pbrt.Encoder.key (3, Pbrt.Varint) encoder; + Pbrt.Encoder.int64_as_varint x encoder; + | Common_types.Double_value x -> + Pbrt.Encoder.key (4, Pbrt.Bits64) encoder; + Pbrt.Encoder.float_as_bits64 x encoder; + | Common_types.Array_value x -> + Pbrt.Encoder.key (5, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_array_value x) encoder; + | Common_types.Kvlist_value x -> + Pbrt.Encoder.key (6, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_key_value_list x) encoder; + | Common_types.Bytes_value x -> + Pbrt.Encoder.key (7, Pbrt.Bytes) encoder; + Pbrt.Encoder.bytes x encoder; end +and encode_array_value (v:Common_types.array_value) encoder = + List.iter (fun x -> + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_any_value x) encoder; + ) v.Common_types.values; + () + and encode_key_value_list (v:Common_types.key_value_list) encoder = List.iter (fun x -> Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; @@ -203,13 +210,6 @@ and encode_key_value (v:Common_types.key_value) encoder = end; () -and encode_array_value (v:Common_types.array_value) encoder = - List.iter (fun x -> - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_any_value x) encoder; - ) v.Common_types.values; - () - let rec encode_instrumentation_scope (v:Common_types.instrumentation_scope) encoder = Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; Pbrt.Encoder.string v.Common_types.name encoder; diff --git a/src/proto/common_pb.mli b/src/proto/common_pb.mli index a415b483..7ece8615 100644 --- a/src/proto/common_pb.mli +++ b/src/proto/common_pb.mli @@ -6,15 +6,15 @@ val encode_any_value : Common_types.any_value -> Pbrt.Encoder.t -> unit (** [encode_any_value v encoder] encodes [v] with the given [encoder] *) +val encode_array_value : Common_types.array_value -> Pbrt.Encoder.t -> unit +(** [encode_array_value v encoder] encodes [v] with the given [encoder] *) + val encode_key_value_list : Common_types.key_value_list -> Pbrt.Encoder.t -> unit (** [encode_key_value_list v encoder] encodes [v] with the given [encoder] *) val encode_key_value : Common_types.key_value -> Pbrt.Encoder.t -> unit (** [encode_key_value v encoder] encodes [v] with the given [encoder] *) -val encode_array_value : Common_types.array_value -> Pbrt.Encoder.t -> unit -(** [encode_array_value v encoder] encodes [v] with the given [encoder] *) - val encode_instrumentation_scope : Common_types.instrumentation_scope -> Pbrt.Encoder.t -> unit (** [encode_instrumentation_scope v encoder] encodes [v] with the given [encoder] *) @@ -24,14 +24,14 @@ val encode_instrumentation_scope : Common_types.instrumentation_scope -> Pbrt.En val decode_any_value : Pbrt.Decoder.t -> Common_types.any_value (** [decode_any_value decoder] decodes a [any_value] value from [decoder] *) +val decode_array_value : Pbrt.Decoder.t -> Common_types.array_value +(** [decode_array_value decoder] decodes a [array_value] value from [decoder] *) + val decode_key_value_list : Pbrt.Decoder.t -> Common_types.key_value_list (** [decode_key_value_list decoder] decodes a [key_value_list] value from [decoder] *) val decode_key_value : Pbrt.Decoder.t -> Common_types.key_value (** [decode_key_value decoder] decodes a [key_value] value from [decoder] *) -val decode_array_value : Pbrt.Decoder.t -> Common_types.array_value -(** [decode_array_value decoder] decodes a [array_value] value from [decoder] *) - val decode_instrumentation_scope : Pbrt.Decoder.t -> Common_types.instrumentation_scope (** [decode_instrumentation_scope decoder] decodes a [instrumentation_scope] value from [decoder] *) diff --git a/src/proto/common_pp.ml b/src/proto/common_pp.ml index 0bbc2906..e809bafc 100644 --- a/src/proto/common_pp.ml +++ b/src/proto/common_pp.ml @@ -2,13 +2,19 @@ let rec pp_any_value fmt (v:Common_types.any_value) = match v with - | Common_types.Bytes_value x -> Format.fprintf fmt "@[Bytes_value(@,%a)@]" Pbrt.Pp.pp_bytes x - | Common_types.Kvlist_value x -> Format.fprintf fmt "@[Kvlist_value(@,%a)@]" pp_key_value_list x - | Common_types.Array_value x -> Format.fprintf fmt "@[Array_value(@,%a)@]" pp_array_value x - | Common_types.Double_value x -> Format.fprintf fmt "@[Double_value(@,%a)@]" Pbrt.Pp.pp_float x - | Common_types.Int_value x -> Format.fprintf fmt "@[Int_value(@,%a)@]" Pbrt.Pp.pp_int64 x - | Common_types.Bool_value x -> Format.fprintf fmt "@[Bool_value(@,%a)@]" Pbrt.Pp.pp_bool x | Common_types.String_value x -> Format.fprintf fmt "@[String_value(@,%a)@]" Pbrt.Pp.pp_string x + | Common_types.Bool_value x -> Format.fprintf fmt "@[Bool_value(@,%a)@]" Pbrt.Pp.pp_bool x + | Common_types.Int_value x -> Format.fprintf fmt "@[Int_value(@,%a)@]" Pbrt.Pp.pp_int64 x + | Common_types.Double_value x -> Format.fprintf fmt "@[Double_value(@,%a)@]" Pbrt.Pp.pp_float x + | Common_types.Array_value x -> Format.fprintf fmt "@[Array_value(@,%a)@]" pp_array_value x + | Common_types.Kvlist_value x -> Format.fprintf fmt "@[Kvlist_value(@,%a)@]" pp_key_value_list x + | Common_types.Bytes_value x -> Format.fprintf fmt "@[Bytes_value(@,%a)@]" Pbrt.Pp.pp_bytes x + +and pp_array_value fmt (v:Common_types.array_value) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "values" (Pbrt.Pp.pp_list pp_any_value) fmt v.Common_types.values; + in + Pbrt.Pp.pp_brk pp_i fmt () and pp_key_value_list fmt (v:Common_types.key_value_list) = let pp_i fmt () = @@ -23,12 +29,6 @@ and pp_key_value fmt (v:Common_types.key_value) = in Pbrt.Pp.pp_brk pp_i fmt () -and pp_array_value fmt (v:Common_types.array_value) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "values" (Pbrt.Pp.pp_list pp_any_value) fmt v.Common_types.values; - in - Pbrt.Pp.pp_brk pp_i fmt () - let rec pp_instrumentation_scope fmt (v:Common_types.instrumentation_scope) = let pp_i fmt () = Pbrt.Pp.pp_record_field ~first:true "name" Pbrt.Pp.pp_string fmt v.Common_types.name; diff --git a/src/proto/common_pp.mli b/src/proto/common_pp.mli index 64c5f919..4c2fc14d 100644 --- a/src/proto/common_pp.mli +++ b/src/proto/common_pp.mli @@ -1,4 +1,3 @@ - (** common.proto Pretty Printing *) @@ -7,14 +6,14 @@ val pp_any_value : Format.formatter -> Common_types.any_value -> unit (** [pp_any_value v] formats v *) +val pp_array_value : Format.formatter -> Common_types.array_value -> unit +(** [pp_array_value v] formats v *) + val pp_key_value_list : Format.formatter -> Common_types.key_value_list -> unit (** [pp_key_value_list v] formats v *) val pp_key_value : Format.formatter -> Common_types.key_value -> unit (** [pp_key_value v] formats v *) -val pp_array_value : Format.formatter -> Common_types.array_value -> unit -(** [pp_array_value v] formats v *) - val pp_instrumentation_scope : Format.formatter -> Common_types.instrumentation_scope -> unit (** [pp_instrumentation_scope v] formats v *) diff --git a/src/proto/common_types.ml b/src/proto/common_types.ml index 3d010172..bddc9354 100644 --- a/src/proto/common_types.ml +++ b/src/proto/common_types.ml @@ -2,13 +2,17 @@ type any_value = - | Bytes_value of bytes - | Kvlist_value of key_value_list - | Array_value of array_value - | Double_value of float - | Int_value of int64 - | Bool_value of bool | String_value of string + | Bool_value of bool + | Int_value of int64 + | Double_value of float + | Array_value of array_value + | Kvlist_value of key_value_list + | Bytes_value of bytes + +and array_value = { + values : any_value list; +} and key_value_list = { values : key_value list; @@ -19,10 +23,6 @@ and key_value = { value : any_value option; } -and array_value = { - values : any_value list; -} - type instrumentation_scope = { name : string; version : string; @@ -30,7 +30,13 @@ type instrumentation_scope = { dropped_attributes_count : int32; } -let rec default_any_value () : any_value = Bytes_value (Bytes.create 0) +let rec default_any_value () : any_value = String_value ("") + +and default_array_value + ?values:((values:any_value list) = []) + () : array_value = { + values; +} and default_key_value_list ?values:((values:key_value list) = []) @@ -46,12 +52,6 @@ and default_key_value value; } -and default_array_value - ?values:((values:any_value list) = []) - () : array_value = { - values; -} - let rec default_instrumentation_scope ?name:((name:string) = "") ?version:((version:string) = "") diff --git a/src/proto/common_types.mli b/src/proto/common_types.mli index 2e72d579..8427638a 100644 --- a/src/proto/common_types.mli +++ b/src/proto/common_types.mli @@ -5,13 +5,17 @@ (** {2 Types} *) type any_value = - | Bytes_value of bytes - | Kvlist_value of key_value_list - | Array_value of array_value - | Double_value of float - | Int_value of int64 - | Bool_value of bool | String_value of string + | Bool_value of bool + | Int_value of int64 + | Double_value of float + | Array_value of array_value + | Kvlist_value of key_value_list + | Bytes_value of bytes + +and array_value = { + values : any_value list; +} and key_value_list = { values : key_value list; @@ -22,10 +26,6 @@ and key_value = { value : any_value option; } -and array_value = { - values : any_value list; -} - type instrumentation_scope = { name : string; version : string; @@ -39,6 +39,12 @@ type instrumentation_scope = { val default_any_value : unit -> any_value (** [default_any_value ()] is the default value for type [any_value] *) +val default_array_value : + ?values:any_value list -> + unit -> + array_value +(** [default_array_value ()] is the default value for type [array_value] *) + val default_key_value_list : ?values:key_value list -> unit -> @@ -52,12 +58,6 @@ val default_key_value : key_value (** [default_key_value ()] is the default value for type [key_value] *) -val default_array_value : - ?values:any_value list -> - unit -> - array_value -(** [default_array_value ()] is the default value for type [array_value] *) - val default_instrumentation_scope : ?name:string -> ?version:string -> diff --git a/src/proto/logs_pp.mli b/src/proto/logs_pp.mli index ecbc28a2..fd952524 100644 --- a/src/proto/logs_pp.mli +++ b/src/proto/logs_pp.mli @@ -1,4 +1,3 @@ - (** logs.proto Pretty Printing *) diff --git a/src/proto/logs_service_pp.mli b/src/proto/logs_service_pp.mli index 31d4613a..6aa6319f 100644 --- a/src/proto/logs_service_pp.mli +++ b/src/proto/logs_service_pp.mli @@ -1,4 +1,3 @@ - (** logs_service.proto Pretty Printing *) diff --git a/src/proto/metrics_pb.ml b/src/proto/metrics_pb.ml index 0c4ed447..d85e1e72 100644 --- a/src/proto/metrics_pb.ml +++ b/src/proto/metrics_pb.ml @@ -1,41 +1,95 @@ [@@@ocaml.warning "-27-30-39"] -type summary_data_point_value_at_quantile_mutable = { - mutable quantile : float; - mutable value : float; +type exemplar_mutable = { + mutable filtered_attributes : Common_types.key_value list; + mutable time_unix_nano : int64; + mutable value : Metrics_types.exemplar_value; + mutable span_id : bytes; + mutable trace_id : bytes; } -let default_summary_data_point_value_at_quantile_mutable () : summary_data_point_value_at_quantile_mutable = { - quantile = 0.; - value = 0.; +let default_exemplar_mutable () : exemplar_mutable = { + filtered_attributes = []; + time_unix_nano = 0L; + value = Metrics_types.As_double (0.); + span_id = Bytes.create 0; + trace_id = Bytes.create 0; } -type summary_data_point_mutable = { +type number_data_point_mutable = { + mutable attributes : Common_types.key_value list; + mutable start_time_unix_nano : int64; + mutable time_unix_nano : int64; + mutable value : Metrics_types.number_data_point_value; + mutable exemplars : Metrics_types.exemplar list; + mutable flags : int32; +} + +let default_number_data_point_mutable () : number_data_point_mutable = { + attributes = []; + start_time_unix_nano = 0L; + time_unix_nano = 0L; + value = Metrics_types.As_double (0.); + exemplars = []; + flags = 0l; +} + +type gauge_mutable = { + mutable data_points : Metrics_types.number_data_point list; +} + +let default_gauge_mutable () : gauge_mutable = { + data_points = []; +} + +type sum_mutable = { + mutable data_points : Metrics_types.number_data_point list; + mutable aggregation_temporality : Metrics_types.aggregation_temporality; + mutable is_monotonic : bool; +} + +let default_sum_mutable () : sum_mutable = { + data_points = []; + aggregation_temporality = Metrics_types.default_aggregation_temporality (); + is_monotonic = false; +} + +type histogram_data_point_mutable = { mutable attributes : Common_types.key_value list; mutable start_time_unix_nano : int64; mutable time_unix_nano : int64; mutable count : int64; - mutable sum : float; - mutable quantile_values : Metrics_types.summary_data_point_value_at_quantile list; + mutable sum : float option; + mutable bucket_counts : int64 list; + mutable explicit_bounds : float list; + mutable exemplars : Metrics_types.exemplar list; mutable flags : int32; + mutable min : float option; + mutable max : float option; } -let default_summary_data_point_mutable () : summary_data_point_mutable = { +let default_histogram_data_point_mutable () : histogram_data_point_mutable = { attributes = []; start_time_unix_nano = 0L; time_unix_nano = 0L; count = 0L; - sum = 0.; - quantile_values = []; + sum = None; + bucket_counts = []; + explicit_bounds = []; + exemplars = []; flags = 0l; + min = None; + max = None; } -type summary_mutable = { - mutable data_points : Metrics_types.summary_data_point list; +type histogram_mutable = { + mutable data_points : Metrics_types.histogram_data_point list; + mutable aggregation_temporality : Metrics_types.aggregation_temporality; } -let default_summary_mutable () : summary_mutable = { +let default_histogram_mutable () : histogram_mutable = { data_points = []; + aggregation_temporality = Metrics_types.default_aggregation_temporality (); } type exponential_histogram_data_point_buckets_mutable = { @@ -48,22 +102,6 @@ let default_exponential_histogram_data_point_buckets_mutable () : exponential_hi bucket_counts = []; } -type exemplar_mutable = { - mutable filtered_attributes : Common_types.key_value list; - mutable time_unix_nano : int64; - mutable value : Metrics_types.exemplar_value; - mutable span_id : bytes; - mutable trace_id : bytes; -} - -let default_exemplar_mutable () : exemplar_mutable = { - filtered_attributes = []; - time_unix_nano = 0L; - value = Metrics_types.As_int (0L); - span_id = Bytes.create 0; - trace_id = Bytes.create 0; -} - type exponential_histogram_data_point_mutable = { mutable attributes : Common_types.key_value list; mutable start_time_unix_nano : int64; @@ -108,79 +146,41 @@ let default_exponential_histogram_mutable () : exponential_histogram_mutable = { aggregation_temporality = Metrics_types.default_aggregation_temporality (); } -type histogram_data_point_mutable = { - mutable attributes : Common_types.key_value list; - mutable start_time_unix_nano : int64; - mutable time_unix_nano : int64; - mutable count : int64; - mutable sum : float option; - mutable bucket_counts : int64 list; - mutable explicit_bounds : float list; - mutable exemplars : Metrics_types.exemplar list; - mutable flags : int32; - mutable min : float option; - mutable max : float option; -} - -let default_histogram_data_point_mutable () : histogram_data_point_mutable = { - attributes = []; - start_time_unix_nano = 0L; - time_unix_nano = 0L; - count = 0L; - sum = None; - bucket_counts = []; - explicit_bounds = []; - exemplars = []; - flags = 0l; - min = None; - max = None; -} - -type histogram_mutable = { - mutable data_points : Metrics_types.histogram_data_point list; - mutable aggregation_temporality : Metrics_types.aggregation_temporality; +type summary_data_point_value_at_quantile_mutable = { + mutable quantile : float; + mutable value : float; } -let default_histogram_mutable () : histogram_mutable = { - data_points = []; - aggregation_temporality = Metrics_types.default_aggregation_temporality (); +let default_summary_data_point_value_at_quantile_mutable () : summary_data_point_value_at_quantile_mutable = { + quantile = 0.; + value = 0.; } -type number_data_point_mutable = { +type summary_data_point_mutable = { mutable attributes : Common_types.key_value list; mutable start_time_unix_nano : int64; mutable time_unix_nano : int64; - mutable value : Metrics_types.number_data_point_value; - mutable exemplars : Metrics_types.exemplar list; + mutable count : int64; + mutable sum : float; + mutable quantile_values : Metrics_types.summary_data_point_value_at_quantile list; mutable flags : int32; } -let default_number_data_point_mutable () : number_data_point_mutable = { +let default_summary_data_point_mutable () : summary_data_point_mutable = { attributes = []; start_time_unix_nano = 0L; time_unix_nano = 0L; - value = Metrics_types.As_int (0L); - exemplars = []; + count = 0L; + sum = 0.; + quantile_values = []; flags = 0l; } -type sum_mutable = { - mutable data_points : Metrics_types.number_data_point list; - mutable aggregation_temporality : Metrics_types.aggregation_temporality; - mutable is_monotonic : bool; -} - -let default_sum_mutable () : sum_mutable = { - data_points = []; - aggregation_temporality = Metrics_types.default_aggregation_temporality (); - is_monotonic = false; -} - -type gauge_mutable = { - mutable data_points : Metrics_types.number_data_point list; +type summary_mutable = { + mutable data_points : Metrics_types.summary_data_point list; } -let default_gauge_mutable () : gauge_mutable = { +let default_summary_mutable () : summary_mutable = { data_points = []; } @@ -195,7 +195,7 @@ let default_metric_mutable () : metric_mutable = { name = ""; description = ""; unit_ = ""; - data = Metrics_types.Summary (Metrics_types.default_summary ()); + data = Metrics_types.Gauge (Metrics_types.default_gauge ()); } type scope_metrics_mutable = { @@ -231,88 +231,141 @@ let default_metrics_data_mutable () : metrics_data_mutable = { } -let rec decode_summary_data_point_value_at_quantile d = - let v = default_summary_data_point_value_at_quantile_mutable () in +let rec decode_exemplar_value d = + let rec loop () = + let ret:Metrics_types.exemplar_value = match Pbrt.Decoder.key d with + | None -> Pbrt.Decoder.malformed_variant "exemplar_value" + | Some (3, _) -> (Metrics_types.As_double (Pbrt.Decoder.float_as_bits64 d) : Metrics_types.exemplar_value) + | Some (6, _) -> (Metrics_types.As_int (Pbrt.Decoder.int64_as_bits64 d) : Metrics_types.exemplar_value) + | Some (n, payload_kind) -> ( + Pbrt.Decoder.skip d payload_kind; + loop () + ) + in + ret + in + loop () + +and decode_exemplar d = + let v = default_exemplar_mutable () in let continue__= ref true in while !continue__ do match Pbrt.Decoder.key d with | None -> ( + v.filtered_attributes <- List.rev v.filtered_attributes; ); continue__ := false - | Some (1, Pbrt.Bits64) -> begin - v.quantile <- Pbrt.Decoder.float_as_bits64 d; + | Some (7, Pbrt.Bytes) -> begin + v.filtered_attributes <- (Common_pb.decode_key_value (Pbrt.Decoder.nested d)) :: v.filtered_attributes; end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(summary_data_point_value_at_quantile), field(1)" pk + | Some (7, pk) -> + Pbrt.Decoder.unexpected_payload "Message(exemplar), field(7)" pk | Some (2, Pbrt.Bits64) -> begin - v.value <- Pbrt.Decoder.float_as_bits64 d; + v.time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; end | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(summary_data_point_value_at_quantile), field(2)" pk + Pbrt.Decoder.unexpected_payload "Message(exemplar), field(2)" pk + | Some (3, Pbrt.Bits64) -> begin + v.value <- Metrics_types.As_double (Pbrt.Decoder.float_as_bits64 d); + end + | Some (3, pk) -> + Pbrt.Decoder.unexpected_payload "Message(exemplar), field(3)" pk + | Some (6, Pbrt.Bits64) -> begin + v.value <- Metrics_types.As_int (Pbrt.Decoder.int64_as_bits64 d); + end + | Some (6, pk) -> + Pbrt.Decoder.unexpected_payload "Message(exemplar), field(6)" pk + | Some (4, Pbrt.Bytes) -> begin + v.span_id <- Pbrt.Decoder.bytes d; + end + | Some (4, pk) -> + Pbrt.Decoder.unexpected_payload "Message(exemplar), field(4)" pk + | Some (5, Pbrt.Bytes) -> begin + v.trace_id <- Pbrt.Decoder.bytes d; + end + | Some (5, pk) -> + Pbrt.Decoder.unexpected_payload "Message(exemplar), field(5)" pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; ({ - Metrics_types.quantile = v.quantile; + Metrics_types.filtered_attributes = v.filtered_attributes; + Metrics_types.time_unix_nano = v.time_unix_nano; Metrics_types.value = v.value; - } : Metrics_types.summary_data_point_value_at_quantile) + Metrics_types.span_id = v.span_id; + Metrics_types.trace_id = v.trace_id; + } : Metrics_types.exemplar) -let rec decode_summary_data_point d = - let v = default_summary_data_point_mutable () in +let rec decode_number_data_point_value d = + let rec loop () = + let ret:Metrics_types.number_data_point_value = match Pbrt.Decoder.key d with + | None -> Pbrt.Decoder.malformed_variant "number_data_point_value" + | Some (4, _) -> (Metrics_types.As_double (Pbrt.Decoder.float_as_bits64 d) : Metrics_types.number_data_point_value) + | Some (6, _) -> (Metrics_types.As_int (Pbrt.Decoder.int64_as_bits64 d) : Metrics_types.number_data_point_value) + | Some (n, payload_kind) -> ( + Pbrt.Decoder.skip d payload_kind; + loop () + ) + in + ret + in + loop () + +and decode_number_data_point d = + let v = default_number_data_point_mutable () in let continue__= ref true in while !continue__ do match Pbrt.Decoder.key d with | None -> ( - v.quantile_values <- List.rev v.quantile_values; + v.exemplars <- List.rev v.exemplars; v.attributes <- List.rev v.attributes; ); continue__ := false | Some (7, Pbrt.Bytes) -> begin v.attributes <- (Common_pb.decode_key_value (Pbrt.Decoder.nested d)) :: v.attributes; end | Some (7, pk) -> - Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(7)" pk + Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(7)" pk | Some (2, Pbrt.Bits64) -> begin v.start_time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; end | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(2)" pk + Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(2)" pk | Some (3, Pbrt.Bits64) -> begin v.time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; end | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(3)" pk + Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(3)" pk | Some (4, Pbrt.Bits64) -> begin - v.count <- Pbrt.Decoder.int64_as_bits64 d; + v.value <- Metrics_types.As_double (Pbrt.Decoder.float_as_bits64 d); end | Some (4, pk) -> - Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(4)" pk - | Some (5, Pbrt.Bits64) -> begin - v.sum <- Pbrt.Decoder.float_as_bits64 d; - end - | Some (5, pk) -> - Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(5)" pk - | Some (6, Pbrt.Bytes) -> begin - v.quantile_values <- (decode_summary_data_point_value_at_quantile (Pbrt.Decoder.nested d)) :: v.quantile_values; + Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(4)" pk + | Some (6, Pbrt.Bits64) -> begin + v.value <- Metrics_types.As_int (Pbrt.Decoder.int64_as_bits64 d); end | Some (6, pk) -> - Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(6)" pk + Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(6)" pk + | Some (5, Pbrt.Bytes) -> begin + v.exemplars <- (decode_exemplar (Pbrt.Decoder.nested d)) :: v.exemplars; + end + | Some (5, pk) -> + Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(5)" pk | Some (8, Pbrt.Varint) -> begin v.flags <- Pbrt.Decoder.int32_as_varint d; end | Some (8, pk) -> - Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(8)" pk + Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(8)" pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; ({ Metrics_types.attributes = v.attributes; Metrics_types.start_time_unix_nano = v.start_time_unix_nano; Metrics_types.time_unix_nano = v.time_unix_nano; - Metrics_types.count = v.count; - Metrics_types.sum = v.sum; - Metrics_types.quantile_values = v.quantile_values; + Metrics_types.value = v.value; + Metrics_types.exemplars = v.exemplars; Metrics_types.flags = v.flags; - } : Metrics_types.summary_data_point) + } : Metrics_types.number_data_point) -let rec decode_summary d = - let v = default_summary_mutable () in +let rec decode_gauge d = + let v = default_gauge_mutable () in let continue__= ref true in while !continue__ do match Pbrt.Decoder.key d with @@ -320,103 +373,185 @@ let rec decode_summary d = v.data_points <- List.rev v.data_points; ); continue__ := false | Some (1, Pbrt.Bytes) -> begin - v.data_points <- (decode_summary_data_point (Pbrt.Decoder.nested d)) :: v.data_points; + v.data_points <- (decode_number_data_point (Pbrt.Decoder.nested d)) :: v.data_points; end | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(summary), field(1)" pk + Pbrt.Decoder.unexpected_payload "Message(gauge), field(1)" pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; ({ Metrics_types.data_points = v.data_points; - } : Metrics_types.summary) + } : Metrics_types.gauge) -let rec decode_exponential_histogram_data_point_buckets d = - let v = default_exponential_histogram_data_point_buckets_mutable () in +let rec decode_aggregation_temporality d = + match Pbrt.Decoder.int_as_varint d with + | 0 -> (Metrics_types.Aggregation_temporality_unspecified:Metrics_types.aggregation_temporality) + | 1 -> (Metrics_types.Aggregation_temporality_delta:Metrics_types.aggregation_temporality) + | 2 -> (Metrics_types.Aggregation_temporality_cumulative:Metrics_types.aggregation_temporality) + | _ -> Pbrt.Decoder.malformed_variant "aggregation_temporality" + +let rec decode_sum d = + let v = default_sum_mutable () in let continue__= ref true in while !continue__ do match Pbrt.Decoder.key d with | None -> ( - v.bucket_counts <- List.rev v.bucket_counts; + v.data_points <- List.rev v.data_points; ); continue__ := false - | Some (1, Pbrt.Varint) -> begin - v.offset <- Pbrt.Decoder.int32_as_zigzag d; + | Some (1, Pbrt.Bytes) -> begin + v.data_points <- (decode_number_data_point (Pbrt.Decoder.nested d)) :: v.data_points; end | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point_buckets), field(1)" pk - | Some (2, Pbrt.Bytes) -> begin - v.bucket_counts <- Pbrt.Decoder.packed_fold (fun l d -> (Pbrt.Decoder.int64_as_varint d)::l) [] d; + Pbrt.Decoder.unexpected_payload "Message(sum), field(1)" pk + | Some (2, Pbrt.Varint) -> begin + v.aggregation_temporality <- decode_aggregation_temporality d; end | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point_buckets), field(2)" pk + Pbrt.Decoder.unexpected_payload "Message(sum), field(2)" pk + | Some (3, Pbrt.Varint) -> begin + v.is_monotonic <- Pbrt.Decoder.bool d; + end + | Some (3, pk) -> + Pbrt.Decoder.unexpected_payload "Message(sum), field(3)" pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; ({ - Metrics_types.offset = v.offset; - Metrics_types.bucket_counts = v.bucket_counts; - } : Metrics_types.exponential_histogram_data_point_buckets) - -let rec decode_exemplar_value d = - let rec loop () = - let ret:Metrics_types.exemplar_value = match Pbrt.Decoder.key d with - | None -> Pbrt.Decoder.malformed_variant "exemplar_value" - | Some (6, _) -> (Metrics_types.As_int (Pbrt.Decoder.int64_as_bits64 d) : Metrics_types.exemplar_value) - | Some (3, _) -> (Metrics_types.As_double (Pbrt.Decoder.float_as_bits64 d) : Metrics_types.exemplar_value) - | Some (n, payload_kind) -> ( - Pbrt.Decoder.skip d payload_kind; - loop () - ) - in - ret - in - loop () + Metrics_types.data_points = v.data_points; + Metrics_types.aggregation_temporality = v.aggregation_temporality; + Metrics_types.is_monotonic = v.is_monotonic; + } : Metrics_types.sum) -and decode_exemplar d = - let v = default_exemplar_mutable () in +let rec decode_histogram_data_point d = + let v = default_histogram_data_point_mutable () in let continue__= ref true in while !continue__ do match Pbrt.Decoder.key d with | None -> ( - v.filtered_attributes <- List.rev v.filtered_attributes; + v.exemplars <- List.rev v.exemplars; + v.explicit_bounds <- List.rev v.explicit_bounds; + v.bucket_counts <- List.rev v.bucket_counts; + v.attributes <- List.rev v.attributes; ); continue__ := false - | Some (7, Pbrt.Bytes) -> begin - v.filtered_attributes <- (Common_pb.decode_key_value (Pbrt.Decoder.nested d)) :: v.filtered_attributes; + | Some (9, Pbrt.Bytes) -> begin + v.attributes <- (Common_pb.decode_key_value (Pbrt.Decoder.nested d)) :: v.attributes; end - | Some (7, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exemplar), field(7)" pk + | Some (9, pk) -> + Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(9)" pk | Some (2, Pbrt.Bits64) -> begin - v.time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; + v.start_time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; end | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exemplar), field(2)" pk - | Some (6, Pbrt.Bits64) -> begin - v.value <- Metrics_types.As_int (Pbrt.Decoder.int64_as_bits64 d); - end - | Some (6, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exemplar), field(6)" pk + Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(2)" pk | Some (3, Pbrt.Bits64) -> begin - v.value <- Metrics_types.As_double (Pbrt.Decoder.float_as_bits64 d); + v.time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; end | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exemplar), field(3)" pk - | Some (4, Pbrt.Bytes) -> begin - v.span_id <- Pbrt.Decoder.bytes d; + Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(3)" pk + | Some (4, Pbrt.Bits64) -> begin + v.count <- Pbrt.Decoder.int64_as_bits64 d; end | Some (4, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exemplar), field(4)" pk - | Some (5, Pbrt.Bytes) -> begin - v.trace_id <- Pbrt.Decoder.bytes d; + Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(4)" pk + | Some (5, Pbrt.Bits64) -> begin + v.sum <- Some (Pbrt.Decoder.float_as_bits64 d); end | Some (5, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exemplar), field(5)" pk + Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(5)" pk + | Some (6, Pbrt.Bytes) -> begin + v.bucket_counts <- Pbrt.Decoder.packed_fold (fun l d -> (Pbrt.Decoder.int64_as_bits64 d)::l) [] d; + end + | Some (6, pk) -> + Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(6)" pk + | Some (7, Pbrt.Bytes) -> begin + v.explicit_bounds <- Pbrt.Decoder.packed_fold (fun l d -> (Pbrt.Decoder.float_as_bits64 d)::l) [] d; + end + | Some (7, pk) -> + Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(7)" pk + | Some (8, Pbrt.Bytes) -> begin + v.exemplars <- (decode_exemplar (Pbrt.Decoder.nested d)) :: v.exemplars; + end + | Some (8, pk) -> + Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(8)" pk + | Some (10, Pbrt.Varint) -> begin + v.flags <- Pbrt.Decoder.int32_as_varint d; + end + | Some (10, pk) -> + Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(10)" pk + | Some (11, Pbrt.Bits64) -> begin + v.min <- Some (Pbrt.Decoder.float_as_bits64 d); + end + | Some (11, pk) -> + Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(11)" pk + | Some (12, Pbrt.Bits64) -> begin + v.max <- Some (Pbrt.Decoder.float_as_bits64 d); + end + | Some (12, pk) -> + Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(12)" pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; ({ - Metrics_types.filtered_attributes = v.filtered_attributes; + Metrics_types.attributes = v.attributes; + Metrics_types.start_time_unix_nano = v.start_time_unix_nano; Metrics_types.time_unix_nano = v.time_unix_nano; - Metrics_types.value = v.value; - Metrics_types.span_id = v.span_id; - Metrics_types.trace_id = v.trace_id; - } : Metrics_types.exemplar) + Metrics_types.count = v.count; + Metrics_types.sum = v.sum; + Metrics_types.bucket_counts = v.bucket_counts; + Metrics_types.explicit_bounds = v.explicit_bounds; + Metrics_types.exemplars = v.exemplars; + Metrics_types.flags = v.flags; + Metrics_types.min = v.min; + Metrics_types.max = v.max; + } : Metrics_types.histogram_data_point) + +let rec decode_histogram d = + let v = default_histogram_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.data_points <- List.rev v.data_points; + ); continue__ := false + | Some (1, Pbrt.Bytes) -> begin + v.data_points <- (decode_histogram_data_point (Pbrt.Decoder.nested d)) :: v.data_points; + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(histogram), field(1)" pk + | Some (2, Pbrt.Varint) -> begin + v.aggregation_temporality <- decode_aggregation_temporality d; + end + | Some (2, pk) -> + Pbrt.Decoder.unexpected_payload "Message(histogram), field(2)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Metrics_types.data_points = v.data_points; + Metrics_types.aggregation_temporality = v.aggregation_temporality; + } : Metrics_types.histogram) + +let rec decode_exponential_histogram_data_point_buckets d = + let v = default_exponential_histogram_data_point_buckets_mutable () in + let continue__= ref true in + while !continue__ do + match Pbrt.Decoder.key d with + | None -> ( + v.bucket_counts <- List.rev v.bucket_counts; + ); continue__ := false + | Some (1, Pbrt.Varint) -> begin + v.offset <- Pbrt.Decoder.int32_as_zigzag d; + end + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point_buckets), field(1)" pk + | Some (2, Pbrt.Bytes) -> begin + v.bucket_counts <- Pbrt.Decoder.packed_fold (fun l d -> (Pbrt.Decoder.int64_as_varint d)::l) [] d; + end + | Some (2, pk) -> + Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point_buckets), field(2)" pk + | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind + done; + ({ + Metrics_types.offset = v.offset; + Metrics_types.bucket_counts = v.bucket_counts; + } : Metrics_types.exponential_histogram_data_point_buckets) let rec decode_exponential_histogram_data_point d = let v = default_exponential_histogram_data_point_mutable () in @@ -516,13 +651,6 @@ let rec decode_exponential_histogram_data_point d = Metrics_types.zero_threshold = v.zero_threshold; } : Metrics_types.exponential_histogram_data_point) -let rec decode_aggregation_temporality d = - match Pbrt.Decoder.int_as_varint d with - | 0 -> (Metrics_types.Aggregation_temporality_unspecified:Metrics_types.aggregation_temporality) - | 1 -> (Metrics_types.Aggregation_temporality_delta:Metrics_types.aggregation_temporality) - | 2 -> (Metrics_types.Aggregation_temporality_cumulative:Metrics_types.aggregation_temporality) - | _ -> Pbrt.Decoder.malformed_variant "aggregation_temporality" - let rec decode_exponential_histogram d = let v = default_exponential_histogram_mutable () in let continue__= ref true in @@ -548,216 +676,88 @@ let rec decode_exponential_histogram d = Metrics_types.aggregation_temporality = v.aggregation_temporality; } : Metrics_types.exponential_histogram) -let rec decode_histogram_data_point d = - let v = default_histogram_data_point_mutable () in +let rec decode_summary_data_point_value_at_quantile d = + let v = default_summary_data_point_value_at_quantile_mutable () in let continue__= ref true in while !continue__ do match Pbrt.Decoder.key d with | None -> ( - v.exemplars <- List.rev v.exemplars; - v.explicit_bounds <- List.rev v.explicit_bounds; - v.bucket_counts <- List.rev v.bucket_counts; - v.attributes <- List.rev v.attributes; ); continue__ := false - | Some (9, Pbrt.Bytes) -> begin - v.attributes <- (Common_pb.decode_key_value (Pbrt.Decoder.nested d)) :: v.attributes; + | Some (1, Pbrt.Bits64) -> begin + v.quantile <- Pbrt.Decoder.float_as_bits64 d; end - | Some (9, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(9)" pk + | Some (1, pk) -> + Pbrt.Decoder.unexpected_payload "Message(summary_data_point_value_at_quantile), field(1)" pk | Some (2, Pbrt.Bits64) -> begin - v.start_time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; + v.value <- Pbrt.Decoder.float_as_bits64 d; end | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(2)" pk - | Some (3, Pbrt.Bits64) -> begin - v.time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; - end - | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(3)" pk - | Some (4, Pbrt.Bits64) -> begin - v.count <- Pbrt.Decoder.int64_as_bits64 d; - end - | Some (4, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(4)" pk - | Some (5, Pbrt.Bits64) -> begin - v.sum <- Some (Pbrt.Decoder.float_as_bits64 d); - end - | Some (5, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(5)" pk - | Some (6, Pbrt.Bytes) -> begin - v.bucket_counts <- Pbrt.Decoder.packed_fold (fun l d -> (Pbrt.Decoder.int64_as_bits64 d)::l) [] d; - end - | Some (6, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(6)" pk - | Some (7, Pbrt.Bytes) -> begin - v.explicit_bounds <- Pbrt.Decoder.packed_fold (fun l d -> (Pbrt.Decoder.float_as_bits64 d)::l) [] d; - end - | Some (7, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(7)" pk - | Some (8, Pbrt.Bytes) -> begin - v.exemplars <- (decode_exemplar (Pbrt.Decoder.nested d)) :: v.exemplars; - end - | Some (8, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(8)" pk - | Some (10, Pbrt.Varint) -> begin - v.flags <- Pbrt.Decoder.int32_as_varint d; - end - | Some (10, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(10)" pk - | Some (11, Pbrt.Bits64) -> begin - v.min <- Some (Pbrt.Decoder.float_as_bits64 d); - end - | Some (11, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(11)" pk - | Some (12, Pbrt.Bits64) -> begin - v.max <- Some (Pbrt.Decoder.float_as_bits64 d); - end - | Some (12, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(12)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Metrics_types.attributes = v.attributes; - Metrics_types.start_time_unix_nano = v.start_time_unix_nano; - Metrics_types.time_unix_nano = v.time_unix_nano; - Metrics_types.count = v.count; - Metrics_types.sum = v.sum; - Metrics_types.bucket_counts = v.bucket_counts; - Metrics_types.explicit_bounds = v.explicit_bounds; - Metrics_types.exemplars = v.exemplars; - Metrics_types.flags = v.flags; - Metrics_types.min = v.min; - Metrics_types.max = v.max; - } : Metrics_types.histogram_data_point) - -let rec decode_histogram d = - let v = default_histogram_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.data_points <- List.rev v.data_points; - ); continue__ := false - | Some (1, Pbrt.Bytes) -> begin - v.data_points <- (decode_histogram_data_point (Pbrt.Decoder.nested d)) :: v.data_points; - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram), field(1)" pk - | Some (2, Pbrt.Varint) -> begin - v.aggregation_temporality <- decode_aggregation_temporality d; - end - | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram), field(2)" pk + Pbrt.Decoder.unexpected_payload "Message(summary_data_point_value_at_quantile), field(2)" pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; ({ - Metrics_types.data_points = v.data_points; - Metrics_types.aggregation_temporality = v.aggregation_temporality; - } : Metrics_types.histogram) - -let rec decode_number_data_point_value d = - let rec loop () = - let ret:Metrics_types.number_data_point_value = match Pbrt.Decoder.key d with - | None -> Pbrt.Decoder.malformed_variant "number_data_point_value" - | Some (6, _) -> (Metrics_types.As_int (Pbrt.Decoder.int64_as_bits64 d) : Metrics_types.number_data_point_value) - | Some (4, _) -> (Metrics_types.As_double (Pbrt.Decoder.float_as_bits64 d) : Metrics_types.number_data_point_value) - | Some (n, payload_kind) -> ( - Pbrt.Decoder.skip d payload_kind; - loop () - ) - in - ret - in - loop () + Metrics_types.quantile = v.quantile; + Metrics_types.value = v.value; + } : Metrics_types.summary_data_point_value_at_quantile) -and decode_number_data_point d = - let v = default_number_data_point_mutable () in +let rec decode_summary_data_point d = + let v = default_summary_data_point_mutable () in let continue__= ref true in while !continue__ do match Pbrt.Decoder.key d with | None -> ( - v.exemplars <- List.rev v.exemplars; + v.quantile_values <- List.rev v.quantile_values; v.attributes <- List.rev v.attributes; ); continue__ := false | Some (7, Pbrt.Bytes) -> begin v.attributes <- (Common_pb.decode_key_value (Pbrt.Decoder.nested d)) :: v.attributes; end | Some (7, pk) -> - Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(7)" pk + Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(7)" pk | Some (2, Pbrt.Bits64) -> begin v.start_time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; end | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(2)" pk + Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(2)" pk | Some (3, Pbrt.Bits64) -> begin v.time_unix_nano <- Pbrt.Decoder.int64_as_bits64 d; end | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(3)" pk - | Some (6, Pbrt.Bits64) -> begin - v.value <- Metrics_types.As_int (Pbrt.Decoder.int64_as_bits64 d); - end - | Some (6, pk) -> - Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(6)" pk + Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(3)" pk | Some (4, Pbrt.Bits64) -> begin - v.value <- Metrics_types.As_double (Pbrt.Decoder.float_as_bits64 d); + v.count <- Pbrt.Decoder.int64_as_bits64 d; end | Some (4, pk) -> - Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(4)" pk - | Some (5, Pbrt.Bytes) -> begin - v.exemplars <- (decode_exemplar (Pbrt.Decoder.nested d)) :: v.exemplars; + Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(4)" pk + | Some (5, Pbrt.Bits64) -> begin + v.sum <- Pbrt.Decoder.float_as_bits64 d; end | Some (5, pk) -> - Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(5)" pk + Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(5)" pk + | Some (6, Pbrt.Bytes) -> begin + v.quantile_values <- (decode_summary_data_point_value_at_quantile (Pbrt.Decoder.nested d)) :: v.quantile_values; + end + | Some (6, pk) -> + Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(6)" pk | Some (8, Pbrt.Varint) -> begin v.flags <- Pbrt.Decoder.int32_as_varint d; end | Some (8, pk) -> - Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(8)" pk + Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(8)" pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; ({ Metrics_types.attributes = v.attributes; Metrics_types.start_time_unix_nano = v.start_time_unix_nano; Metrics_types.time_unix_nano = v.time_unix_nano; - Metrics_types.value = v.value; - Metrics_types.exemplars = v.exemplars; + Metrics_types.count = v.count; + Metrics_types.sum = v.sum; + Metrics_types.quantile_values = v.quantile_values; Metrics_types.flags = v.flags; - } : Metrics_types.number_data_point) - -let rec decode_sum d = - let v = default_sum_mutable () in - let continue__= ref true in - while !continue__ do - match Pbrt.Decoder.key d with - | None -> ( - v.data_points <- List.rev v.data_points; - ); continue__ := false - | Some (1, Pbrt.Bytes) -> begin - v.data_points <- (decode_number_data_point (Pbrt.Decoder.nested d)) :: v.data_points; - end - | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(sum), field(1)" pk - | Some (2, Pbrt.Varint) -> begin - v.aggregation_temporality <- decode_aggregation_temporality d; - end - | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(sum), field(2)" pk - | Some (3, Pbrt.Varint) -> begin - v.is_monotonic <- Pbrt.Decoder.bool d; - end - | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(sum), field(3)" pk - | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind - done; - ({ - Metrics_types.data_points = v.data_points; - Metrics_types.aggregation_temporality = v.aggregation_temporality; - Metrics_types.is_monotonic = v.is_monotonic; - } : Metrics_types.sum) + } : Metrics_types.summary_data_point) -let rec decode_gauge d = - let v = default_gauge_mutable () in +let rec decode_summary d = + let v = default_summary_mutable () in let continue__= ref true in while !continue__ do match Pbrt.Decoder.key d with @@ -765,25 +765,25 @@ let rec decode_gauge d = v.data_points <- List.rev v.data_points; ); continue__ := false | Some (1, Pbrt.Bytes) -> begin - v.data_points <- (decode_number_data_point (Pbrt.Decoder.nested d)) :: v.data_points; + v.data_points <- (decode_summary_data_point (Pbrt.Decoder.nested d)) :: v.data_points; end | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(gauge), field(1)" pk + Pbrt.Decoder.unexpected_payload "Message(summary), field(1)" pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; ({ Metrics_types.data_points = v.data_points; - } : Metrics_types.gauge) + } : Metrics_types.summary) let rec decode_metric_data d = let rec loop () = let ret:Metrics_types.metric_data = match Pbrt.Decoder.key d with | None -> Pbrt.Decoder.malformed_variant "metric_data" - | Some (11, _) -> (Metrics_types.Summary (decode_summary (Pbrt.Decoder.nested d)) : Metrics_types.metric_data) - | Some (10, _) -> (Metrics_types.Exponential_histogram (decode_exponential_histogram (Pbrt.Decoder.nested d)) : Metrics_types.metric_data) - | Some (9, _) -> (Metrics_types.Histogram (decode_histogram (Pbrt.Decoder.nested d)) : Metrics_types.metric_data) - | Some (7, _) -> (Metrics_types.Sum (decode_sum (Pbrt.Decoder.nested d)) : Metrics_types.metric_data) | Some (5, _) -> (Metrics_types.Gauge (decode_gauge (Pbrt.Decoder.nested d)) : Metrics_types.metric_data) + | Some (7, _) -> (Metrics_types.Sum (decode_sum (Pbrt.Decoder.nested d)) : Metrics_types.metric_data) + | Some (9, _) -> (Metrics_types.Histogram (decode_histogram (Pbrt.Decoder.nested d)) : Metrics_types.metric_data) + | Some (10, _) -> (Metrics_types.Exponential_histogram (decode_exponential_histogram (Pbrt.Decoder.nested d)) : Metrics_types.metric_data) + | Some (11, _) -> (Metrics_types.Summary (decode_summary (Pbrt.Decoder.nested d)) : Metrics_types.metric_data) | Some (n, payload_kind) -> ( Pbrt.Decoder.skip d payload_kind; loop () @@ -815,31 +815,31 @@ and decode_metric d = end | Some (3, pk) -> Pbrt.Decoder.unexpected_payload "Message(metric), field(3)" pk - | Some (11, Pbrt.Bytes) -> begin - v.data <- Metrics_types.Summary (decode_summary (Pbrt.Decoder.nested d)); + | Some (5, Pbrt.Bytes) -> begin + v.data <- Metrics_types.Gauge (decode_gauge (Pbrt.Decoder.nested d)); end - | Some (11, pk) -> - Pbrt.Decoder.unexpected_payload "Message(metric), field(11)" pk - | Some (10, Pbrt.Bytes) -> begin - v.data <- Metrics_types.Exponential_histogram (decode_exponential_histogram (Pbrt.Decoder.nested d)); + | Some (5, pk) -> + Pbrt.Decoder.unexpected_payload "Message(metric), field(5)" pk + | Some (7, Pbrt.Bytes) -> begin + v.data <- Metrics_types.Sum (decode_sum (Pbrt.Decoder.nested d)); end - | Some (10, pk) -> - Pbrt.Decoder.unexpected_payload "Message(metric), field(10)" pk + | Some (7, pk) -> + Pbrt.Decoder.unexpected_payload "Message(metric), field(7)" pk | Some (9, Pbrt.Bytes) -> begin v.data <- Metrics_types.Histogram (decode_histogram (Pbrt.Decoder.nested d)); end | Some (9, pk) -> Pbrt.Decoder.unexpected_payload "Message(metric), field(9)" pk - | Some (7, Pbrt.Bytes) -> begin - v.data <- Metrics_types.Sum (decode_sum (Pbrt.Decoder.nested d)); + | Some (10, Pbrt.Bytes) -> begin + v.data <- Metrics_types.Exponential_histogram (decode_exponential_histogram (Pbrt.Decoder.nested d)); end - | Some (7, pk) -> - Pbrt.Decoder.unexpected_payload "Message(metric), field(7)" pk - | Some (5, Pbrt.Bytes) -> begin - v.data <- Metrics_types.Gauge (decode_gauge (Pbrt.Decoder.nested d)); + | Some (10, pk) -> + Pbrt.Decoder.unexpected_payload "Message(metric), field(10)" pk + | Some (11, Pbrt.Bytes) -> begin + v.data <- Metrics_types.Summary (decode_summary (Pbrt.Decoder.nested d)); end - | Some (5, pk) -> - Pbrt.Decoder.unexpected_payload "Message(metric), field(5)" pk + | Some (11, pk) -> + Pbrt.Decoder.unexpected_payload "Message(metric), field(11)" pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; ({ @@ -936,60 +936,14 @@ let rec decode_data_point_flags d = | 1 -> (Metrics_types.Data_point_flags_no_recorded_value_mask:Metrics_types.data_point_flags) | _ -> Pbrt.Decoder.malformed_variant "data_point_flags" -let rec encode_summary_data_point_value_at_quantile (v:Metrics_types.summary_data_point_value_at_quantile) encoder = - Pbrt.Encoder.key (1, Pbrt.Bits64) encoder; - Pbrt.Encoder.float_as_bits64 v.Metrics_types.quantile encoder; - Pbrt.Encoder.key (2, Pbrt.Bits64) encoder; - Pbrt.Encoder.float_as_bits64 v.Metrics_types.value encoder; - () - -let rec encode_summary_data_point (v:Metrics_types.summary_data_point) encoder = - List.iter (fun x -> - Pbrt.Encoder.key (7, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (Common_pb.encode_key_value x) encoder; - ) v.Metrics_types.attributes; - Pbrt.Encoder.key (2, Pbrt.Bits64) encoder; - Pbrt.Encoder.int64_as_bits64 v.Metrics_types.start_time_unix_nano encoder; - Pbrt.Encoder.key (3, Pbrt.Bits64) encoder; - Pbrt.Encoder.int64_as_bits64 v.Metrics_types.time_unix_nano encoder; - Pbrt.Encoder.key (4, Pbrt.Bits64) encoder; - Pbrt.Encoder.int64_as_bits64 v.Metrics_types.count encoder; - Pbrt.Encoder.key (5, Pbrt.Bits64) encoder; - Pbrt.Encoder.float_as_bits64 v.Metrics_types.sum encoder; - List.iter (fun x -> - Pbrt.Encoder.key (6, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_summary_data_point_value_at_quantile x) encoder; - ) v.Metrics_types.quantile_values; - Pbrt.Encoder.key (8, Pbrt.Varint) encoder; - Pbrt.Encoder.int32_as_varint v.Metrics_types.flags encoder; - () - -let rec encode_summary (v:Metrics_types.summary) encoder = - List.iter (fun x -> - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_summary_data_point x) encoder; - ) v.Metrics_types.data_points; - () - -let rec encode_exponential_histogram_data_point_buckets (v:Metrics_types.exponential_histogram_data_point_buckets) encoder = - Pbrt.Encoder.key (1, Pbrt.Varint) encoder; - Pbrt.Encoder.int32_as_zigzag v.Metrics_types.offset encoder; - Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (fun encoder -> - List.iter (fun x -> - Pbrt.Encoder.int64_as_varint x encoder; - ) v.Metrics_types.bucket_counts; - ) encoder; - () - let rec encode_exemplar_value (v:Metrics_types.exemplar_value) encoder = begin match v with - | Metrics_types.As_int x -> - Pbrt.Encoder.key (6, Pbrt.Bits64) encoder; - Pbrt.Encoder.int64_as_bits64 x encoder; | Metrics_types.As_double x -> Pbrt.Encoder.key (3, Pbrt.Bits64) encoder; Pbrt.Encoder.float_as_bits64 x encoder; + | Metrics_types.As_int x -> + Pbrt.Encoder.key (6, Pbrt.Bits64) encoder; + Pbrt.Encoder.int64_as_bits64 x encoder; end and encode_exemplar (v:Metrics_types.exemplar) encoder = @@ -1000,12 +954,12 @@ and encode_exemplar (v:Metrics_types.exemplar) encoder = Pbrt.Encoder.key (2, Pbrt.Bits64) encoder; Pbrt.Encoder.int64_as_bits64 v.Metrics_types.time_unix_nano encoder; begin match v.Metrics_types.value with - | Metrics_types.As_int x -> - Pbrt.Encoder.key (6, Pbrt.Bits64) encoder; - Pbrt.Encoder.int64_as_bits64 x encoder; | Metrics_types.As_double x -> Pbrt.Encoder.key (3, Pbrt.Bits64) encoder; Pbrt.Encoder.float_as_bits64 x encoder; + | Metrics_types.As_int x -> + Pbrt.Encoder.key (6, Pbrt.Bits64) encoder; + Pbrt.Encoder.int64_as_bits64 x encoder; end; Pbrt.Encoder.key (4, Pbrt.Bytes) encoder; Pbrt.Encoder.bytes v.Metrics_types.span_id encoder; @@ -1013,59 +967,46 @@ and encode_exemplar (v:Metrics_types.exemplar) encoder = Pbrt.Encoder.bytes v.Metrics_types.trace_id encoder; () -let rec encode_exponential_histogram_data_point (v:Metrics_types.exponential_histogram_data_point) encoder = +let rec encode_number_data_point_value (v:Metrics_types.number_data_point_value) encoder = + begin match v with + | Metrics_types.As_double x -> + Pbrt.Encoder.key (4, Pbrt.Bits64) encoder; + Pbrt.Encoder.float_as_bits64 x encoder; + | Metrics_types.As_int x -> + Pbrt.Encoder.key (6, Pbrt.Bits64) encoder; + Pbrt.Encoder.int64_as_bits64 x encoder; + end + +and encode_number_data_point (v:Metrics_types.number_data_point) encoder = List.iter (fun x -> - Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.key (7, Pbrt.Bytes) encoder; Pbrt.Encoder.nested (Common_pb.encode_key_value x) encoder; ) v.Metrics_types.attributes; Pbrt.Encoder.key (2, Pbrt.Bits64) encoder; Pbrt.Encoder.int64_as_bits64 v.Metrics_types.start_time_unix_nano encoder; Pbrt.Encoder.key (3, Pbrt.Bits64) encoder; Pbrt.Encoder.int64_as_bits64 v.Metrics_types.time_unix_nano encoder; - Pbrt.Encoder.key (4, Pbrt.Bits64) encoder; - Pbrt.Encoder.int64_as_bits64 v.Metrics_types.count encoder; - begin match v.Metrics_types.sum with - | Some x -> - Pbrt.Encoder.key (5, Pbrt.Bits64) encoder; + begin match v.Metrics_types.value with + | Metrics_types.As_double x -> + Pbrt.Encoder.key (4, Pbrt.Bits64) encoder; Pbrt.Encoder.float_as_bits64 x encoder; - | None -> (); - end; - Pbrt.Encoder.key (6, Pbrt.Varint) encoder; - Pbrt.Encoder.int32_as_zigzag v.Metrics_types.scale encoder; - Pbrt.Encoder.key (7, Pbrt.Bits64) encoder; - Pbrt.Encoder.int64_as_bits64 v.Metrics_types.zero_count encoder; - begin match v.Metrics_types.positive with - | Some x -> - Pbrt.Encoder.key (8, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_exponential_histogram_data_point_buckets x) encoder; - | None -> (); - end; - begin match v.Metrics_types.negative with - | Some x -> - Pbrt.Encoder.key (9, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_exponential_histogram_data_point_buckets x) encoder; - | None -> (); + | Metrics_types.As_int x -> + Pbrt.Encoder.key (6, Pbrt.Bits64) encoder; + Pbrt.Encoder.int64_as_bits64 x encoder; end; - Pbrt.Encoder.key (10, Pbrt.Varint) encoder; - Pbrt.Encoder.int32_as_varint v.Metrics_types.flags encoder; List.iter (fun x -> - Pbrt.Encoder.key (11, Pbrt.Bytes) encoder; + Pbrt.Encoder.key (5, Pbrt.Bytes) encoder; Pbrt.Encoder.nested (encode_exemplar x) encoder; ) v.Metrics_types.exemplars; - begin match v.Metrics_types.min with - | Some x -> - Pbrt.Encoder.key (12, Pbrt.Bits64) encoder; - Pbrt.Encoder.float_as_bits64 x encoder; - | None -> (); - end; - begin match v.Metrics_types.max with - | Some x -> - Pbrt.Encoder.key (13, Pbrt.Bits64) encoder; - Pbrt.Encoder.float_as_bits64 x encoder; - | None -> (); - end; - Pbrt.Encoder.key (14, Pbrt.Bits64) encoder; - Pbrt.Encoder.float_as_bits64 v.Metrics_types.zero_threshold encoder; + Pbrt.Encoder.key (8, Pbrt.Varint) encoder; + Pbrt.Encoder.int32_as_varint v.Metrics_types.flags encoder; + () + +let rec encode_gauge (v:Metrics_types.gauge) encoder = + List.iter (fun x -> + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_number_data_point x) encoder; + ) v.Metrics_types.data_points; () let rec encode_aggregation_temporality (v:Metrics_types.aggregation_temporality) encoder = @@ -1074,13 +1015,15 @@ let rec encode_aggregation_temporality (v:Metrics_types.aggregation_temporality) | Metrics_types.Aggregation_temporality_delta -> Pbrt.Encoder.int_as_varint 1 encoder | Metrics_types.Aggregation_temporality_cumulative -> Pbrt.Encoder.int_as_varint 2 encoder -let rec encode_exponential_histogram (v:Metrics_types.exponential_histogram) encoder = +let rec encode_sum (v:Metrics_types.sum) encoder = List.iter (fun x -> Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_exponential_histogram_data_point x) encoder; + Pbrt.Encoder.nested (encode_number_data_point x) encoder; ) v.Metrics_types.data_points; Pbrt.Encoder.key (2, Pbrt.Varint) encoder; encode_aggregation_temporality v.Metrics_types.aggregation_temporality encoder; + Pbrt.Encoder.key (3, Pbrt.Varint) encoder; + Pbrt.Encoder.bool v.Metrics_types.is_monotonic encoder; () let rec encode_histogram_data_point (v:Metrics_types.histogram_data_point) encoder = @@ -1141,76 +1084,133 @@ let rec encode_histogram (v:Metrics_types.histogram) encoder = encode_aggregation_temporality v.Metrics_types.aggregation_temporality encoder; () -let rec encode_number_data_point_value (v:Metrics_types.number_data_point_value) encoder = - begin match v with - | Metrics_types.As_int x -> - Pbrt.Encoder.key (6, Pbrt.Bits64) encoder; - Pbrt.Encoder.int64_as_bits64 x encoder; - | Metrics_types.As_double x -> - Pbrt.Encoder.key (4, Pbrt.Bits64) encoder; - Pbrt.Encoder.float_as_bits64 x encoder; - end +let rec encode_exponential_histogram_data_point_buckets (v:Metrics_types.exponential_histogram_data_point_buckets) encoder = + Pbrt.Encoder.key (1, Pbrt.Varint) encoder; + Pbrt.Encoder.int32_as_zigzag v.Metrics_types.offset encoder; + Pbrt.Encoder.key (2, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (fun encoder -> + List.iter (fun x -> + Pbrt.Encoder.int64_as_varint x encoder; + ) v.Metrics_types.bucket_counts; + ) encoder; + () -and encode_number_data_point (v:Metrics_types.number_data_point) encoder = +let rec encode_exponential_histogram_data_point (v:Metrics_types.exponential_histogram_data_point) encoder = List.iter (fun x -> - Pbrt.Encoder.key (7, Pbrt.Bytes) encoder; + Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; Pbrt.Encoder.nested (Common_pb.encode_key_value x) encoder; ) v.Metrics_types.attributes; Pbrt.Encoder.key (2, Pbrt.Bits64) encoder; Pbrt.Encoder.int64_as_bits64 v.Metrics_types.start_time_unix_nano encoder; Pbrt.Encoder.key (3, Pbrt.Bits64) encoder; Pbrt.Encoder.int64_as_bits64 v.Metrics_types.time_unix_nano encoder; - begin match v.Metrics_types.value with - | Metrics_types.As_int x -> - Pbrt.Encoder.key (6, Pbrt.Bits64) encoder; - Pbrt.Encoder.int64_as_bits64 x encoder; - | Metrics_types.As_double x -> - Pbrt.Encoder.key (4, Pbrt.Bits64) encoder; + Pbrt.Encoder.key (4, Pbrt.Bits64) encoder; + Pbrt.Encoder.int64_as_bits64 v.Metrics_types.count encoder; + begin match v.Metrics_types.sum with + | Some x -> + Pbrt.Encoder.key (5, Pbrt.Bits64) encoder; Pbrt.Encoder.float_as_bits64 x encoder; + | None -> (); + end; + Pbrt.Encoder.key (6, Pbrt.Varint) encoder; + Pbrt.Encoder.int32_as_zigzag v.Metrics_types.scale encoder; + Pbrt.Encoder.key (7, Pbrt.Bits64) encoder; + Pbrt.Encoder.int64_as_bits64 v.Metrics_types.zero_count encoder; + begin match v.Metrics_types.positive with + | Some x -> + Pbrt.Encoder.key (8, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_exponential_histogram_data_point_buckets x) encoder; + | None -> (); + end; + begin match v.Metrics_types.negative with + | Some x -> + Pbrt.Encoder.key (9, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_exponential_histogram_data_point_buckets x) encoder; + | None -> (); end; + Pbrt.Encoder.key (10, Pbrt.Varint) encoder; + Pbrt.Encoder.int32_as_varint v.Metrics_types.flags encoder; List.iter (fun x -> - Pbrt.Encoder.key (5, Pbrt.Bytes) encoder; + Pbrt.Encoder.key (11, Pbrt.Bytes) encoder; Pbrt.Encoder.nested (encode_exemplar x) encoder; ) v.Metrics_types.exemplars; - Pbrt.Encoder.key (8, Pbrt.Varint) encoder; - Pbrt.Encoder.int32_as_varint v.Metrics_types.flags encoder; + begin match v.Metrics_types.min with + | Some x -> + Pbrt.Encoder.key (12, Pbrt.Bits64) encoder; + Pbrt.Encoder.float_as_bits64 x encoder; + | None -> (); + end; + begin match v.Metrics_types.max with + | Some x -> + Pbrt.Encoder.key (13, Pbrt.Bits64) encoder; + Pbrt.Encoder.float_as_bits64 x encoder; + | None -> (); + end; + Pbrt.Encoder.key (14, Pbrt.Bits64) encoder; + Pbrt.Encoder.float_as_bits64 v.Metrics_types.zero_threshold encoder; () -let rec encode_sum (v:Metrics_types.sum) encoder = +let rec encode_exponential_histogram (v:Metrics_types.exponential_histogram) encoder = List.iter (fun x -> Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_number_data_point x) encoder; + Pbrt.Encoder.nested (encode_exponential_histogram_data_point x) encoder; ) v.Metrics_types.data_points; Pbrt.Encoder.key (2, Pbrt.Varint) encoder; encode_aggregation_temporality v.Metrics_types.aggregation_temporality encoder; - Pbrt.Encoder.key (3, Pbrt.Varint) encoder; - Pbrt.Encoder.bool v.Metrics_types.is_monotonic encoder; () -let rec encode_gauge (v:Metrics_types.gauge) encoder = +let rec encode_summary_data_point_value_at_quantile (v:Metrics_types.summary_data_point_value_at_quantile) encoder = + Pbrt.Encoder.key (1, Pbrt.Bits64) encoder; + Pbrt.Encoder.float_as_bits64 v.Metrics_types.quantile encoder; + Pbrt.Encoder.key (2, Pbrt.Bits64) encoder; + Pbrt.Encoder.float_as_bits64 v.Metrics_types.value encoder; + () + +let rec encode_summary_data_point (v:Metrics_types.summary_data_point) encoder = + List.iter (fun x -> + Pbrt.Encoder.key (7, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (Common_pb.encode_key_value x) encoder; + ) v.Metrics_types.attributes; + Pbrt.Encoder.key (2, Pbrt.Bits64) encoder; + Pbrt.Encoder.int64_as_bits64 v.Metrics_types.start_time_unix_nano encoder; + Pbrt.Encoder.key (3, Pbrt.Bits64) encoder; + Pbrt.Encoder.int64_as_bits64 v.Metrics_types.time_unix_nano encoder; + Pbrt.Encoder.key (4, Pbrt.Bits64) encoder; + Pbrt.Encoder.int64_as_bits64 v.Metrics_types.count encoder; + Pbrt.Encoder.key (5, Pbrt.Bits64) encoder; + Pbrt.Encoder.float_as_bits64 v.Metrics_types.sum encoder; + List.iter (fun x -> + Pbrt.Encoder.key (6, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_summary_data_point_value_at_quantile x) encoder; + ) v.Metrics_types.quantile_values; + Pbrt.Encoder.key (8, Pbrt.Varint) encoder; + Pbrt.Encoder.int32_as_varint v.Metrics_types.flags encoder; + () + +let rec encode_summary (v:Metrics_types.summary) encoder = List.iter (fun x -> Pbrt.Encoder.key (1, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_number_data_point x) encoder; + Pbrt.Encoder.nested (encode_summary_data_point x) encoder; ) v.Metrics_types.data_points; () let rec encode_metric_data (v:Metrics_types.metric_data) encoder = begin match v with - | Metrics_types.Summary x -> - Pbrt.Encoder.key (11, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_summary x) encoder; - | Metrics_types.Exponential_histogram x -> - Pbrt.Encoder.key (10, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_exponential_histogram x) encoder; - | Metrics_types.Histogram x -> - Pbrt.Encoder.key (9, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_histogram x) encoder; - | Metrics_types.Sum x -> - Pbrt.Encoder.key (7, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_sum x) encoder; | Metrics_types.Gauge x -> Pbrt.Encoder.key (5, Pbrt.Bytes) encoder; Pbrt.Encoder.nested (encode_gauge x) encoder; + | Metrics_types.Sum x -> + Pbrt.Encoder.key (7, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_sum x) encoder; + | Metrics_types.Histogram x -> + Pbrt.Encoder.key (9, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_histogram x) encoder; + | Metrics_types.Exponential_histogram x -> + Pbrt.Encoder.key (10, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_exponential_histogram x) encoder; + | Metrics_types.Summary x -> + Pbrt.Encoder.key (11, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_summary x) encoder; end and encode_metric (v:Metrics_types.metric) encoder = @@ -1221,21 +1221,21 @@ and encode_metric (v:Metrics_types.metric) encoder = Pbrt.Encoder.key (3, Pbrt.Bytes) encoder; Pbrt.Encoder.string v.Metrics_types.unit_ encoder; begin match v.Metrics_types.data with - | Metrics_types.Summary x -> - Pbrt.Encoder.key (11, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_summary x) encoder; - | Metrics_types.Exponential_histogram x -> - Pbrt.Encoder.key (10, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_exponential_histogram x) encoder; - | Metrics_types.Histogram x -> - Pbrt.Encoder.key (9, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_histogram x) encoder; - | Metrics_types.Sum x -> - Pbrt.Encoder.key (7, Pbrt.Bytes) encoder; - Pbrt.Encoder.nested (encode_sum x) encoder; | Metrics_types.Gauge x -> Pbrt.Encoder.key (5, Pbrt.Bytes) encoder; Pbrt.Encoder.nested (encode_gauge x) encoder; + | Metrics_types.Sum x -> + Pbrt.Encoder.key (7, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_sum x) encoder; + | Metrics_types.Histogram x -> + Pbrt.Encoder.key (9, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_histogram x) encoder; + | Metrics_types.Exponential_histogram x -> + Pbrt.Encoder.key (10, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_exponential_histogram x) encoder; + | Metrics_types.Summary x -> + Pbrt.Encoder.key (11, Pbrt.Bytes) encoder; + Pbrt.Encoder.nested (encode_summary x) encoder; end; () diff --git a/src/proto/metrics_pb.mli b/src/proto/metrics_pb.mli index 8184e069..6393cedd 100644 --- a/src/proto/metrics_pb.mli +++ b/src/proto/metrics_pb.mli @@ -3,32 +3,26 @@ (** {2 Protobuf Encoding} *) -val encode_summary_data_point_value_at_quantile : Metrics_types.summary_data_point_value_at_quantile -> Pbrt.Encoder.t -> unit -(** [encode_summary_data_point_value_at_quantile v encoder] encodes [v] with the given [encoder] *) - -val encode_summary_data_point : Metrics_types.summary_data_point -> Pbrt.Encoder.t -> unit -(** [encode_summary_data_point v encoder] encodes [v] with the given [encoder] *) - -val encode_summary : Metrics_types.summary -> Pbrt.Encoder.t -> unit -(** [encode_summary v encoder] encodes [v] with the given [encoder] *) - -val encode_exponential_histogram_data_point_buckets : Metrics_types.exponential_histogram_data_point_buckets -> Pbrt.Encoder.t -> unit -(** [encode_exponential_histogram_data_point_buckets v encoder] encodes [v] with the given [encoder] *) - val encode_exemplar_value : Metrics_types.exemplar_value -> Pbrt.Encoder.t -> unit (** [encode_exemplar_value v encoder] encodes [v] with the given [encoder] *) val encode_exemplar : Metrics_types.exemplar -> Pbrt.Encoder.t -> unit (** [encode_exemplar v encoder] encodes [v] with the given [encoder] *) -val encode_exponential_histogram_data_point : Metrics_types.exponential_histogram_data_point -> Pbrt.Encoder.t -> unit -(** [encode_exponential_histogram_data_point v encoder] encodes [v] with the given [encoder] *) +val encode_number_data_point_value : Metrics_types.number_data_point_value -> Pbrt.Encoder.t -> unit +(** [encode_number_data_point_value v encoder] encodes [v] with the given [encoder] *) + +val encode_number_data_point : Metrics_types.number_data_point -> Pbrt.Encoder.t -> unit +(** [encode_number_data_point v encoder] encodes [v] with the given [encoder] *) + +val encode_gauge : Metrics_types.gauge -> Pbrt.Encoder.t -> unit +(** [encode_gauge v encoder] encodes [v] with the given [encoder] *) val encode_aggregation_temporality : Metrics_types.aggregation_temporality -> Pbrt.Encoder.t -> unit (** [encode_aggregation_temporality v encoder] encodes [v] with the given [encoder] *) -val encode_exponential_histogram : Metrics_types.exponential_histogram -> Pbrt.Encoder.t -> unit -(** [encode_exponential_histogram v encoder] encodes [v] with the given [encoder] *) +val encode_sum : Metrics_types.sum -> Pbrt.Encoder.t -> unit +(** [encode_sum v encoder] encodes [v] with the given [encoder] *) val encode_histogram_data_point : Metrics_types.histogram_data_point -> Pbrt.Encoder.t -> unit (** [encode_histogram_data_point v encoder] encodes [v] with the given [encoder] *) @@ -36,17 +30,23 @@ val encode_histogram_data_point : Metrics_types.histogram_data_point -> Pbrt.Enc val encode_histogram : Metrics_types.histogram -> Pbrt.Encoder.t -> unit (** [encode_histogram v encoder] encodes [v] with the given [encoder] *) -val encode_number_data_point_value : Metrics_types.number_data_point_value -> Pbrt.Encoder.t -> unit -(** [encode_number_data_point_value v encoder] encodes [v] with the given [encoder] *) +val encode_exponential_histogram_data_point_buckets : Metrics_types.exponential_histogram_data_point_buckets -> Pbrt.Encoder.t -> unit +(** [encode_exponential_histogram_data_point_buckets v encoder] encodes [v] with the given [encoder] *) -val encode_number_data_point : Metrics_types.number_data_point -> Pbrt.Encoder.t -> unit -(** [encode_number_data_point v encoder] encodes [v] with the given [encoder] *) +val encode_exponential_histogram_data_point : Metrics_types.exponential_histogram_data_point -> Pbrt.Encoder.t -> unit +(** [encode_exponential_histogram_data_point v encoder] encodes [v] with the given [encoder] *) -val encode_sum : Metrics_types.sum -> Pbrt.Encoder.t -> unit -(** [encode_sum v encoder] encodes [v] with the given [encoder] *) +val encode_exponential_histogram : Metrics_types.exponential_histogram -> Pbrt.Encoder.t -> unit +(** [encode_exponential_histogram v encoder] encodes [v] with the given [encoder] *) -val encode_gauge : Metrics_types.gauge -> Pbrt.Encoder.t -> unit -(** [encode_gauge v encoder] encodes [v] with the given [encoder] *) +val encode_summary_data_point_value_at_quantile : Metrics_types.summary_data_point_value_at_quantile -> Pbrt.Encoder.t -> unit +(** [encode_summary_data_point_value_at_quantile v encoder] encodes [v] with the given [encoder] *) + +val encode_summary_data_point : Metrics_types.summary_data_point -> Pbrt.Encoder.t -> unit +(** [encode_summary_data_point v encoder] encodes [v] with the given [encoder] *) + +val encode_summary : Metrics_types.summary -> Pbrt.Encoder.t -> unit +(** [encode_summary v encoder] encodes [v] with the given [encoder] *) val encode_metric_data : Metrics_types.metric_data -> Pbrt.Encoder.t -> unit (** [encode_metric_data v encoder] encodes [v] with the given [encoder] *) @@ -69,32 +69,26 @@ val encode_data_point_flags : Metrics_types.data_point_flags -> Pbrt.Encoder.t - (** {2 Protobuf Decoding} *) -val decode_summary_data_point_value_at_quantile : Pbrt.Decoder.t -> Metrics_types.summary_data_point_value_at_quantile -(** [decode_summary_data_point_value_at_quantile decoder] decodes a [summary_data_point_value_at_quantile] value from [decoder] *) - -val decode_summary_data_point : Pbrt.Decoder.t -> Metrics_types.summary_data_point -(** [decode_summary_data_point decoder] decodes a [summary_data_point] value from [decoder] *) - -val decode_summary : Pbrt.Decoder.t -> Metrics_types.summary -(** [decode_summary decoder] decodes a [summary] value from [decoder] *) - -val decode_exponential_histogram_data_point_buckets : Pbrt.Decoder.t -> Metrics_types.exponential_histogram_data_point_buckets -(** [decode_exponential_histogram_data_point_buckets decoder] decodes a [exponential_histogram_data_point_buckets] value from [decoder] *) - val decode_exemplar_value : Pbrt.Decoder.t -> Metrics_types.exemplar_value (** [decode_exemplar_value decoder] decodes a [exemplar_value] value from [decoder] *) val decode_exemplar : Pbrt.Decoder.t -> Metrics_types.exemplar (** [decode_exemplar decoder] decodes a [exemplar] value from [decoder] *) -val decode_exponential_histogram_data_point : Pbrt.Decoder.t -> Metrics_types.exponential_histogram_data_point -(** [decode_exponential_histogram_data_point decoder] decodes a [exponential_histogram_data_point] value from [decoder] *) +val decode_number_data_point_value : Pbrt.Decoder.t -> Metrics_types.number_data_point_value +(** [decode_number_data_point_value decoder] decodes a [number_data_point_value] value from [decoder] *) + +val decode_number_data_point : Pbrt.Decoder.t -> Metrics_types.number_data_point +(** [decode_number_data_point decoder] decodes a [number_data_point] value from [decoder] *) + +val decode_gauge : Pbrt.Decoder.t -> Metrics_types.gauge +(** [decode_gauge decoder] decodes a [gauge] value from [decoder] *) val decode_aggregation_temporality : Pbrt.Decoder.t -> Metrics_types.aggregation_temporality (** [decode_aggregation_temporality decoder] decodes a [aggregation_temporality] value from [decoder] *) -val decode_exponential_histogram : Pbrt.Decoder.t -> Metrics_types.exponential_histogram -(** [decode_exponential_histogram decoder] decodes a [exponential_histogram] value from [decoder] *) +val decode_sum : Pbrt.Decoder.t -> Metrics_types.sum +(** [decode_sum decoder] decodes a [sum] value from [decoder] *) val decode_histogram_data_point : Pbrt.Decoder.t -> Metrics_types.histogram_data_point (** [decode_histogram_data_point decoder] decodes a [histogram_data_point] value from [decoder] *) @@ -102,17 +96,23 @@ val decode_histogram_data_point : Pbrt.Decoder.t -> Metrics_types.histogram_data val decode_histogram : Pbrt.Decoder.t -> Metrics_types.histogram (** [decode_histogram decoder] decodes a [histogram] value from [decoder] *) -val decode_number_data_point_value : Pbrt.Decoder.t -> Metrics_types.number_data_point_value -(** [decode_number_data_point_value decoder] decodes a [number_data_point_value] value from [decoder] *) +val decode_exponential_histogram_data_point_buckets : Pbrt.Decoder.t -> Metrics_types.exponential_histogram_data_point_buckets +(** [decode_exponential_histogram_data_point_buckets decoder] decodes a [exponential_histogram_data_point_buckets] value from [decoder] *) -val decode_number_data_point : Pbrt.Decoder.t -> Metrics_types.number_data_point -(** [decode_number_data_point decoder] decodes a [number_data_point] value from [decoder] *) +val decode_exponential_histogram_data_point : Pbrt.Decoder.t -> Metrics_types.exponential_histogram_data_point +(** [decode_exponential_histogram_data_point decoder] decodes a [exponential_histogram_data_point] value from [decoder] *) -val decode_sum : Pbrt.Decoder.t -> Metrics_types.sum -(** [decode_sum decoder] decodes a [sum] value from [decoder] *) +val decode_exponential_histogram : Pbrt.Decoder.t -> Metrics_types.exponential_histogram +(** [decode_exponential_histogram decoder] decodes a [exponential_histogram] value from [decoder] *) -val decode_gauge : Pbrt.Decoder.t -> Metrics_types.gauge -(** [decode_gauge decoder] decodes a [gauge] value from [decoder] *) +val decode_summary_data_point_value_at_quantile : Pbrt.Decoder.t -> Metrics_types.summary_data_point_value_at_quantile +(** [decode_summary_data_point_value_at_quantile decoder] decodes a [summary_data_point_value_at_quantile] value from [decoder] *) + +val decode_summary_data_point : Pbrt.Decoder.t -> Metrics_types.summary_data_point +(** [decode_summary_data_point decoder] decodes a [summary_data_point] value from [decoder] *) + +val decode_summary : Pbrt.Decoder.t -> Metrics_types.summary +(** [decode_summary decoder] decodes a [summary] value from [decoder] *) val decode_metric_data : Pbrt.Decoder.t -> Metrics_types.metric_data (** [decode_metric_data decoder] decodes a [metric_data] value from [decoder] *) diff --git a/src/proto/metrics_pp.ml b/src/proto/metrics_pp.ml index 974c2f7e..838343ff 100644 --- a/src/proto/metrics_pp.ml +++ b/src/proto/metrics_pp.ml @@ -1,41 +1,9 @@ [@@@ocaml.warning "-27-30-39"] -let rec pp_summary_data_point_value_at_quantile fmt (v:Metrics_types.summary_data_point_value_at_quantile) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "quantile" Pbrt.Pp.pp_float fmt v.Metrics_types.quantile; - Pbrt.Pp.pp_record_field ~first:false "value" Pbrt.Pp.pp_float fmt v.Metrics_types.value; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_summary_data_point fmt (v:Metrics_types.summary_data_point) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "attributes" (Pbrt.Pp.pp_list Common_pp.pp_key_value) fmt v.Metrics_types.attributes; - Pbrt.Pp.pp_record_field ~first:false "start_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Metrics_types.start_time_unix_nano; - Pbrt.Pp.pp_record_field ~first:false "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Metrics_types.time_unix_nano; - Pbrt.Pp.pp_record_field ~first:false "count" Pbrt.Pp.pp_int64 fmt v.Metrics_types.count; - Pbrt.Pp.pp_record_field ~first:false "sum" Pbrt.Pp.pp_float fmt v.Metrics_types.sum; - Pbrt.Pp.pp_record_field ~first:false "quantile_values" (Pbrt.Pp.pp_list pp_summary_data_point_value_at_quantile) fmt v.Metrics_types.quantile_values; - Pbrt.Pp.pp_record_field ~first:false "flags" Pbrt.Pp.pp_int32 fmt v.Metrics_types.flags; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_summary fmt (v:Metrics_types.summary) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "data_points" (Pbrt.Pp.pp_list pp_summary_data_point) fmt v.Metrics_types.data_points; - in - Pbrt.Pp.pp_brk pp_i fmt () - -let rec pp_exponential_histogram_data_point_buckets fmt (v:Metrics_types.exponential_histogram_data_point_buckets) = - let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "offset" Pbrt.Pp.pp_int32 fmt v.Metrics_types.offset; - Pbrt.Pp.pp_record_field ~first:false "bucket_counts" (Pbrt.Pp.pp_list Pbrt.Pp.pp_int64) fmt v.Metrics_types.bucket_counts; - in - Pbrt.Pp.pp_brk pp_i fmt () - let rec pp_exemplar_value fmt (v:Metrics_types.exemplar_value) = match v with - | Metrics_types.As_int x -> Format.fprintf fmt "@[As_int(@,%a)@]" Pbrt.Pp.pp_int64 x | Metrics_types.As_double x -> Format.fprintf fmt "@[As_double(@,%a)@]" Pbrt.Pp.pp_float x + | Metrics_types.As_int x -> Format.fprintf fmt "@[As_int(@,%a)@]" Pbrt.Pp.pp_int64 x and pp_exemplar fmt (v:Metrics_types.exemplar) = let pp_i fmt () = @@ -47,22 +15,25 @@ and pp_exemplar fmt (v:Metrics_types.exemplar) = in Pbrt.Pp.pp_brk pp_i fmt () -let rec pp_exponential_histogram_data_point fmt (v:Metrics_types.exponential_histogram_data_point) = +let rec pp_number_data_point_value fmt (v:Metrics_types.number_data_point_value) = + match v with + | Metrics_types.As_double x -> Format.fprintf fmt "@[As_double(@,%a)@]" Pbrt.Pp.pp_float x + | Metrics_types.As_int x -> Format.fprintf fmt "@[As_int(@,%a)@]" Pbrt.Pp.pp_int64 x + +and pp_number_data_point fmt (v:Metrics_types.number_data_point) = let pp_i fmt () = Pbrt.Pp.pp_record_field ~first:true "attributes" (Pbrt.Pp.pp_list Common_pp.pp_key_value) fmt v.Metrics_types.attributes; Pbrt.Pp.pp_record_field ~first:false "start_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Metrics_types.start_time_unix_nano; Pbrt.Pp.pp_record_field ~first:false "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Metrics_types.time_unix_nano; - Pbrt.Pp.pp_record_field ~first:false "count" Pbrt.Pp.pp_int64 fmt v.Metrics_types.count; - Pbrt.Pp.pp_record_field ~first:false "sum" (Pbrt.Pp.pp_option Pbrt.Pp.pp_float) fmt v.Metrics_types.sum; - Pbrt.Pp.pp_record_field ~first:false "scale" Pbrt.Pp.pp_int32 fmt v.Metrics_types.scale; - Pbrt.Pp.pp_record_field ~first:false "zero_count" Pbrt.Pp.pp_int64 fmt v.Metrics_types.zero_count; - Pbrt.Pp.pp_record_field ~first:false "positive" (Pbrt.Pp.pp_option pp_exponential_histogram_data_point_buckets) fmt v.Metrics_types.positive; - Pbrt.Pp.pp_record_field ~first:false "negative" (Pbrt.Pp.pp_option pp_exponential_histogram_data_point_buckets) fmt v.Metrics_types.negative; - Pbrt.Pp.pp_record_field ~first:false "flags" Pbrt.Pp.pp_int32 fmt v.Metrics_types.flags; + Pbrt.Pp.pp_record_field ~first:false "value" pp_number_data_point_value fmt v.Metrics_types.value; Pbrt.Pp.pp_record_field ~first:false "exemplars" (Pbrt.Pp.pp_list pp_exemplar) fmt v.Metrics_types.exemplars; - Pbrt.Pp.pp_record_field ~first:false "min" (Pbrt.Pp.pp_option Pbrt.Pp.pp_float) fmt v.Metrics_types.min; - Pbrt.Pp.pp_record_field ~first:false "max" (Pbrt.Pp.pp_option Pbrt.Pp.pp_float) fmt v.Metrics_types.max; - Pbrt.Pp.pp_record_field ~first:false "zero_threshold" Pbrt.Pp.pp_float fmt v.Metrics_types.zero_threshold; + Pbrt.Pp.pp_record_field ~first:false "flags" Pbrt.Pp.pp_int32 fmt v.Metrics_types.flags; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_gauge fmt (v:Metrics_types.gauge) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "data_points" (Pbrt.Pp.pp_list pp_number_data_point) fmt v.Metrics_types.data_points; in Pbrt.Pp.pp_brk pp_i fmt () @@ -72,10 +43,11 @@ let rec pp_aggregation_temporality fmt (v:Metrics_types.aggregation_temporality) | Metrics_types.Aggregation_temporality_delta -> Format.fprintf fmt "Aggregation_temporality_delta" | Metrics_types.Aggregation_temporality_cumulative -> Format.fprintf fmt "Aggregation_temporality_cumulative" -let rec pp_exponential_histogram fmt (v:Metrics_types.exponential_histogram) = +let rec pp_sum fmt (v:Metrics_types.sum) = let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "data_points" (Pbrt.Pp.pp_list pp_exponential_histogram_data_point) fmt v.Metrics_types.data_points; + Pbrt.Pp.pp_record_field ~first:true "data_points" (Pbrt.Pp.pp_list pp_number_data_point) fmt v.Metrics_types.data_points; Pbrt.Pp.pp_record_field ~first:false "aggregation_temporality" pp_aggregation_temporality fmt v.Metrics_types.aggregation_temporality; + Pbrt.Pp.pp_record_field ~first:false "is_monotonic" Pbrt.Pp.pp_bool fmt v.Metrics_types.is_monotonic; in Pbrt.Pp.pp_brk pp_i fmt () @@ -102,43 +74,71 @@ let rec pp_histogram fmt (v:Metrics_types.histogram) = in Pbrt.Pp.pp_brk pp_i fmt () -let rec pp_number_data_point_value fmt (v:Metrics_types.number_data_point_value) = - match v with - | Metrics_types.As_int x -> Format.fprintf fmt "@[As_int(@,%a)@]" Pbrt.Pp.pp_int64 x - | Metrics_types.As_double x -> Format.fprintf fmt "@[As_double(@,%a)@]" Pbrt.Pp.pp_float x +let rec pp_exponential_histogram_data_point_buckets fmt (v:Metrics_types.exponential_histogram_data_point_buckets) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "offset" Pbrt.Pp.pp_int32 fmt v.Metrics_types.offset; + Pbrt.Pp.pp_record_field ~first:false "bucket_counts" (Pbrt.Pp.pp_list Pbrt.Pp.pp_int64) fmt v.Metrics_types.bucket_counts; + in + Pbrt.Pp.pp_brk pp_i fmt () -and pp_number_data_point fmt (v:Metrics_types.number_data_point) = +let rec pp_exponential_histogram_data_point fmt (v:Metrics_types.exponential_histogram_data_point) = let pp_i fmt () = Pbrt.Pp.pp_record_field ~first:true "attributes" (Pbrt.Pp.pp_list Common_pp.pp_key_value) fmt v.Metrics_types.attributes; Pbrt.Pp.pp_record_field ~first:false "start_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Metrics_types.start_time_unix_nano; Pbrt.Pp.pp_record_field ~first:false "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Metrics_types.time_unix_nano; - Pbrt.Pp.pp_record_field ~first:false "value" pp_number_data_point_value fmt v.Metrics_types.value; - Pbrt.Pp.pp_record_field ~first:false "exemplars" (Pbrt.Pp.pp_list pp_exemplar) fmt v.Metrics_types.exemplars; + Pbrt.Pp.pp_record_field ~first:false "count" Pbrt.Pp.pp_int64 fmt v.Metrics_types.count; + Pbrt.Pp.pp_record_field ~first:false "sum" (Pbrt.Pp.pp_option Pbrt.Pp.pp_float) fmt v.Metrics_types.sum; + Pbrt.Pp.pp_record_field ~first:false "scale" Pbrt.Pp.pp_int32 fmt v.Metrics_types.scale; + Pbrt.Pp.pp_record_field ~first:false "zero_count" Pbrt.Pp.pp_int64 fmt v.Metrics_types.zero_count; + Pbrt.Pp.pp_record_field ~first:false "positive" (Pbrt.Pp.pp_option pp_exponential_histogram_data_point_buckets) fmt v.Metrics_types.positive; + Pbrt.Pp.pp_record_field ~first:false "negative" (Pbrt.Pp.pp_option pp_exponential_histogram_data_point_buckets) fmt v.Metrics_types.negative; Pbrt.Pp.pp_record_field ~first:false "flags" Pbrt.Pp.pp_int32 fmt v.Metrics_types.flags; + Pbrt.Pp.pp_record_field ~first:false "exemplars" (Pbrt.Pp.pp_list pp_exemplar) fmt v.Metrics_types.exemplars; + Pbrt.Pp.pp_record_field ~first:false "min" (Pbrt.Pp.pp_option Pbrt.Pp.pp_float) fmt v.Metrics_types.min; + Pbrt.Pp.pp_record_field ~first:false "max" (Pbrt.Pp.pp_option Pbrt.Pp.pp_float) fmt v.Metrics_types.max; + Pbrt.Pp.pp_record_field ~first:false "zero_threshold" Pbrt.Pp.pp_float fmt v.Metrics_types.zero_threshold; in Pbrt.Pp.pp_brk pp_i fmt () -let rec pp_sum fmt (v:Metrics_types.sum) = +let rec pp_exponential_histogram fmt (v:Metrics_types.exponential_histogram) = let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "data_points" (Pbrt.Pp.pp_list pp_number_data_point) fmt v.Metrics_types.data_points; + Pbrt.Pp.pp_record_field ~first:true "data_points" (Pbrt.Pp.pp_list pp_exponential_histogram_data_point) fmt v.Metrics_types.data_points; Pbrt.Pp.pp_record_field ~first:false "aggregation_temporality" pp_aggregation_temporality fmt v.Metrics_types.aggregation_temporality; - Pbrt.Pp.pp_record_field ~first:false "is_monotonic" Pbrt.Pp.pp_bool fmt v.Metrics_types.is_monotonic; in Pbrt.Pp.pp_brk pp_i fmt () -let rec pp_gauge fmt (v:Metrics_types.gauge) = +let rec pp_summary_data_point_value_at_quantile fmt (v:Metrics_types.summary_data_point_value_at_quantile) = let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "data_points" (Pbrt.Pp.pp_list pp_number_data_point) fmt v.Metrics_types.data_points; + Pbrt.Pp.pp_record_field ~first:true "quantile" Pbrt.Pp.pp_float fmt v.Metrics_types.quantile; + Pbrt.Pp.pp_record_field ~first:false "value" Pbrt.Pp.pp_float fmt v.Metrics_types.value; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_summary_data_point fmt (v:Metrics_types.summary_data_point) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "attributes" (Pbrt.Pp.pp_list Common_pp.pp_key_value) fmt v.Metrics_types.attributes; + Pbrt.Pp.pp_record_field ~first:false "start_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Metrics_types.start_time_unix_nano; + Pbrt.Pp.pp_record_field ~first:false "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.Metrics_types.time_unix_nano; + Pbrt.Pp.pp_record_field ~first:false "count" Pbrt.Pp.pp_int64 fmt v.Metrics_types.count; + Pbrt.Pp.pp_record_field ~first:false "sum" Pbrt.Pp.pp_float fmt v.Metrics_types.sum; + Pbrt.Pp.pp_record_field ~first:false "quantile_values" (Pbrt.Pp.pp_list pp_summary_data_point_value_at_quantile) fmt v.Metrics_types.quantile_values; + Pbrt.Pp.pp_record_field ~first:false "flags" Pbrt.Pp.pp_int32 fmt v.Metrics_types.flags; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_summary fmt (v:Metrics_types.summary) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "data_points" (Pbrt.Pp.pp_list pp_summary_data_point) fmt v.Metrics_types.data_points; in Pbrt.Pp.pp_brk pp_i fmt () let rec pp_metric_data fmt (v:Metrics_types.metric_data) = match v with - | Metrics_types.Summary x -> Format.fprintf fmt "@[Summary(@,%a)@]" pp_summary x - | Metrics_types.Exponential_histogram x -> Format.fprintf fmt "@[Exponential_histogram(@,%a)@]" pp_exponential_histogram x - | Metrics_types.Histogram x -> Format.fprintf fmt "@[Histogram(@,%a)@]" pp_histogram x - | Metrics_types.Sum x -> Format.fprintf fmt "@[Sum(@,%a)@]" pp_sum x | Metrics_types.Gauge x -> Format.fprintf fmt "@[Gauge(@,%a)@]" pp_gauge x + | Metrics_types.Sum x -> Format.fprintf fmt "@[Sum(@,%a)@]" pp_sum x + | Metrics_types.Histogram x -> Format.fprintf fmt "@[Histogram(@,%a)@]" pp_histogram x + | Metrics_types.Exponential_histogram x -> Format.fprintf fmt "@[Exponential_histogram(@,%a)@]" pp_exponential_histogram x + | Metrics_types.Summary x -> Format.fprintf fmt "@[Summary(@,%a)@]" pp_summary x and pp_metric fmt (v:Metrics_types.metric) = let pp_i fmt () = diff --git a/src/proto/metrics_pp.mli b/src/proto/metrics_pp.mli index 7ee4b6fc..c506e897 100644 --- a/src/proto/metrics_pp.mli +++ b/src/proto/metrics_pp.mli @@ -1,35 +1,28 @@ - (** metrics.proto Pretty Printing *) (** {2 Formatters} *) -val pp_summary_data_point_value_at_quantile : Format.formatter -> Metrics_types.summary_data_point_value_at_quantile -> unit -(** [pp_summary_data_point_value_at_quantile v] formats v *) - -val pp_summary_data_point : Format.formatter -> Metrics_types.summary_data_point -> unit -(** [pp_summary_data_point v] formats v *) - -val pp_summary : Format.formatter -> Metrics_types.summary -> unit -(** [pp_summary v] formats v *) - -val pp_exponential_histogram_data_point_buckets : Format.formatter -> Metrics_types.exponential_histogram_data_point_buckets -> unit -(** [pp_exponential_histogram_data_point_buckets v] formats v *) - val pp_exemplar_value : Format.formatter -> Metrics_types.exemplar_value -> unit (** [pp_exemplar_value v] formats v *) val pp_exemplar : Format.formatter -> Metrics_types.exemplar -> unit (** [pp_exemplar v] formats v *) -val pp_exponential_histogram_data_point : Format.formatter -> Metrics_types.exponential_histogram_data_point -> unit -(** [pp_exponential_histogram_data_point v] formats v *) +val pp_number_data_point_value : Format.formatter -> Metrics_types.number_data_point_value -> unit +(** [pp_number_data_point_value v] formats v *) + +val pp_number_data_point : Format.formatter -> Metrics_types.number_data_point -> unit +(** [pp_number_data_point v] formats v *) + +val pp_gauge : Format.formatter -> Metrics_types.gauge -> unit +(** [pp_gauge v] formats v *) val pp_aggregation_temporality : Format.formatter -> Metrics_types.aggregation_temporality -> unit (** [pp_aggregation_temporality v] formats v *) -val pp_exponential_histogram : Format.formatter -> Metrics_types.exponential_histogram -> unit -(** [pp_exponential_histogram v] formats v *) +val pp_sum : Format.formatter -> Metrics_types.sum -> unit +(** [pp_sum v] formats v *) val pp_histogram_data_point : Format.formatter -> Metrics_types.histogram_data_point -> unit (** [pp_histogram_data_point v] formats v *) @@ -37,17 +30,23 @@ val pp_histogram_data_point : Format.formatter -> Metrics_types.histogram_data_p val pp_histogram : Format.formatter -> Metrics_types.histogram -> unit (** [pp_histogram v] formats v *) -val pp_number_data_point_value : Format.formatter -> Metrics_types.number_data_point_value -> unit -(** [pp_number_data_point_value v] formats v *) +val pp_exponential_histogram_data_point_buckets : Format.formatter -> Metrics_types.exponential_histogram_data_point_buckets -> unit +(** [pp_exponential_histogram_data_point_buckets v] formats v *) -val pp_number_data_point : Format.formatter -> Metrics_types.number_data_point -> unit -(** [pp_number_data_point v] formats v *) +val pp_exponential_histogram_data_point : Format.formatter -> Metrics_types.exponential_histogram_data_point -> unit +(** [pp_exponential_histogram_data_point v] formats v *) -val pp_sum : Format.formatter -> Metrics_types.sum -> unit -(** [pp_sum v] formats v *) +val pp_exponential_histogram : Format.formatter -> Metrics_types.exponential_histogram -> unit +(** [pp_exponential_histogram v] formats v *) -val pp_gauge : Format.formatter -> Metrics_types.gauge -> unit -(** [pp_gauge v] formats v *) +val pp_summary_data_point_value_at_quantile : Format.formatter -> Metrics_types.summary_data_point_value_at_quantile -> unit +(** [pp_summary_data_point_value_at_quantile v] formats v *) + +val pp_summary_data_point : Format.formatter -> Metrics_types.summary_data_point -> unit +(** [pp_summary_data_point v] formats v *) + +val pp_summary : Format.formatter -> Metrics_types.summary -> unit +(** [pp_summary v] formats v *) val pp_metric_data : Format.formatter -> Metrics_types.metric_data -> unit (** [pp_metric_data v] formats v *) diff --git a/src/proto/metrics_service_pp.mli b/src/proto/metrics_service_pp.mli index c9b5ed6f..90301da8 100644 --- a/src/proto/metrics_service_pp.mli +++ b/src/proto/metrics_service_pp.mli @@ -1,4 +1,3 @@ - (** metrics_service.proto Pretty Printing *) diff --git a/src/proto/metrics_types.ml b/src/proto/metrics_types.ml index d238843c..4cd9c09e 100644 --- a/src/proto/metrics_types.ml +++ b/src/proto/metrics_types.ml @@ -1,33 +1,9 @@ [@@@ocaml.warning "-27-30-39"] -type summary_data_point_value_at_quantile = { - quantile : float; - value : float; -} - -type summary_data_point = { - attributes : Common_types.key_value list; - start_time_unix_nano : int64; - time_unix_nano : int64; - count : int64; - sum : float; - quantile_values : summary_data_point_value_at_quantile list; - flags : int32; -} - -type summary = { - data_points : summary_data_point list; -} - -type exponential_histogram_data_point_buckets = { - offset : int32; - bucket_counts : int64 list; -} - type exemplar_value = - | As_int of int64 | As_double of float + | As_int of int64 and exemplar = { filtered_attributes : Common_types.key_value list; @@ -37,21 +13,21 @@ and exemplar = { trace_id : bytes; } -type exponential_histogram_data_point = { +type number_data_point_value = + | As_double of float + | As_int of int64 + +and number_data_point = { attributes : Common_types.key_value list; start_time_unix_nano : int64; time_unix_nano : int64; - count : int64; - sum : float option; - scale : int32; - zero_count : int64; - positive : exponential_histogram_data_point_buckets option; - negative : exponential_histogram_data_point_buckets option; - flags : int32; + value : number_data_point_value; exemplars : exemplar list; - min : float option; - max : float option; - zero_threshold : float; + flags : int32; +} + +type gauge = { + data_points : number_data_point list; } type aggregation_temporality = @@ -59,9 +35,10 @@ type aggregation_temporality = | Aggregation_temporality_delta | Aggregation_temporality_cumulative -type exponential_histogram = { - data_points : exponential_histogram_data_point list; +type sum = { + data_points : number_data_point list; aggregation_temporality : aggregation_temporality; + is_monotonic : bool; } type histogram_data_point = { @@ -83,35 +60,58 @@ type histogram = { aggregation_temporality : aggregation_temporality; } -type number_data_point_value = - | As_int of int64 - | As_double of float +type exponential_histogram_data_point_buckets = { + offset : int32; + bucket_counts : int64 list; +} -and number_data_point = { +type exponential_histogram_data_point = { attributes : Common_types.key_value list; start_time_unix_nano : int64; time_unix_nano : int64; - value : number_data_point_value; - exemplars : exemplar list; + count : int64; + sum : float option; + scale : int32; + zero_count : int64; + positive : exponential_histogram_data_point_buckets option; + negative : exponential_histogram_data_point_buckets option; flags : int32; + exemplars : exemplar list; + min : float option; + max : float option; + zero_threshold : float; } -type sum = { - data_points : number_data_point list; +type exponential_histogram = { + data_points : exponential_histogram_data_point list; aggregation_temporality : aggregation_temporality; - is_monotonic : bool; } -type gauge = { - data_points : number_data_point list; +type summary_data_point_value_at_quantile = { + quantile : float; + value : float; +} + +type summary_data_point = { + attributes : Common_types.key_value list; + start_time_unix_nano : int64; + time_unix_nano : int64; + count : int64; + sum : float; + quantile_values : summary_data_point_value_at_quantile list; + flags : int32; +} + +type summary = { + data_points : summary_data_point list; } type metric_data = - | Summary of summary - | Exponential_histogram of exponential_histogram - | Histogram of histogram - | Sum of sum | Gauge of gauge + | Sum of sum + | Histogram of histogram + | Exponential_histogram of exponential_histogram + | Summary of summary and metric = { name : string; @@ -140,52 +140,12 @@ type data_point_flags = | Data_point_flags_do_not_use | Data_point_flags_no_recorded_value_mask -let rec default_summary_data_point_value_at_quantile - ?quantile:((quantile:float) = 0.) - ?value:((value:float) = 0.) - () : summary_data_point_value_at_quantile = { - quantile; - value; -} - -let rec default_summary_data_point - ?attributes:((attributes:Common_types.key_value list) = []) - ?start_time_unix_nano:((start_time_unix_nano:int64) = 0L) - ?time_unix_nano:((time_unix_nano:int64) = 0L) - ?count:((count:int64) = 0L) - ?sum:((sum:float) = 0.) - ?quantile_values:((quantile_values:summary_data_point_value_at_quantile list) = []) - ?flags:((flags:int32) = 0l) - () : summary_data_point = { - attributes; - start_time_unix_nano; - time_unix_nano; - count; - sum; - quantile_values; - flags; -} - -let rec default_summary - ?data_points:((data_points:summary_data_point list) = []) - () : summary = { - data_points; -} - -let rec default_exponential_histogram_data_point_buckets - ?offset:((offset:int32) = 0l) - ?bucket_counts:((bucket_counts:int64 list) = []) - () : exponential_histogram_data_point_buckets = { - offset; - bucket_counts; -} - -let rec default_exemplar_value () : exemplar_value = As_int (0L) +let rec default_exemplar_value () : exemplar_value = As_double (0.) and default_exemplar ?filtered_attributes:((filtered_attributes:Common_types.key_value list) = []) ?time_unix_nano:((time_unix_nano:int64) = 0L) - ?value:((value:exemplar_value) = As_int (0L)) + ?value:((value:exemplar_value) = As_double (0.)) ?span_id:((span_id:bytes) = Bytes.create 0) ?trace_id:((trace_id:bytes) = Bytes.create 0) () : exemplar = { @@ -196,46 +156,40 @@ and default_exemplar trace_id; } -let rec default_exponential_histogram_data_point +let rec default_number_data_point_value () : number_data_point_value = As_double (0.) + +and default_number_data_point ?attributes:((attributes:Common_types.key_value list) = []) ?start_time_unix_nano:((start_time_unix_nano:int64) = 0L) ?time_unix_nano:((time_unix_nano:int64) = 0L) - ?count:((count:int64) = 0L) - ?sum:((sum:float option) = None) - ?scale:((scale:int32) = 0l) - ?zero_count:((zero_count:int64) = 0L) - ?positive:((positive:exponential_histogram_data_point_buckets option) = None) - ?negative:((negative:exponential_histogram_data_point_buckets option) = None) - ?flags:((flags:int32) = 0l) + ?value:((value:number_data_point_value) = As_double (0.)) ?exemplars:((exemplars:exemplar list) = []) - ?min:((min:float option) = None) - ?max:((max:float option) = None) - ?zero_threshold:((zero_threshold:float) = 0.) - () : exponential_histogram_data_point = { + ?flags:((flags:int32) = 0l) + () : number_data_point = { attributes; start_time_unix_nano; time_unix_nano; - count; - sum; - scale; - zero_count; - positive; - negative; - flags; + value; exemplars; - min; - max; - zero_threshold; + flags; +} + +let rec default_gauge + ?data_points:((data_points:number_data_point list) = []) + () : gauge = { + data_points; } let rec default_aggregation_temporality () = (Aggregation_temporality_unspecified:aggregation_temporality) -let rec default_exponential_histogram - ?data_points:((data_points:exponential_histogram_data_point list) = []) +let rec default_sum + ?data_points:((data_points:number_data_point list) = []) ?aggregation_temporality:((aggregation_temporality:aggregation_temporality) = default_aggregation_temporality ()) - () : exponential_histogram = { + ?is_monotonic:((is_monotonic:bool) = false) + () : sum = { data_points; aggregation_temporality; + is_monotonic; } let rec default_histogram_data_point @@ -272,47 +226,93 @@ let rec default_histogram aggregation_temporality; } -let rec default_number_data_point_value () : number_data_point_value = As_int (0L) +let rec default_exponential_histogram_data_point_buckets + ?offset:((offset:int32) = 0l) + ?bucket_counts:((bucket_counts:int64 list) = []) + () : exponential_histogram_data_point_buckets = { + offset; + bucket_counts; +} -and default_number_data_point +let rec default_exponential_histogram_data_point ?attributes:((attributes:Common_types.key_value list) = []) ?start_time_unix_nano:((start_time_unix_nano:int64) = 0L) ?time_unix_nano:((time_unix_nano:int64) = 0L) - ?value:((value:number_data_point_value) = As_int (0L)) - ?exemplars:((exemplars:exemplar list) = []) + ?count:((count:int64) = 0L) + ?sum:((sum:float option) = None) + ?scale:((scale:int32) = 0l) + ?zero_count:((zero_count:int64) = 0L) + ?positive:((positive:exponential_histogram_data_point_buckets option) = None) + ?negative:((negative:exponential_histogram_data_point_buckets option) = None) ?flags:((flags:int32) = 0l) - () : number_data_point = { + ?exemplars:((exemplars:exemplar list) = []) + ?min:((min:float option) = None) + ?max:((max:float option) = None) + ?zero_threshold:((zero_threshold:float) = 0.) + () : exponential_histogram_data_point = { attributes; start_time_unix_nano; time_unix_nano; - value; - exemplars; + count; + sum; + scale; + zero_count; + positive; + negative; flags; + exemplars; + min; + max; + zero_threshold; } -let rec default_sum - ?data_points:((data_points:number_data_point list) = []) +let rec default_exponential_histogram + ?data_points:((data_points:exponential_histogram_data_point list) = []) ?aggregation_temporality:((aggregation_temporality:aggregation_temporality) = default_aggregation_temporality ()) - ?is_monotonic:((is_monotonic:bool) = false) - () : sum = { + () : exponential_histogram = { data_points; aggregation_temporality; - is_monotonic; } -let rec default_gauge - ?data_points:((data_points:number_data_point list) = []) - () : gauge = { +let rec default_summary_data_point_value_at_quantile + ?quantile:((quantile:float) = 0.) + ?value:((value:float) = 0.) + () : summary_data_point_value_at_quantile = { + quantile; + value; +} + +let rec default_summary_data_point + ?attributes:((attributes:Common_types.key_value list) = []) + ?start_time_unix_nano:((start_time_unix_nano:int64) = 0L) + ?time_unix_nano:((time_unix_nano:int64) = 0L) + ?count:((count:int64) = 0L) + ?sum:((sum:float) = 0.) + ?quantile_values:((quantile_values:summary_data_point_value_at_quantile list) = []) + ?flags:((flags:int32) = 0l) + () : summary_data_point = { + attributes; + start_time_unix_nano; + time_unix_nano; + count; + sum; + quantile_values; + flags; +} + +let rec default_summary + ?data_points:((data_points:summary_data_point list) = []) + () : summary = { data_points; } -let rec default_metric_data () : metric_data = Summary (default_summary ()) +let rec default_metric_data () : metric_data = Gauge (default_gauge ()) and default_metric ?name:((name:string) = "") ?description:((description:string) = "") ?unit_:((unit_:string) = "") - ?data:((data:metric_data) = Summary (default_summary ())) + ?data:((data:metric_data) = Gauge (default_gauge ())) () : metric = { name; description; diff --git a/src/proto/metrics_types.mli b/src/proto/metrics_types.mli index 17471582..8cf43dbf 100644 --- a/src/proto/metrics_types.mli +++ b/src/proto/metrics_types.mli @@ -4,33 +4,9 @@ (** {2 Types} *) -type summary_data_point_value_at_quantile = { - quantile : float; - value : float; -} - -type summary_data_point = { - attributes : Common_types.key_value list; - start_time_unix_nano : int64; - time_unix_nano : int64; - count : int64; - sum : float; - quantile_values : summary_data_point_value_at_quantile list; - flags : int32; -} - -type summary = { - data_points : summary_data_point list; -} - -type exponential_histogram_data_point_buckets = { - offset : int32; - bucket_counts : int64 list; -} - type exemplar_value = - | As_int of int64 | As_double of float + | As_int of int64 and exemplar = { filtered_attributes : Common_types.key_value list; @@ -40,21 +16,21 @@ and exemplar = { trace_id : bytes; } -type exponential_histogram_data_point = { +type number_data_point_value = + | As_double of float + | As_int of int64 + +and number_data_point = { attributes : Common_types.key_value list; start_time_unix_nano : int64; time_unix_nano : int64; - count : int64; - sum : float option; - scale : int32; - zero_count : int64; - positive : exponential_histogram_data_point_buckets option; - negative : exponential_histogram_data_point_buckets option; - flags : int32; + value : number_data_point_value; exemplars : exemplar list; - min : float option; - max : float option; - zero_threshold : float; + flags : int32; +} + +type gauge = { + data_points : number_data_point list; } type aggregation_temporality = @@ -62,9 +38,10 @@ type aggregation_temporality = | Aggregation_temporality_delta | Aggregation_temporality_cumulative -type exponential_histogram = { - data_points : exponential_histogram_data_point list; +type sum = { + data_points : number_data_point list; aggregation_temporality : aggregation_temporality; + is_monotonic : bool; } type histogram_data_point = { @@ -86,35 +63,58 @@ type histogram = { aggregation_temporality : aggregation_temporality; } -type number_data_point_value = - | As_int of int64 - | As_double of float +type exponential_histogram_data_point_buckets = { + offset : int32; + bucket_counts : int64 list; +} -and number_data_point = { +type exponential_histogram_data_point = { attributes : Common_types.key_value list; start_time_unix_nano : int64; time_unix_nano : int64; - value : number_data_point_value; - exemplars : exemplar list; + count : int64; + sum : float option; + scale : int32; + zero_count : int64; + positive : exponential_histogram_data_point_buckets option; + negative : exponential_histogram_data_point_buckets option; flags : int32; + exemplars : exemplar list; + min : float option; + max : float option; + zero_threshold : float; } -type sum = { - data_points : number_data_point list; +type exponential_histogram = { + data_points : exponential_histogram_data_point list; aggregation_temporality : aggregation_temporality; - is_monotonic : bool; } -type gauge = { - data_points : number_data_point list; +type summary_data_point_value_at_quantile = { + quantile : float; + value : float; +} + +type summary_data_point = { + attributes : Common_types.key_value list; + start_time_unix_nano : int64; + time_unix_nano : int64; + count : int64; + sum : float; + quantile_values : summary_data_point_value_at_quantile list; + flags : int32; +} + +type summary = { + data_points : summary_data_point list; } type metric_data = - | Summary of summary - | Exponential_histogram of exponential_histogram - | Histogram of histogram - | Sum of sum | Gauge of gauge + | Sum of sum + | Histogram of histogram + | Exponential_histogram of exponential_histogram + | Summary of summary and metric = { name : string; @@ -146,38 +146,6 @@ type data_point_flags = (** {2 Default values} *) -val default_summary_data_point_value_at_quantile : - ?quantile:float -> - ?value:float -> - unit -> - summary_data_point_value_at_quantile -(** [default_summary_data_point_value_at_quantile ()] is the default value for type [summary_data_point_value_at_quantile] *) - -val default_summary_data_point : - ?attributes:Common_types.key_value list -> - ?start_time_unix_nano:int64 -> - ?time_unix_nano:int64 -> - ?count:int64 -> - ?sum:float -> - ?quantile_values:summary_data_point_value_at_quantile list -> - ?flags:int32 -> - unit -> - summary_data_point -(** [default_summary_data_point ()] is the default value for type [summary_data_point] *) - -val default_summary : - ?data_points:summary_data_point list -> - unit -> - summary -(** [default_summary ()] is the default value for type [summary] *) - -val default_exponential_histogram_data_point_buckets : - ?offset:int32 -> - ?bucket_counts:int64 list -> - unit -> - exponential_histogram_data_point_buckets -(** [default_exponential_histogram_data_point_buckets ()] is the default value for type [exponential_histogram_data_point_buckets] *) - val default_exemplar_value : unit -> exemplar_value (** [default_exemplar_value ()] is the default value for type [exemplar_value] *) @@ -191,34 +159,36 @@ val default_exemplar : exemplar (** [default_exemplar ()] is the default value for type [exemplar] *) -val default_exponential_histogram_data_point : +val default_number_data_point_value : unit -> number_data_point_value +(** [default_number_data_point_value ()] is the default value for type [number_data_point_value] *) + +val default_number_data_point : ?attributes:Common_types.key_value list -> ?start_time_unix_nano:int64 -> ?time_unix_nano:int64 -> - ?count:int64 -> - ?sum:float option -> - ?scale:int32 -> - ?zero_count:int64 -> - ?positive:exponential_histogram_data_point_buckets option -> - ?negative:exponential_histogram_data_point_buckets option -> - ?flags:int32 -> + ?value:number_data_point_value -> ?exemplars:exemplar list -> - ?min:float option -> - ?max:float option -> - ?zero_threshold:float -> + ?flags:int32 -> unit -> - exponential_histogram_data_point -(** [default_exponential_histogram_data_point ()] is the default value for type [exponential_histogram_data_point] *) + number_data_point +(** [default_number_data_point ()] is the default value for type [number_data_point] *) + +val default_gauge : + ?data_points:number_data_point list -> + unit -> + gauge +(** [default_gauge ()] is the default value for type [gauge] *) val default_aggregation_temporality : unit -> aggregation_temporality (** [default_aggregation_temporality ()] is the default value for type [aggregation_temporality] *) -val default_exponential_histogram : - ?data_points:exponential_histogram_data_point list -> +val default_sum : + ?data_points:number_data_point list -> ?aggregation_temporality:aggregation_temporality -> + ?is_monotonic:bool -> unit -> - exponential_histogram -(** [default_exponential_histogram ()] is the default value for type [exponential_histogram] *) + sum +(** [default_sum ()] is the default value for type [sum] *) val default_histogram_data_point : ?attributes:Common_types.key_value list -> @@ -243,33 +213,63 @@ val default_histogram : histogram (** [default_histogram ()] is the default value for type [histogram] *) -val default_number_data_point_value : unit -> number_data_point_value -(** [default_number_data_point_value ()] is the default value for type [number_data_point_value] *) +val default_exponential_histogram_data_point_buckets : + ?offset:int32 -> + ?bucket_counts:int64 list -> + unit -> + exponential_histogram_data_point_buckets +(** [default_exponential_histogram_data_point_buckets ()] is the default value for type [exponential_histogram_data_point_buckets] *) -val default_number_data_point : +val default_exponential_histogram_data_point : ?attributes:Common_types.key_value list -> ?start_time_unix_nano:int64 -> ?time_unix_nano:int64 -> - ?value:number_data_point_value -> - ?exemplars:exemplar list -> + ?count:int64 -> + ?sum:float option -> + ?scale:int32 -> + ?zero_count:int64 -> + ?positive:exponential_histogram_data_point_buckets option -> + ?negative:exponential_histogram_data_point_buckets option -> ?flags:int32 -> + ?exemplars:exemplar list -> + ?min:float option -> + ?max:float option -> + ?zero_threshold:float -> unit -> - number_data_point -(** [default_number_data_point ()] is the default value for type [number_data_point] *) + exponential_histogram_data_point +(** [default_exponential_histogram_data_point ()] is the default value for type [exponential_histogram_data_point] *) -val default_sum : - ?data_points:number_data_point list -> +val default_exponential_histogram : + ?data_points:exponential_histogram_data_point list -> ?aggregation_temporality:aggregation_temporality -> - ?is_monotonic:bool -> unit -> - sum -(** [default_sum ()] is the default value for type [sum] *) + exponential_histogram +(** [default_exponential_histogram ()] is the default value for type [exponential_histogram] *) -val default_gauge : - ?data_points:number_data_point list -> +val default_summary_data_point_value_at_quantile : + ?quantile:float -> + ?value:float -> unit -> - gauge -(** [default_gauge ()] is the default value for type [gauge] *) + summary_data_point_value_at_quantile +(** [default_summary_data_point_value_at_quantile ()] is the default value for type [summary_data_point_value_at_quantile] *) + +val default_summary_data_point : + ?attributes:Common_types.key_value list -> + ?start_time_unix_nano:int64 -> + ?time_unix_nano:int64 -> + ?count:int64 -> + ?sum:float -> + ?quantile_values:summary_data_point_value_at_quantile list -> + ?flags:int32 -> + unit -> + summary_data_point +(** [default_summary_data_point ()] is the default value for type [summary_data_point] *) + +val default_summary : + ?data_points:summary_data_point list -> + unit -> + summary +(** [default_summary ()] is the default value for type [summary] *) val default_metric_data : unit -> metric_data (** [default_metric_data ()] is the default value for type [metric_data] *) diff --git a/src/proto/resource_pp.mli b/src/proto/resource_pp.mli index f18aa338..60d1f43a 100644 --- a/src/proto/resource_pp.mli +++ b/src/proto/resource_pp.mli @@ -1,4 +1,3 @@ - (** resource.proto Pretty Printing *) diff --git a/src/proto/status_pp.mli b/src/proto/status_pp.mli index 3333057d..cb19e3bd 100644 --- a/src/proto/status_pp.mli +++ b/src/proto/status_pp.mli @@ -1,4 +1,3 @@ - (** status.proto Pretty Printing *) diff --git a/src/proto/trace_pp.mli b/src/proto/trace_pp.mli index ea7ffdc9..047f5207 100644 --- a/src/proto/trace_pp.mli +++ b/src/proto/trace_pp.mli @@ -1,4 +1,3 @@ - (** trace.proto Pretty Printing *) diff --git a/src/proto/trace_service_pp.mli b/src/proto/trace_service_pp.mli index 63b19223..d7d52f99 100644 --- a/src/proto/trace_service_pp.mli +++ b/src/proto/trace_service_pp.mli @@ -1,4 +1,3 @@ - (** trace_service.proto Pretty Printing *)