From e052893759885b28f96826a392e88c0fe0a4e45f Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Thu, 14 Dec 2023 20:48:46 -0500 Subject: [PATCH 1/6] bench: add counter --- tests/bin/emit1.ml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/bin/emit1.ml b/tests/bin/emit1.ml index 35f16423..179ddc78 100644 --- a/tests/bin/emit1.ml +++ b/tests/bin/emit1.ml @@ -11,6 +11,8 @@ let sleep_outer = ref 2.0 let n_jobs = ref 1 +let n = ref max_int + let num_sleep = Atomic.make 0 let stress_alloc_ = ref true @@ -22,13 +24,18 @@ let num_tr = Atomic.make 0 let run_job () = let@ () = Fun.protect ~finally:(fun () -> Atomic.set stop true) in let i = ref 0 in - while not @@ Atomic.get stop do + let cnt = ref 0 in + + while (not @@ Atomic.get stop) && !cnt < !n do let@ _scope = Atomic.incr num_tr; T.Trace.with_ ~kind:T.Span.Span_kind_producer "loop.outer" ~attrs:[ "i", `Int !i ] in + (* Printf.printf "cnt=%d\n%!" !cnt; *) + incr cnt; + for j = 0 to 4 do (* parent scope is found via thread local storage *) let@ scope = @@ -109,6 +116,7 @@ let () = "--sleep-outer", Arg.Set_float sleep_outer, " sleep (in s) in outer loop"; "-j", Arg.Set_int n_jobs, " number of parallel jobs"; "--bg-threads", Arg.Set_int n_bg_threads, " number of background threads"; + "-n", Arg.Set_int n, " number of iterations (default ∞)"; ] |> Arg.align in From 725a806b8b560eeb8e027efc3bd5d273c62383d3 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Mon, 11 Dec 2023 15:42:36 -0500 Subject: [PATCH 2/6] migrate to ocaml-protoc 3.0 --- dune-project | 10 +- opentelemetry-client-cohttp-lwt.opam | 5 +- opentelemetry-client-ocurl.opam | 5 +- opentelemetry-cohttp-lwt.opam | 4 +- opentelemetry-lwt.opam | 4 +- opentelemetry.opam | 8 +- src/proto/common.ml | 372 +++++ src/proto/common.mli | 160 ++ src/proto/common_pb.ml | 224 --- src/proto/common_pb.mli | 37 - src/proto/common_pp.ml | 39 - src/proto/common_pp.mli | 19 - src/proto/common_types.ml | 65 - src/proto/common_types.mli | 68 - src/proto/dune | 46 +- src/proto/logs.ml | 598 ++++++++ src/proto/logs.mli | 222 +++ src/proto/logs_pb.ml | 348 ----- src/proto/logs_pb.mli | 43 - src/proto/logs_pp.ml | 71 - src/proto/logs_pp.mli | 22 - src/proto/logs_service.ml | 243 ++++ src/proto/logs_service.mli | 122 ++ 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 | 13 - 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.ml | 2022 ++++++++++++++++++++++++++ src/proto/metrics.mli | 668 +++++++++ src/proto/metrics_pb.ml | 1282 ---------------- src/proto/metrics_pb.mli | 133 -- src/proto/metrics_pp.ml | 177 --- src/proto/metrics_pp.mli | 67 - src/proto/metrics_service.ml | 243 ++++ src/proto/metrics_service.mli | 122 ++ 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 | 13 - 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.ml | 88 ++ src/proto/resource.mli | 54 + src/proto/resource_pb.ml | 46 - src/proto/resource_pb.mli | 13 - src/proto/resource_pp.ml | 8 - src/proto/resource_pp.mli | 7 - src/proto/resource_types.ml | 15 - src/proto/resource_types.mli | 20 - src/proto/status.ml | 104 ++ src/proto/status.mli | 57 + src/proto/status_pb.ml | 56 - src/proto/status_pb.mli | 13 - src/proto/status_pp.ml | 9 - src/proto/status_pp.mli | 7 - src/proto/status_types.ml | 18 - src/proto/status_types.mli | 22 - src/proto/trace.ml | 905 ++++++++++++ src/proto/trace.mli | 318 ++++ src/proto/trace_pb.ml | 547 ------- src/proto/trace_pb.mli | 61 - src/proto/trace_pp.ml | 84 -- src/proto/trace_pp.mli | 31 - src/proto/trace_service.ml | 243 ++++ src/proto/trace_service.mli | 122 ++ 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 | 13 - 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 -- 79 files changed, 6701 insertions(+), 5532 deletions(-) create mode 100644 src/proto/common.ml create mode 100644 src/proto/common.mli delete mode 100644 src/proto/common_pb.ml delete mode 100644 src/proto/common_pb.mli delete mode 100644 src/proto/common_pp.ml delete mode 100644 src/proto/common_pp.mli delete mode 100644 src/proto/common_types.ml delete mode 100644 src/proto/common_types.mli create mode 100644 src/proto/logs.ml create mode 100644 src/proto/logs.mli delete mode 100644 src/proto/logs_pb.ml delete mode 100644 src/proto/logs_pb.mli delete mode 100644 src/proto/logs_pp.ml delete mode 100644 src/proto/logs_pp.mli create mode 100644 src/proto/logs_service.ml create mode 100644 src/proto/logs_service.mli delete mode 100644 src/proto/logs_service_pb.ml delete mode 100644 src/proto/logs_service_pb.mli delete mode 100644 src/proto/logs_service_pp.ml delete mode 100644 src/proto/logs_service_pp.mli delete mode 100644 src/proto/logs_service_types.ml delete mode 100644 src/proto/logs_service_types.mli delete mode 100644 src/proto/logs_types.ml delete mode 100644 src/proto/logs_types.mli create mode 100644 src/proto/metrics.ml create mode 100644 src/proto/metrics.mli delete mode 100644 src/proto/metrics_pb.ml delete mode 100644 src/proto/metrics_pb.mli delete mode 100644 src/proto/metrics_pp.ml delete mode 100644 src/proto/metrics_pp.mli create mode 100644 src/proto/metrics_service.ml create mode 100644 src/proto/metrics_service.mli delete mode 100644 src/proto/metrics_service_pb.ml delete mode 100644 src/proto/metrics_service_pb.mli delete mode 100644 src/proto/metrics_service_pp.ml delete mode 100644 src/proto/metrics_service_pp.mli delete mode 100644 src/proto/metrics_service_types.ml delete mode 100644 src/proto/metrics_service_types.mli delete mode 100644 src/proto/metrics_types.ml delete mode 100644 src/proto/metrics_types.mli create mode 100644 src/proto/resource.ml create mode 100644 src/proto/resource.mli delete mode 100644 src/proto/resource_pb.ml delete mode 100644 src/proto/resource_pb.mli delete mode 100644 src/proto/resource_pp.ml delete mode 100644 src/proto/resource_pp.mli delete mode 100644 src/proto/resource_types.ml delete mode 100644 src/proto/resource_types.mli create mode 100644 src/proto/status.ml create mode 100644 src/proto/status.mli delete mode 100644 src/proto/status_pb.ml delete mode 100644 src/proto/status_pb.mli delete mode 100644 src/proto/status_pp.ml delete mode 100644 src/proto/status_pp.mli delete mode 100644 src/proto/status_types.ml delete mode 100644 src/proto/status_types.mli create mode 100644 src/proto/trace.ml create mode 100644 src/proto/trace.mli delete mode 100644 src/proto/trace_pb.ml delete mode 100644 src/proto/trace_pb.mli delete mode 100644 src/proto/trace_pp.ml delete mode 100644 src/proto/trace_pp.mli create mode 100644 src/proto/trace_service.ml create mode 100644 src/proto/trace_service.mli delete mode 100644 src/proto/trace_service_pb.ml delete mode 100644 src/proto/trace_service_pb.mli delete mode 100644 src/proto/trace_service_pp.ml delete mode 100644 src/proto/trace_service_pp.mli delete mode 100644 src/proto/trace_service_types.ml delete mode 100644 src/proto/trace_service_types.mli delete mode 100644 src/proto/trace_types.ml delete mode 100644 src/proto/trace_types.mli diff --git a/dune-project b/dune-project index 7b98398e..292008ba 100644 --- a/dune-project +++ b/dune-project @@ -1,4 +1,4 @@ -(lang dune 2.7) +(lang dune 2.9) (name opentelemetry) @@ -31,7 +31,7 @@ (odoc :with-doc) (alcotest :with-test) (pbrt - (and (>= 2.3) (< 3.0))) + (and (>= 3.0) (< 4.0))) (ocaml-lsp-server :with-dev-setup) (ocamlformat (and @@ -43,7 +43,7 @@ (trace (or (< 0.4) - (>= 0.5)))) + (>= 0.6)))) (tags (instrumentation tracing opentelemetry datadog jaeger))) @@ -77,8 +77,6 @@ ; atomic ; vendored (opentelemetry (= :version)) - (pbrt - (and (>= 2.3) (< 3.0))) (odoc :with-doc) (ezcurl (>= 0.2.3)) @@ -113,8 +111,6 @@ ; for spans (opentelemetry (= :version)) - (pbrt - (and (>= 2.2) (< 3.0))) (odoc :with-doc) (lwt (>= "5.3")) diff --git a/opentelemetry-client-cohttp-lwt.opam b/opentelemetry-client-cohttp-lwt.opam index bcaf7adb..a9b605ac 100644 --- a/opentelemetry-client-cohttp-lwt.opam +++ b/opentelemetry-client-cohttp-lwt.opam @@ -12,11 +12,10 @@ license: "MIT" homepage: "https://github.com/imandra-ai/ocaml-opentelemetry" bug-reports: "https://github.com/imandra-ai/ocaml-opentelemetry/issues" depends: [ - "dune" {>= "2.7"} + "dune" {>= "2.9"} "ocaml" {>= "4.08"} "mtime" {>= "1.4"} "opentelemetry" {= version} - "pbrt" {>= "2.2" & < "3.0"} "odoc" {with-doc} "lwt" {>= "5.3"} "lwt_ppx" {>= "2.0"} @@ -33,9 +32,11 @@ build: [ name "-j" jobs + "--promote-install-files=false" "@install" "@runtest" {with-test} "@doc" {with-doc} ] + ["dune" "install" "-p" name "--create-install-files" name] ] dev-repo: "git+https://github.com/imandra-ai/ocaml-opentelemetry.git" diff --git a/opentelemetry-client-ocurl.opam b/opentelemetry-client-ocurl.opam index 1fbef60b..95ac3e33 100644 --- a/opentelemetry-client-ocurl.opam +++ b/opentelemetry-client-ocurl.opam @@ -12,11 +12,10 @@ license: "MIT" homepage: "https://github.com/imandra-ai/ocaml-opentelemetry" bug-reports: "https://github.com/imandra-ai/ocaml-opentelemetry/issues" depends: [ - "dune" {>= "2.7"} + "dune" {>= "2.9"} "ocaml" {>= "4.08"} "mtime" {>= "1.4"} "opentelemetry" {= version} - "pbrt" {>= "2.3" & < "3.0"} "odoc" {with-doc} "ezcurl" {>= "0.2.3"} "ocurl" @@ -31,9 +30,11 @@ build: [ name "-j" jobs + "--promote-install-files=false" "@install" "@runtest" {with-test} "@doc" {with-doc} ] + ["dune" "install" "-p" name "--create-install-files" name] ] dev-repo: "git+https://github.com/imandra-ai/ocaml-opentelemetry.git" diff --git a/opentelemetry-cohttp-lwt.opam b/opentelemetry-cohttp-lwt.opam index 20c5321a..1a94cada 100644 --- a/opentelemetry-cohttp-lwt.opam +++ b/opentelemetry-cohttp-lwt.opam @@ -12,7 +12,7 @@ license: "MIT" homepage: "https://github.com/imandra-ai/ocaml-opentelemetry" bug-reports: "https://github.com/imandra-ai/ocaml-opentelemetry/issues" depends: [ - "dune" {>= "2.7"} + "dune" {>= "2.9"} "ocaml" {>= "4.08"} "opentelemetry" {= version} "opentelemetry-lwt" {= version} @@ -30,9 +30,11 @@ build: [ name "-j" jobs + "--promote-install-files=false" "@install" "@runtest" {with-test} "@doc" {with-doc} ] + ["dune" "install" "-p" name "--create-install-files" name] ] dev-repo: "git+https://github.com/imandra-ai/ocaml-opentelemetry.git" diff --git a/opentelemetry-lwt.opam b/opentelemetry-lwt.opam index a03196a2..ed0f50b8 100644 --- a/opentelemetry-lwt.opam +++ b/opentelemetry-lwt.opam @@ -13,7 +13,7 @@ tags: ["instrumentation" "tracing" "opentelemetry" "datadog" "lwt"] homepage: "https://github.com/imandra-ai/ocaml-opentelemetry" bug-reports: "https://github.com/imandra-ai/ocaml-opentelemetry/issues" depends: [ - "dune" {>= "2.7"} + "dune" {>= "2.9"} "ocaml" {>= "4.08"} "ambient-context" "opentelemetry" {= version} @@ -32,9 +32,11 @@ build: [ name "-j" jobs + "--promote-install-files=false" "@install" "@runtest" {with-test} "@doc" {with-doc} ] + ["dune" "install" "-p" name "--create-install-files" name] ] dev-repo: "git+https://github.com/imandra-ai/ocaml-opentelemetry.git" diff --git a/opentelemetry.opam b/opentelemetry.opam index 0a181143..ed6c9fca 100644 --- a/opentelemetry.opam +++ b/opentelemetry.opam @@ -13,19 +13,19 @@ tags: ["instrumentation" "tracing" "opentelemetry" "datadog" "jaeger"] homepage: "https://github.com/imandra-ai/ocaml-opentelemetry" bug-reports: "https://github.com/imandra-ai/ocaml-opentelemetry/issues" depends: [ - "dune" {>= "2.7"} + "dune" {>= "2.9"} "ocaml" {>= "4.08"} "ptime" "ambient-context" "odoc" {with-doc} "alcotest" {with-test} - "pbrt" {>= "2.3" & < "3.0"} + "pbrt" {>= "3.0" & < "4.0"} "ocaml-lsp-server" {with-dev-setup} "ocamlformat" {with-dev-setup & >= "0.24" & < "0.25"} ] depopts: ["trace"] conflicts: [ - "trace" {< "0.4" | >= "0.5"} + "trace" {< "0.4" | >= "0.6"} ] build: [ ["dune" "subst"] {dev} @@ -36,9 +36,11 @@ build: [ name "-j" jobs + "--promote-install-files=false" "@install" "@runtest" {with-test} "@doc" {with-doc} ] + ["dune" "install" "-p" name "--create-install-files" name] ] dev-repo: "git+https://github.com/imandra-ai/ocaml-opentelemetry.git" diff --git a/src/proto/common.ml b/src/proto/common.ml new file mode 100644 index 00000000..b0faafa5 --- /dev/null +++ b/src/proto/common.ml @@ -0,0 +1,372 @@ +[@@@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; +} + +type array_value_mutable = { + mutable values : any_value list; +} + +let default_array_value_mutable () : array_value_mutable = { + values = []; +} + +type key_value_list_mutable = { + mutable values : key_value list; +} + +let default_key_value_list_mutable () : key_value_list_mutable = { + values = []; +} + +type key_value_mutable = { + mutable key : string; + mutable value : 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 : key_value list; + mutable dropped_attributes_count : int32; +} + +let default_instrumentation_scope_mutable () : instrumentation_scope_mutable = { + name = ""; + version = ""; + attributes = []; + dropped_attributes_count = 0l; +} + + +(** {2 Make functions} *) + + +let rec make_array_value + ~(values:any_value list) + () : array_value = { + values; +} + +and make_key_value_list + ~(values:key_value list) + () : key_value_list = { + values; +} + +and make_key_value + ~(key:string) + ?value:((value:any_value option) = None) + () : key_value = { + key; + value; +} + +let rec make_instrumentation_scope + ~(name:string) + ~(version:string) + ~(attributes:key_value list) + ~(dropped_attributes_count:int32) + () : instrumentation_scope = { + name; + version; + attributes; + dropped_attributes_count; +} + +[@@@ocaml.warning "-27-30-39"] + +(** {2 Formatters} *) + +let rec pp_any_value fmt (v:any_value) = + match v with + | String_value x -> Format.fprintf fmt "@[String_value(@,%a)@]" Pbrt.Pp.pp_string x + | Bool_value x -> Format.fprintf fmt "@[Bool_value(@,%a)@]" Pbrt.Pp.pp_bool x + | Int_value x -> Format.fprintf fmt "@[Int_value(@,%a)@]" Pbrt.Pp.pp_int64 x + | Double_value x -> Format.fprintf fmt "@[Double_value(@,%a)@]" Pbrt.Pp.pp_float x + | Array_value x -> Format.fprintf fmt "@[Array_value(@,%a)@]" pp_array_value x + | Kvlist_value x -> Format.fprintf fmt "@[Kvlist_value(@,%a)@]" pp_key_value_list x + | Bytes_value x -> Format.fprintf fmt "@[Bytes_value(@,%a)@]" Pbrt.Pp.pp_bytes x + +and pp_array_value fmt (v:array_value) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "values" (Pbrt.Pp.pp_list pp_any_value) fmt v.values; + in + Pbrt.Pp.pp_brk pp_i fmt () + +and pp_key_value_list fmt (v:key_value_list) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "values" (Pbrt.Pp.pp_list pp_key_value) fmt v.values; + in + Pbrt.Pp.pp_brk pp_i fmt () + +and pp_key_value fmt (v:key_value) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "key" Pbrt.Pp.pp_string fmt v.key; + Pbrt.Pp.pp_record_field ~first:false "value" (Pbrt.Pp.pp_option pp_any_value) fmt v.value; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_instrumentation_scope fmt (v:instrumentation_scope) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "name" Pbrt.Pp.pp_string fmt v.name; + Pbrt.Pp.pp_record_field ~first:false "version" Pbrt.Pp.pp_string fmt v.version; + Pbrt.Pp.pp_record_field ~first:false "attributes" (Pbrt.Pp.pp_list pp_key_value) fmt v.attributes; + Pbrt.Pp.pp_record_field ~first:false "dropped_attributes_count" Pbrt.Pp.pp_int32 fmt v.dropped_attributes_count; + in + Pbrt.Pp.pp_brk pp_i fmt () + +[@@@ocaml.warning "-27-30-39"] + +(** {2 Protobuf Encoding} *) + +let rec encode_pb_any_value (v:any_value) encoder = + begin match v with + | String_value x -> + Pbrt.Encoder.string x encoder; + Pbrt.Encoder.key 1 Pbrt.Bytes encoder; + | Bool_value x -> + Pbrt.Encoder.bool x encoder; + Pbrt.Encoder.key 2 Pbrt.Varint encoder; + | Int_value x -> + Pbrt.Encoder.int64_as_varint x encoder; + Pbrt.Encoder.key 3 Pbrt.Varint encoder; + | Double_value x -> + Pbrt.Encoder.float_as_bits64 x encoder; + Pbrt.Encoder.key 4 Pbrt.Bits64 encoder; + | Array_value x -> + Pbrt.Encoder.nested encode_pb_array_value x encoder; + Pbrt.Encoder.key 5 Pbrt.Bytes encoder; + | Kvlist_value x -> + Pbrt.Encoder.nested encode_pb_key_value_list x encoder; + Pbrt.Encoder.key 6 Pbrt.Bytes encoder; + | Bytes_value x -> + Pbrt.Encoder.bytes x encoder; + Pbrt.Encoder.key 7 Pbrt.Bytes encoder; + end + +and encode_pb_array_value (v:array_value) encoder = + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested encode_pb_any_value x encoder; + Pbrt.Encoder.key 1 Pbrt.Bytes encoder; + ) v.values encoder; + () + +and encode_pb_key_value_list (v:key_value_list) encoder = + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested encode_pb_key_value x encoder; + Pbrt.Encoder.key 1 Pbrt.Bytes encoder; + ) v.values encoder; + () + +and encode_pb_key_value (v:key_value) encoder = + Pbrt.Encoder.string v.key encoder; + Pbrt.Encoder.key 1 Pbrt.Bytes encoder; + begin match v.value with + | Some x -> + Pbrt.Encoder.nested encode_pb_any_value x encoder; + Pbrt.Encoder.key 2 Pbrt.Bytes encoder; + | None -> (); + end; + () + +let rec encode_pb_instrumentation_scope (v:instrumentation_scope) encoder = + Pbrt.Encoder.string v.name encoder; + Pbrt.Encoder.key 1 Pbrt.Bytes encoder; + Pbrt.Encoder.string v.version encoder; + Pbrt.Encoder.key 2 Pbrt.Bytes encoder; + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested encode_pb_key_value x encoder; + Pbrt.Encoder.key 3 Pbrt.Bytes encoder; + ) v.attributes encoder; + Pbrt.Encoder.int32_as_varint v.dropped_attributes_count encoder; + Pbrt.Encoder.key 4 Pbrt.Varint encoder; + () + +[@@@ocaml.warning "-27-30-39"] + +(** {2 Protobuf Decoding} *) + +let rec decode_pb_any_value d = + let rec loop () = + let ret:any_value = match Pbrt.Decoder.key d with + | None -> Pbrt.Decoder.malformed_variant "any_value" + | Some (1, _) -> (String_value (Pbrt.Decoder.string d) : any_value) + | Some (2, _) -> (Bool_value (Pbrt.Decoder.bool d) : any_value) + | Some (3, _) -> (Int_value (Pbrt.Decoder.int64_as_varint d) : any_value) + | Some (4, _) -> (Double_value (Pbrt.Decoder.float_as_bits64 d) : any_value) + | Some (5, _) -> (Array_value (decode_pb_array_value (Pbrt.Decoder.nested d)) : any_value) + | Some (6, _) -> (Kvlist_value (decode_pb_key_value_list (Pbrt.Decoder.nested d)) : any_value) + | Some (7, _) -> (Bytes_value (Pbrt.Decoder.bytes d) : any_value) + | Some (n, payload_kind) -> ( + Pbrt.Decoder.skip d payload_kind; + loop () + ) + in + ret + in + loop () + +and decode_pb_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_pb_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; + ({ + values = v.values; + } : array_value) + +and decode_pb_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_pb_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; + ({ + values = v.values; + } : key_value_list) + +and decode_pb_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_pb_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; + ({ + key = v.key; + value = v.value; + } : key_value) + +let rec decode_pb_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_pb_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; + ({ + name = v.name; + version = v.version; + attributes = v.attributes; + dropped_attributes_count = v.dropped_attributes_count; + } : instrumentation_scope) diff --git a/src/proto/common.mli b/src/proto/common.mli new file mode 100644 index 00000000..fcbc7999 --- /dev/null +++ b/src/proto/common.mli @@ -0,0 +1,160 @@ + +(** Code for common.proto *) + +(* generated from "../../vendor/opentelemetry-proto/opentelemetry/proto/common/v1/common.proto", do not edit *) + + + +(** {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 Basic 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] *) + + +(** {2 Make functions} *) + + +val make_array_value : + values:any_value list -> + unit -> + array_value +(** [make_array_value … ()] is a builder for type [array_value] *) + +val make_key_value_list : + values:key_value list -> + unit -> + key_value_list +(** [make_key_value_list … ()] is a builder for type [key_value_list] *) + +val make_key_value : + key:string -> + ?value:any_value option -> + unit -> + key_value +(** [make_key_value … ()] is a builder for type [key_value] *) + +val make_instrumentation_scope : + name:string -> + version:string -> + attributes:key_value list -> + dropped_attributes_count:int32 -> + unit -> + instrumentation_scope +(** [make_instrumentation_scope … ()] is a builder for type [instrumentation_scope] *) + + +(** {2 Formatters} *) + +val pp_any_value : Format.formatter -> any_value -> unit +(** [pp_any_value v] formats v *) + +val pp_array_value : Format.formatter -> array_value -> unit +(** [pp_array_value v] formats v *) + +val pp_key_value_list : Format.formatter -> key_value_list -> unit +(** [pp_key_value_list v] formats v *) + +val pp_key_value : Format.formatter -> key_value -> unit +(** [pp_key_value v] formats v *) + +val pp_instrumentation_scope : Format.formatter -> instrumentation_scope -> unit +(** [pp_instrumentation_scope v] formats v *) + + +(** {2 Protobuf Encoding} *) + +val encode_pb_any_value : any_value -> Pbrt.Encoder.t -> unit +(** [encode_pb_any_value v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_array_value : array_value -> Pbrt.Encoder.t -> unit +(** [encode_pb_array_value v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_key_value_list : key_value_list -> Pbrt.Encoder.t -> unit +(** [encode_pb_key_value_list v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_key_value : key_value -> Pbrt.Encoder.t -> unit +(** [encode_pb_key_value v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_instrumentation_scope : instrumentation_scope -> Pbrt.Encoder.t -> unit +(** [encode_pb_instrumentation_scope v encoder] encodes [v] with the given [encoder] *) + + +(** {2 Protobuf Decoding} *) + +val decode_pb_any_value : Pbrt.Decoder.t -> any_value +(** [decode_pb_any_value decoder] decodes a [any_value] binary value from [decoder] *) + +val decode_pb_array_value : Pbrt.Decoder.t -> array_value +(** [decode_pb_array_value decoder] decodes a [array_value] binary value from [decoder] *) + +val decode_pb_key_value_list : Pbrt.Decoder.t -> key_value_list +(** [decode_pb_key_value_list decoder] decodes a [key_value_list] binary value from [decoder] *) + +val decode_pb_key_value : Pbrt.Decoder.t -> key_value +(** [decode_pb_key_value decoder] decodes a [key_value] binary value from [decoder] *) + +val decode_pb_instrumentation_scope : Pbrt.Decoder.t -> instrumentation_scope +(** [decode_pb_instrumentation_scope decoder] decodes a [instrumentation_scope] binary value from [decoder] *) + + +(** {2 Services} *) diff --git a/src/proto/common_pb.ml b/src/proto/common_pb.ml deleted file mode 100644 index 07425f0f..00000000 --- a/src/proto/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/proto/common_pb.mli b/src/proto/common_pb.mli deleted file mode 100644 index 7ece8615..00000000 --- a/src/proto/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/proto/common_pp.ml b/src/proto/common_pp.ml deleted file mode 100644 index e809bafc..00000000 --- a/src/proto/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/proto/common_pp.mli b/src/proto/common_pp.mli deleted file mode 100644 index 4c2fc14d..00000000 --- a/src/proto/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/proto/common_types.ml b/src/proto/common_types.ml deleted file mode 100644 index bddc9354..00000000 --- a/src/proto/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/proto/common_types.mli b/src/proto/common_types.mli deleted file mode 100644 index 8427638a..00000000 --- a/src/proto/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/proto/dune b/src/proto/dune index b786b70e..57961c27 100644 --- a/src/proto/dune +++ b/src/proto/dune @@ -10,115 +10,105 @@ (rule (alias lint) (mode promote) - (targets status_types.ml status_types.mli status_pb.ml status_pb.mli - status_pp.ml status_pp.mli) + (targets status.ml status.mli) (deps (:file status.proto) (source_tree %{project_root}/vendor/opentelemetry-proto/)) (action - (run ocaml-protoc %{file} -ml_out . -pp -binary))) + (run ocaml-protoc %{file} --ml_out . --pp --make --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) + (targets common.ml common.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))) + --ml_out . --pp --make --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) + (targets resource.ml resource.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))) + --ml_out . --pp --make --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) + (targets trace.ml trace.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))) + --ml_out . --pp --make --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) + (targets metrics.ml metrics.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))) + --ml_out . --pp --make --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) + (targets logs.ml logs.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))) + --ml_out . --pp --make --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) + (targets metrics_service.ml metrics_service.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))) + --ml_out . --pp --make --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) + (targets trace_service.ml trace_service.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))) + --ml_out . --pp --make --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) + (targets logs_service.ml logs_service.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))) + --ml_out . --pp --make --binary))) diff --git a/src/proto/logs.ml b/src/proto/logs.ml new file mode 100644 index 00000000..37509420 --- /dev/null +++ b/src/proto/logs.ml @@ -0,0 +1,598 @@ +[@@@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.any_value option; + attributes : Common.key_value list; + dropped_attributes_count : int32; + flags : int32; + trace_id : bytes; + span_id : bytes; +} + +type scope_logs = { + scope : Common.instrumentation_scope option; + log_records : log_record list; + schema_url : string; +} + +type resource_logs = { + resource : Resource.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.any_value option) = None) + ?attributes:((attributes:Common.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.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.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) + +type log_record_mutable = { + mutable time_unix_nano : int64; + mutable observed_time_unix_nano : int64; + mutable severity_number : severity_number; + mutable severity_text : string; + mutable body : Common.any_value option; + mutable attributes : Common.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 = 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.instrumentation_scope option; + mutable log_records : 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.resource option; + mutable scope_logs : 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 : resource_logs list; +} + +let default_logs_data_mutable () : logs_data_mutable = { + resource_logs = []; +} + + +(** {2 Make functions} *) + + +let rec make_log_record + ~(time_unix_nano:int64) + ~(observed_time_unix_nano:int64) + ~(severity_number:severity_number) + ~(severity_text:string) + ?body:((body:Common.any_value option) = None) + ~(attributes:Common.key_value list) + ~(dropped_attributes_count:int32) + ~(flags:int32) + ~(trace_id:bytes) + ~(span_id:bytes) + () : 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 make_scope_logs + ?scope:((scope:Common.instrumentation_scope option) = None) + ~(log_records:log_record list) + ~(schema_url:string) + () : scope_logs = { + scope; + log_records; + schema_url; +} + +let rec make_resource_logs + ?resource:((resource:Resource.resource option) = None) + ~(scope_logs:scope_logs list) + ~(schema_url:string) + () : resource_logs = { + resource; + scope_logs; + schema_url; +} + +let rec make_logs_data + ~(resource_logs:resource_logs list) + () : logs_data = { + resource_logs; +} + + +[@@@ocaml.warning "-27-30-39"] + +(** {2 Formatters} *) + +let rec pp_severity_number fmt (v:severity_number) = + match v with + | Severity_number_unspecified -> Format.fprintf fmt "Severity_number_unspecified" + | Severity_number_trace -> Format.fprintf fmt "Severity_number_trace" + | Severity_number_trace2 -> Format.fprintf fmt "Severity_number_trace2" + | Severity_number_trace3 -> Format.fprintf fmt "Severity_number_trace3" + | Severity_number_trace4 -> Format.fprintf fmt "Severity_number_trace4" + | Severity_number_debug -> Format.fprintf fmt "Severity_number_debug" + | Severity_number_debug2 -> Format.fprintf fmt "Severity_number_debug2" + | Severity_number_debug3 -> Format.fprintf fmt "Severity_number_debug3" + | Severity_number_debug4 -> Format.fprintf fmt "Severity_number_debug4" + | Severity_number_info -> Format.fprintf fmt "Severity_number_info" + | Severity_number_info2 -> Format.fprintf fmt "Severity_number_info2" + | Severity_number_info3 -> Format.fprintf fmt "Severity_number_info3" + | Severity_number_info4 -> Format.fprintf fmt "Severity_number_info4" + | Severity_number_warn -> Format.fprintf fmt "Severity_number_warn" + | Severity_number_warn2 -> Format.fprintf fmt "Severity_number_warn2" + | Severity_number_warn3 -> Format.fprintf fmt "Severity_number_warn3" + | Severity_number_warn4 -> Format.fprintf fmt "Severity_number_warn4" + | Severity_number_error -> Format.fprintf fmt "Severity_number_error" + | Severity_number_error2 -> Format.fprintf fmt "Severity_number_error2" + | Severity_number_error3 -> Format.fprintf fmt "Severity_number_error3" + | Severity_number_error4 -> Format.fprintf fmt "Severity_number_error4" + | Severity_number_fatal -> Format.fprintf fmt "Severity_number_fatal" + | Severity_number_fatal2 -> Format.fprintf fmt "Severity_number_fatal2" + | Severity_number_fatal3 -> Format.fprintf fmt "Severity_number_fatal3" + | Severity_number_fatal4 -> Format.fprintf fmt "Severity_number_fatal4" + +let rec pp_log_record fmt (v:log_record) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.time_unix_nano; + Pbrt.Pp.pp_record_field ~first:false "observed_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.observed_time_unix_nano; + Pbrt.Pp.pp_record_field ~first:false "severity_number" pp_severity_number fmt v.severity_number; + Pbrt.Pp.pp_record_field ~first:false "severity_text" Pbrt.Pp.pp_string fmt v.severity_text; + Pbrt.Pp.pp_record_field ~first:false "body" (Pbrt.Pp.pp_option Common.pp_any_value) fmt v.body; + Pbrt.Pp.pp_record_field ~first:false "attributes" (Pbrt.Pp.pp_list Common.pp_key_value) fmt v.attributes; + Pbrt.Pp.pp_record_field ~first:false "dropped_attributes_count" Pbrt.Pp.pp_int32 fmt v.dropped_attributes_count; + Pbrt.Pp.pp_record_field ~first:false "flags" Pbrt.Pp.pp_int32 fmt v.flags; + Pbrt.Pp.pp_record_field ~first:false "trace_id" Pbrt.Pp.pp_bytes fmt v.trace_id; + Pbrt.Pp.pp_record_field ~first:false "span_id" Pbrt.Pp.pp_bytes fmt v.span_id; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_scope_logs fmt (v:scope_logs) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "scope" (Pbrt.Pp.pp_option Common.pp_instrumentation_scope) fmt v.scope; + Pbrt.Pp.pp_record_field ~first:false "log_records" (Pbrt.Pp.pp_list pp_log_record) fmt v.log_records; + Pbrt.Pp.pp_record_field ~first:false "schema_url" Pbrt.Pp.pp_string fmt v.schema_url; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_resource_logs fmt (v:resource_logs) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "resource" (Pbrt.Pp.pp_option Resource.pp_resource) fmt v.resource; + Pbrt.Pp.pp_record_field ~first:false "scope_logs" (Pbrt.Pp.pp_list pp_scope_logs) fmt v.scope_logs; + Pbrt.Pp.pp_record_field ~first:false "schema_url" Pbrt.Pp.pp_string fmt v.schema_url; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_logs_data fmt (v:logs_data) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "resource_logs" (Pbrt.Pp.pp_list pp_resource_logs) fmt v.resource_logs; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_log_record_flags fmt (v:log_record_flags) = + match v with + | Log_record_flags_do_not_use -> Format.fprintf fmt "Log_record_flags_do_not_use" + | Log_record_flags_trace_flags_mask -> Format.fprintf fmt "Log_record_flags_trace_flags_mask" + +[@@@ocaml.warning "-27-30-39"] + +(** {2 Protobuf Encoding} *) + +let rec encode_pb_severity_number (v:severity_number) encoder = + match v with + | Severity_number_unspecified -> Pbrt.Encoder.int_as_varint (0) encoder + | Severity_number_trace -> Pbrt.Encoder.int_as_varint 1 encoder + | Severity_number_trace2 -> Pbrt.Encoder.int_as_varint 2 encoder + | Severity_number_trace3 -> Pbrt.Encoder.int_as_varint 3 encoder + | Severity_number_trace4 -> Pbrt.Encoder.int_as_varint 4 encoder + | Severity_number_debug -> Pbrt.Encoder.int_as_varint 5 encoder + | Severity_number_debug2 -> Pbrt.Encoder.int_as_varint 6 encoder + | Severity_number_debug3 -> Pbrt.Encoder.int_as_varint 7 encoder + | Severity_number_debug4 -> Pbrt.Encoder.int_as_varint 8 encoder + | Severity_number_info -> Pbrt.Encoder.int_as_varint 9 encoder + | Severity_number_info2 -> Pbrt.Encoder.int_as_varint 10 encoder + | Severity_number_info3 -> Pbrt.Encoder.int_as_varint 11 encoder + | Severity_number_info4 -> Pbrt.Encoder.int_as_varint 12 encoder + | Severity_number_warn -> Pbrt.Encoder.int_as_varint 13 encoder + | Severity_number_warn2 -> Pbrt.Encoder.int_as_varint 14 encoder + | Severity_number_warn3 -> Pbrt.Encoder.int_as_varint 15 encoder + | Severity_number_warn4 -> Pbrt.Encoder.int_as_varint 16 encoder + | Severity_number_error -> Pbrt.Encoder.int_as_varint 17 encoder + | Severity_number_error2 -> Pbrt.Encoder.int_as_varint 18 encoder + | Severity_number_error3 -> Pbrt.Encoder.int_as_varint 19 encoder + | Severity_number_error4 -> Pbrt.Encoder.int_as_varint 20 encoder + | Severity_number_fatal -> Pbrt.Encoder.int_as_varint 21 encoder + | Severity_number_fatal2 -> Pbrt.Encoder.int_as_varint 22 encoder + | Severity_number_fatal3 -> Pbrt.Encoder.int_as_varint 23 encoder + | Severity_number_fatal4 -> Pbrt.Encoder.int_as_varint 24 encoder + +let rec encode_pb_log_record (v:log_record) encoder = + Pbrt.Encoder.int64_as_bits64 v.time_unix_nano encoder; + Pbrt.Encoder.key 1 Pbrt.Bits64 encoder; + Pbrt.Encoder.int64_as_bits64 v.observed_time_unix_nano encoder; + Pbrt.Encoder.key 11 Pbrt.Bits64 encoder; + encode_pb_severity_number v.severity_number encoder; + Pbrt.Encoder.key 2 Pbrt.Varint encoder; + Pbrt.Encoder.string v.severity_text encoder; + Pbrt.Encoder.key 3 Pbrt.Bytes encoder; + begin match v.body with + | Some x -> + Pbrt.Encoder.nested Common.encode_pb_any_value x encoder; + Pbrt.Encoder.key 5 Pbrt.Bytes encoder; + | None -> (); + end; + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested Common.encode_pb_key_value x encoder; + Pbrt.Encoder.key 6 Pbrt.Bytes encoder; + ) v.attributes encoder; + Pbrt.Encoder.int32_as_varint v.dropped_attributes_count encoder; + Pbrt.Encoder.key 7 Pbrt.Varint encoder; + Pbrt.Encoder.int32_as_bits32 v.flags encoder; + Pbrt.Encoder.key 8 Pbrt.Bits32 encoder; + Pbrt.Encoder.bytes v.trace_id encoder; + Pbrt.Encoder.key 9 Pbrt.Bytes encoder; + Pbrt.Encoder.bytes v.span_id encoder; + Pbrt.Encoder.key 10 Pbrt.Bytes encoder; + () + +let rec encode_pb_scope_logs (v:scope_logs) encoder = + begin match v.scope with + | Some x -> + Pbrt.Encoder.nested Common.encode_pb_instrumentation_scope x encoder; + Pbrt.Encoder.key 1 Pbrt.Bytes encoder; + | None -> (); + end; + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested encode_pb_log_record x encoder; + Pbrt.Encoder.key 2 Pbrt.Bytes encoder; + ) v.log_records encoder; + Pbrt.Encoder.string v.schema_url encoder; + Pbrt.Encoder.key 3 Pbrt.Bytes encoder; + () + +let rec encode_pb_resource_logs (v:resource_logs) encoder = + begin match v.resource with + | Some x -> + Pbrt.Encoder.nested Resource.encode_pb_resource x encoder; + Pbrt.Encoder.key 1 Pbrt.Bytes encoder; + | None -> (); + end; + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested encode_pb_scope_logs x encoder; + Pbrt.Encoder.key 2 Pbrt.Bytes encoder; + ) v.scope_logs encoder; + Pbrt.Encoder.string v.schema_url encoder; + Pbrt.Encoder.key 3 Pbrt.Bytes encoder; + () + +let rec encode_pb_logs_data (v:logs_data) encoder = + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested encode_pb_resource_logs x encoder; + Pbrt.Encoder.key 1 Pbrt.Bytes encoder; + ) v.resource_logs encoder; + () + +let rec encode_pb_log_record_flags (v:log_record_flags) encoder = + match v with + | Log_record_flags_do_not_use -> Pbrt.Encoder.int_as_varint (0) encoder + | Log_record_flags_trace_flags_mask -> Pbrt.Encoder.int_as_varint 255 encoder + +[@@@ocaml.warning "-27-30-39"] + +(** {2 Protobuf Decoding} *) + +let rec decode_pb_severity_number d = + match Pbrt.Decoder.int_as_varint d with + | 0 -> (Severity_number_unspecified:severity_number) + | 1 -> (Severity_number_trace:severity_number) + | 2 -> (Severity_number_trace2:severity_number) + | 3 -> (Severity_number_trace3:severity_number) + | 4 -> (Severity_number_trace4:severity_number) + | 5 -> (Severity_number_debug:severity_number) + | 6 -> (Severity_number_debug2:severity_number) + | 7 -> (Severity_number_debug3:severity_number) + | 8 -> (Severity_number_debug4:severity_number) + | 9 -> (Severity_number_info:severity_number) + | 10 -> (Severity_number_info2:severity_number) + | 11 -> (Severity_number_info3:severity_number) + | 12 -> (Severity_number_info4:severity_number) + | 13 -> (Severity_number_warn:severity_number) + | 14 -> (Severity_number_warn2:severity_number) + | 15 -> (Severity_number_warn3:severity_number) + | 16 -> (Severity_number_warn4:severity_number) + | 17 -> (Severity_number_error:severity_number) + | 18 -> (Severity_number_error2:severity_number) + | 19 -> (Severity_number_error3:severity_number) + | 20 -> (Severity_number_error4:severity_number) + | 21 -> (Severity_number_fatal:severity_number) + | 22 -> (Severity_number_fatal2:severity_number) + | 23 -> (Severity_number_fatal3:severity_number) + | 24 -> (Severity_number_fatal4:severity_number) + | _ -> Pbrt.Decoder.malformed_variant "severity_number" + +let rec decode_pb_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_pb_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.decode_pb_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.decode_pb_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; + ({ + time_unix_nano = v.time_unix_nano; + observed_time_unix_nano = v.observed_time_unix_nano; + severity_number = v.severity_number; + severity_text = v.severity_text; + body = v.body; + attributes = v.attributes; + dropped_attributes_count = v.dropped_attributes_count; + flags = v.flags; + trace_id = v.trace_id; + span_id = v.span_id; + } : log_record) + +let rec decode_pb_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.decode_pb_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_pb_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; + ({ + scope = v.scope; + log_records = v.log_records; + schema_url = v.schema_url; + } : scope_logs) + +let rec decode_pb_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.decode_pb_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_pb_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; + ({ + resource = v.resource; + scope_logs = v.scope_logs; + schema_url = v.schema_url; + } : resource_logs) + +let rec decode_pb_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_pb_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; + ({ + resource_logs = v.resource_logs; + } : logs_data) + +let rec decode_pb_log_record_flags d = + match Pbrt.Decoder.int_as_varint d with + | 0 -> (Log_record_flags_do_not_use:log_record_flags) + | 255 -> (Log_record_flags_trace_flags_mask:log_record_flags) + | _ -> Pbrt.Decoder.malformed_variant "log_record_flags" diff --git a/src/proto/logs.mli b/src/proto/logs.mli new file mode 100644 index 00000000..f1a17d69 --- /dev/null +++ b/src/proto/logs.mli @@ -0,0 +1,222 @@ + +(** Code for logs.proto *) + +(* generated from "../../vendor/opentelemetry-proto/opentelemetry/proto/logs/v1/logs.proto", do not edit *) + + + +(** {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.any_value option; + attributes : Common.key_value list; + dropped_attributes_count : int32; + flags : int32; + trace_id : bytes; + span_id : bytes; +} + +type scope_logs = { + scope : Common.instrumentation_scope option; + log_records : log_record list; + schema_url : string; +} + +type resource_logs = { + resource : Resource.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 Basic 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.any_value option -> + ?attributes:Common.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.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.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] *) + + +(** {2 Make functions} *) + + +val make_log_record : + time_unix_nano:int64 -> + observed_time_unix_nano:int64 -> + severity_number:severity_number -> + severity_text:string -> + ?body:Common.any_value option -> + attributes:Common.key_value list -> + dropped_attributes_count:int32 -> + flags:int32 -> + trace_id:bytes -> + span_id:bytes -> + unit -> + log_record +(** [make_log_record … ()] is a builder for type [log_record] *) + +val make_scope_logs : + ?scope:Common.instrumentation_scope option -> + log_records:log_record list -> + schema_url:string -> + unit -> + scope_logs +(** [make_scope_logs … ()] is a builder for type [scope_logs] *) + +val make_resource_logs : + ?resource:Resource.resource option -> + scope_logs:scope_logs list -> + schema_url:string -> + unit -> + resource_logs +(** [make_resource_logs … ()] is a builder for type [resource_logs] *) + +val make_logs_data : + resource_logs:resource_logs list -> + unit -> + logs_data +(** [make_logs_data … ()] is a builder for type [logs_data] *) + + + +(** {2 Formatters} *) + +val pp_severity_number : Format.formatter -> severity_number -> unit +(** [pp_severity_number v] formats v *) + +val pp_log_record : Format.formatter -> log_record -> unit +(** [pp_log_record v] formats v *) + +val pp_scope_logs : Format.formatter -> scope_logs -> unit +(** [pp_scope_logs v] formats v *) + +val pp_resource_logs : Format.formatter -> resource_logs -> unit +(** [pp_resource_logs v] formats v *) + +val pp_logs_data : Format.formatter -> logs_data -> unit +(** [pp_logs_data v] formats v *) + +val pp_log_record_flags : Format.formatter -> log_record_flags -> unit +(** [pp_log_record_flags v] formats v *) + + +(** {2 Protobuf Encoding} *) + +val encode_pb_severity_number : severity_number -> Pbrt.Encoder.t -> unit +(** [encode_pb_severity_number v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_log_record : log_record -> Pbrt.Encoder.t -> unit +(** [encode_pb_log_record v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_scope_logs : scope_logs -> Pbrt.Encoder.t -> unit +(** [encode_pb_scope_logs v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_resource_logs : resource_logs -> Pbrt.Encoder.t -> unit +(** [encode_pb_resource_logs v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_logs_data : logs_data -> Pbrt.Encoder.t -> unit +(** [encode_pb_logs_data v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_log_record_flags : log_record_flags -> Pbrt.Encoder.t -> unit +(** [encode_pb_log_record_flags v encoder] encodes [v] with the given [encoder] *) + + +(** {2 Protobuf Decoding} *) + +val decode_pb_severity_number : Pbrt.Decoder.t -> severity_number +(** [decode_pb_severity_number decoder] decodes a [severity_number] binary value from [decoder] *) + +val decode_pb_log_record : Pbrt.Decoder.t -> log_record +(** [decode_pb_log_record decoder] decodes a [log_record] binary value from [decoder] *) + +val decode_pb_scope_logs : Pbrt.Decoder.t -> scope_logs +(** [decode_pb_scope_logs decoder] decodes a [scope_logs] binary value from [decoder] *) + +val decode_pb_resource_logs : Pbrt.Decoder.t -> resource_logs +(** [decode_pb_resource_logs decoder] decodes a [resource_logs] binary value from [decoder] *) + +val decode_pb_logs_data : Pbrt.Decoder.t -> logs_data +(** [decode_pb_logs_data decoder] decodes a [logs_data] binary value from [decoder] *) + +val decode_pb_log_record_flags : Pbrt.Decoder.t -> log_record_flags +(** [decode_pb_log_record_flags decoder] decodes a [log_record_flags] binary value from [decoder] *) + + +(** {2 Services} *) diff --git a/src/proto/logs_pb.ml b/src/proto/logs_pb.ml deleted file mode 100644 index 2ad391c5..00000000 --- a/src/proto/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/proto/logs_pb.mli b/src/proto/logs_pb.mli deleted file mode 100644 index 93e6d369..00000000 --- a/src/proto/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/proto/logs_pp.ml b/src/proto/logs_pp.ml deleted file mode 100644 index 408f01d9..00000000 --- a/src/proto/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/proto/logs_pp.mli b/src/proto/logs_pp.mli deleted file mode 100644 index fd952524..00000000 --- a/src/proto/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/proto/logs_service.ml b/src/proto/logs_service.ml new file mode 100644 index 00000000..7958071b --- /dev/null +++ b/src/proto/logs_service.ml @@ -0,0 +1,243 @@ +[@@@ocaml.warning "-27-30-39"] + +type export_logs_service_request = { + resource_logs : Logs.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.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; +} + +type export_logs_service_request_mutable = { + mutable resource_logs : Logs.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 : export_logs_partial_success option; +} + +let default_export_logs_service_response_mutable () : export_logs_service_response_mutable = { + partial_success = None; +} + + +(** {2 Make functions} *) + +let rec make_export_logs_service_request + ~(resource_logs:Logs.resource_logs list) + () : export_logs_service_request = { + resource_logs; +} + +let rec make_export_logs_partial_success + ~(rejected_log_records:int64) + ~(error_message:string) + () : export_logs_partial_success = { + rejected_log_records; + error_message; +} + +let rec make_export_logs_service_response + ?partial_success:((partial_success:export_logs_partial_success option) = None) + () : export_logs_service_response = { + partial_success; +} + +[@@@ocaml.warning "-27-30-39"] + +(** {2 Formatters} *) + +let rec pp_export_logs_service_request fmt (v:export_logs_service_request) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "resource_logs" (Pbrt.Pp.pp_list Logs.pp_resource_logs) fmt v.resource_logs; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_export_logs_partial_success fmt (v:export_logs_partial_success) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "rejected_log_records" Pbrt.Pp.pp_int64 fmt v.rejected_log_records; + Pbrt.Pp.pp_record_field ~first:false "error_message" Pbrt.Pp.pp_string fmt v.error_message; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_export_logs_service_response fmt (v: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.partial_success; + in + Pbrt.Pp.pp_brk pp_i fmt () + +[@@@ocaml.warning "-27-30-39"] + +(** {2 Protobuf Encoding} *) + +let rec encode_pb_export_logs_service_request (v:export_logs_service_request) encoder = + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested Logs.encode_pb_resource_logs x encoder; + Pbrt.Encoder.key 1 Pbrt.Bytes encoder; + ) v.resource_logs encoder; + () + +let rec encode_pb_export_logs_partial_success (v:export_logs_partial_success) encoder = + Pbrt.Encoder.int64_as_varint v.rejected_log_records encoder; + Pbrt.Encoder.key 1 Pbrt.Varint encoder; + Pbrt.Encoder.string v.error_message encoder; + Pbrt.Encoder.key 2 Pbrt.Bytes encoder; + () + +let rec encode_pb_export_logs_service_response (v:export_logs_service_response) encoder = + begin match v.partial_success with + | Some x -> + Pbrt.Encoder.nested encode_pb_export_logs_partial_success x encoder; + Pbrt.Encoder.key 1 Pbrt.Bytes encoder; + | None -> (); + end; + () + +[@@@ocaml.warning "-27-30-39"] + +(** {2 Protobuf Decoding} *) + +let rec decode_pb_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.decode_pb_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; + ({ + resource_logs = v.resource_logs; + } : export_logs_service_request) + +let rec decode_pb_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; + ({ + rejected_log_records = v.rejected_log_records; + error_message = v.error_message; + } : export_logs_partial_success) + +let rec decode_pb_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_pb_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; + ({ + partial_success = v.partial_success; + } : export_logs_service_response) + +module LogsService = struct + open Pbrt_services.Value_mode + module Client = struct + open Pbrt_services + + let export : (export_logs_service_request, unary, export_logs_service_response, unary) Client.rpc = + (Client.mk_rpc + ~package:["opentelemetry";"proto";"collector";"logs";"v1"] + ~service_name:"LogsService" ~rpc_name:"Export" + ~req_mode:Client.Unary + ~res_mode:Client.Unary + ~encode_json_req:encode_json_export_logs_service_request + ~encode_pb_req:encode_pb_export_logs_service_request + ~decode_json_res:decode_json_export_logs_service_response + ~decode_pb_res:decode_pb_export_logs_service_response + () : (export_logs_service_request, unary, export_logs_service_response, unary) Client.rpc) + end + + module Server = struct + open Pbrt_services + + let _rpc_export : (export_logs_service_request,unary,export_logs_service_response,unary) Server.rpc = + (Server.mk_rpc ~name:"Export" + ~req_mode:Server.Unary + ~res_mode:Server.Unary + ~encode_json_res:encode_json_export_logs_service_response + ~encode_pb_res:encode_pb_export_logs_service_response + ~decode_json_req:decode_json_export_logs_service_request + ~decode_pb_req:decode_pb_export_logs_service_request + () : _ Server.rpc) + + let make + ~export + () : _ Server.t = + { Server. + service_name="LogsService"; + package=["opentelemetry";"proto";"collector";"logs";"v1"]; + handlers=[ + (export _rpc_export); + ]; + } + end + +end diff --git a/src/proto/logs_service.mli b/src/proto/logs_service.mli new file mode 100644 index 00000000..cb477313 --- /dev/null +++ b/src/proto/logs_service.mli @@ -0,0 +1,122 @@ + +(** Code for logs_service.proto *) + +(* generated from "../../vendor/opentelemetry-proto/opentelemetry/proto/collector/logs/v1/logs_service.proto", do not edit *) + + + +(** {2 Types} *) + +type export_logs_service_request = { + resource_logs : Logs.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 Basic values} *) + +val default_export_logs_service_request : + ?resource_logs:Logs.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] *) + + +(** {2 Make functions} *) + +val make_export_logs_service_request : + resource_logs:Logs.resource_logs list -> + unit -> + export_logs_service_request +(** [make_export_logs_service_request … ()] is a builder for type [export_logs_service_request] *) + +val make_export_logs_partial_success : + rejected_log_records:int64 -> + error_message:string -> + unit -> + export_logs_partial_success +(** [make_export_logs_partial_success … ()] is a builder for type [export_logs_partial_success] *) + +val make_export_logs_service_response : + ?partial_success:export_logs_partial_success option -> + unit -> + export_logs_service_response +(** [make_export_logs_service_response … ()] is a builder for type [export_logs_service_response] *) + + +(** {2 Formatters} *) + +val pp_export_logs_service_request : Format.formatter -> export_logs_service_request -> unit +(** [pp_export_logs_service_request v] formats v *) + +val pp_export_logs_partial_success : Format.formatter -> export_logs_partial_success -> unit +(** [pp_export_logs_partial_success v] formats v *) + +val pp_export_logs_service_response : Format.formatter -> export_logs_service_response -> unit +(** [pp_export_logs_service_response v] formats v *) + + +(** {2 Protobuf Encoding} *) + +val encode_pb_export_logs_service_request : export_logs_service_request -> Pbrt.Encoder.t -> unit +(** [encode_pb_export_logs_service_request v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_export_logs_partial_success : export_logs_partial_success -> Pbrt.Encoder.t -> unit +(** [encode_pb_export_logs_partial_success v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_export_logs_service_response : export_logs_service_response -> Pbrt.Encoder.t -> unit +(** [encode_pb_export_logs_service_response v encoder] encodes [v] with the given [encoder] *) + + +(** {2 Protobuf Decoding} *) + +val decode_pb_export_logs_service_request : Pbrt.Decoder.t -> export_logs_service_request +(** [decode_pb_export_logs_service_request decoder] decodes a [export_logs_service_request] binary value from [decoder] *) + +val decode_pb_export_logs_partial_success : Pbrt.Decoder.t -> export_logs_partial_success +(** [decode_pb_export_logs_partial_success decoder] decodes a [export_logs_partial_success] binary value from [decoder] *) + +val decode_pb_export_logs_service_response : Pbrt.Decoder.t -> export_logs_service_response +(** [decode_pb_export_logs_service_response decoder] decodes a [export_logs_service_response] binary value from [decoder] *) + + +(** {2 Services} *) + +(** LogsService service *) +module LogsService : sig + open Pbrt_services + open Pbrt_services.Value_mode + + module Client : sig + + val export : (export_logs_service_request, unary, export_logs_service_response, unary) Client.rpc + end + + module Server : sig + (** Produce a server implementation from handlers *) + val make : + export:((export_logs_service_request, unary, export_logs_service_response, unary) Server.rpc -> 'handler) -> + unit -> 'handler Pbrt_services.Server.t + end +end diff --git a/src/proto/logs_service_pb.ml b/src/proto/logs_service_pb.ml deleted file mode 100644 index 64fde20f..00000000 --- a/src/proto/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/proto/logs_service_pb.mli b/src/proto/logs_service_pb.mli deleted file mode 100644 index db4d8c89..00000000 --- a/src/proto/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/proto/logs_service_pp.ml b/src/proto/logs_service_pp.ml deleted file mode 100644 index 19830e4c..00000000 --- a/src/proto/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/proto/logs_service_pp.mli b/src/proto/logs_service_pp.mli deleted file mode 100644 index 6aa6319f..00000000 --- a/src/proto/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/proto/logs_service_types.ml b/src/proto/logs_service_types.ml deleted file mode 100644 index 9bf19974..00000000 --- a/src/proto/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/proto/logs_service_types.mli b/src/proto/logs_service_types.mli deleted file mode 100644 index beef4fd3..00000000 --- a/src/proto/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/proto/logs_types.ml b/src/proto/logs_types.ml deleted file mode 100644 index 4a383ff7..00000000 --- a/src/proto/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/proto/logs_types.mli b/src/proto/logs_types.mli deleted file mode 100644 index 7a9cc1a3..00000000 --- a/src/proto/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/proto/metrics.ml b/src/proto/metrics.ml new file mode 100644 index 00000000..a829c10b --- /dev/null +++ b/src/proto/metrics.ml @@ -0,0 +1,2022 @@ +[@@@ocaml.warning "-27-30-39"] + +type exemplar_value = + | As_double of float + | As_int of int64 + +and exemplar = { + filtered_attributes : Common.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.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.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.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.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.instrumentation_scope option; + metrics : metric list; + schema_url : string; +} + +type resource_metrics = { + resource : Resource.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.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.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.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.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.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.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.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) + +type exemplar_mutable = { + mutable filtered_attributes : Common.key_value list; + mutable time_unix_nano : int64; + mutable value : exemplar_value; + mutable span_id : bytes; + mutable trace_id : bytes; +} + +let default_exemplar_mutable () : exemplar_mutable = { + filtered_attributes = []; + time_unix_nano = 0L; + value = As_double (0.); + span_id = Bytes.create 0; + trace_id = Bytes.create 0; +} + +type number_data_point_mutable = { + mutable attributes : Common.key_value list; + mutable start_time_unix_nano : int64; + mutable time_unix_nano : int64; + mutable value : number_data_point_value; + mutable exemplars : 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 = As_double (0.); + exemplars = []; + flags = 0l; +} + +type gauge_mutable = { + mutable data_points : number_data_point list; +} + +let default_gauge_mutable () : gauge_mutable = { + data_points = []; +} + +type sum_mutable = { + mutable data_points : number_data_point list; + mutable aggregation_temporality : aggregation_temporality; + mutable is_monotonic : bool; +} + +let default_sum_mutable () : sum_mutable = { + data_points = []; + aggregation_temporality = default_aggregation_temporality (); + is_monotonic = false; +} + +type histogram_data_point_mutable = { + mutable attributes : Common.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 : 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 : histogram_data_point list; + mutable aggregation_temporality : aggregation_temporality; +} + +let default_histogram_mutable () : histogram_mutable = { + data_points = []; + aggregation_temporality = 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.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 : exponential_histogram_data_point_buckets option; + mutable negative : exponential_histogram_data_point_buckets option; + mutable flags : int32; + mutable exemplars : 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 : exponential_histogram_data_point list; + mutable aggregation_temporality : aggregation_temporality; +} + +let default_exponential_histogram_mutable () : exponential_histogram_mutable = { + data_points = []; + aggregation_temporality = 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.key_value list; + mutable start_time_unix_nano : int64; + mutable time_unix_nano : int64; + mutable count : int64; + mutable sum : float; + mutable quantile_values : 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 : 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 : metric_data; +} + +let default_metric_mutable () : metric_mutable = { + name = ""; + description = ""; + unit_ = ""; + data = Gauge (default_gauge ()); +} + +type scope_metrics_mutable = { + mutable scope : Common.instrumentation_scope option; + mutable metrics : 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.resource option; + mutable scope_metrics : 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 : resource_metrics list; +} + +let default_metrics_data_mutable () : metrics_data_mutable = { + resource_metrics = []; +} + + +(** {2 Make functions} *) + + +let rec make_exemplar + ~(filtered_attributes:Common.key_value list) + ~(time_unix_nano:int64) + ~(value:exemplar_value) + ~(span_id:bytes) + ~(trace_id:bytes) + () : exemplar = { + filtered_attributes; + time_unix_nano; + value; + span_id; + trace_id; +} + + +let rec make_number_data_point + ~(attributes:Common.key_value list) + ~(start_time_unix_nano:int64) + ~(time_unix_nano:int64) + ~(value:number_data_point_value) + ~(exemplars:exemplar list) + ~(flags:int32) + () : number_data_point = { + attributes; + start_time_unix_nano; + time_unix_nano; + value; + exemplars; + flags; +} + +let rec make_gauge + ~(data_points:number_data_point list) + () : gauge = { + data_points; +} + + +let rec make_sum + ~(data_points:number_data_point list) + ~(aggregation_temporality:aggregation_temporality) + ~(is_monotonic:bool) + () : sum = { + data_points; + aggregation_temporality; + is_monotonic; +} + +let rec make_histogram_data_point + ~(attributes:Common.key_value list) + ~(start_time_unix_nano:int64) + ~(time_unix_nano:int64) + ~(count:int64) + ?sum:((sum:float option) = None) + ~(bucket_counts:int64 list) + ~(explicit_bounds:float list) + ~(exemplars:exemplar list) + ~(flags:int32) + ?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 make_histogram + ~(data_points:histogram_data_point list) + ~(aggregation_temporality:aggregation_temporality) + () : histogram = { + data_points; + aggregation_temporality; +} + +let rec make_exponential_histogram_data_point_buckets + ~(offset:int32) + ~(bucket_counts:int64 list) + () : exponential_histogram_data_point_buckets = { + offset; + bucket_counts; +} + +let rec make_exponential_histogram_data_point + ~(attributes:Common.key_value list) + ~(start_time_unix_nano:int64) + ~(time_unix_nano:int64) + ~(count:int64) + ?sum:((sum:float option) = None) + ~(scale:int32) + ~(zero_count:int64) + ?positive:((positive:exponential_histogram_data_point_buckets option) = None) + ?negative:((negative:exponential_histogram_data_point_buckets option) = None) + ~(flags:int32) + ~(exemplars:exemplar list) + ?min:((min:float option) = None) + ?max:((max:float option) = None) + ~(zero_threshold:float) + () : 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 make_exponential_histogram + ~(data_points:exponential_histogram_data_point list) + ~(aggregation_temporality:aggregation_temporality) + () : exponential_histogram = { + data_points; + aggregation_temporality; +} + +let rec make_summary_data_point_value_at_quantile + ~(quantile:float) + ~(value:float) + () : summary_data_point_value_at_quantile = { + quantile; + value; +} + +let rec make_summary_data_point + ~(attributes:Common.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) + () : summary_data_point = { + attributes; + start_time_unix_nano; + time_unix_nano; + count; + sum; + quantile_values; + flags; +} + +let rec make_summary + ~(data_points:summary_data_point list) + () : summary = { + data_points; +} + + +let rec make_metric + ~(name:string) + ~(description:string) + ~(unit_:string) + ~(data:metric_data) + () : metric = { + name; + description; + unit_; + data; +} + +let rec make_scope_metrics + ?scope:((scope:Common.instrumentation_scope option) = None) + ~(metrics:metric list) + ~(schema_url:string) + () : scope_metrics = { + scope; + metrics; + schema_url; +} + +let rec make_resource_metrics + ?resource:((resource:Resource.resource option) = None) + ~(scope_metrics:scope_metrics list) + ~(schema_url:string) + () : resource_metrics = { + resource; + scope_metrics; + schema_url; +} + +let rec make_metrics_data + ~(resource_metrics:resource_metrics list) + () : metrics_data = { + resource_metrics; +} + + +[@@@ocaml.warning "-27-30-39"] + +(** {2 Formatters} *) + +let rec pp_exemplar_value fmt (v:exemplar_value) = + match v with + | As_double x -> Format.fprintf fmt "@[As_double(@,%a)@]" Pbrt.Pp.pp_float x + | As_int x -> Format.fprintf fmt "@[As_int(@,%a)@]" Pbrt.Pp.pp_int64 x + +and pp_exemplar fmt (v:exemplar) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "filtered_attributes" (Pbrt.Pp.pp_list Common.pp_key_value) fmt v.filtered_attributes; + Pbrt.Pp.pp_record_field ~first:false "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.time_unix_nano; + Pbrt.Pp.pp_record_field ~first:false "value" pp_exemplar_value fmt v.value; + Pbrt.Pp.pp_record_field ~first:false "span_id" Pbrt.Pp.pp_bytes fmt v.span_id; + Pbrt.Pp.pp_record_field ~first:false "trace_id" Pbrt.Pp.pp_bytes fmt v.trace_id; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_number_data_point_value fmt (v:number_data_point_value) = + match v with + | As_double x -> Format.fprintf fmt "@[As_double(@,%a)@]" Pbrt.Pp.pp_float x + | As_int x -> Format.fprintf fmt "@[As_int(@,%a)@]" Pbrt.Pp.pp_int64 x + +and pp_number_data_point fmt (v:number_data_point) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "attributes" (Pbrt.Pp.pp_list Common.pp_key_value) fmt v.attributes; + Pbrt.Pp.pp_record_field ~first:false "start_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.start_time_unix_nano; + Pbrt.Pp.pp_record_field ~first:false "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.time_unix_nano; + Pbrt.Pp.pp_record_field ~first:false "value" pp_number_data_point_value fmt v.value; + Pbrt.Pp.pp_record_field ~first:false "exemplars" (Pbrt.Pp.pp_list pp_exemplar) fmt v.exemplars; + Pbrt.Pp.pp_record_field ~first:false "flags" Pbrt.Pp.pp_int32 fmt v.flags; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_gauge fmt (v:gauge) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "data_points" (Pbrt.Pp.pp_list pp_number_data_point) fmt v.data_points; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_aggregation_temporality fmt (v:aggregation_temporality) = + match v with + | Aggregation_temporality_unspecified -> Format.fprintf fmt "Aggregation_temporality_unspecified" + | Aggregation_temporality_delta -> Format.fprintf fmt "Aggregation_temporality_delta" + | Aggregation_temporality_cumulative -> Format.fprintf fmt "Aggregation_temporality_cumulative" + +let rec pp_sum fmt (v:sum) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "data_points" (Pbrt.Pp.pp_list pp_number_data_point) fmt v.data_points; + Pbrt.Pp.pp_record_field ~first:false "aggregation_temporality" pp_aggregation_temporality fmt v.aggregation_temporality; + Pbrt.Pp.pp_record_field ~first:false "is_monotonic" Pbrt.Pp.pp_bool fmt v.is_monotonic; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_histogram_data_point fmt (v:histogram_data_point) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "attributes" (Pbrt.Pp.pp_list Common.pp_key_value) fmt v.attributes; + Pbrt.Pp.pp_record_field ~first:false "start_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.start_time_unix_nano; + Pbrt.Pp.pp_record_field ~first:false "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.time_unix_nano; + Pbrt.Pp.pp_record_field ~first:false "count" Pbrt.Pp.pp_int64 fmt v.count; + Pbrt.Pp.pp_record_field ~first:false "sum" (Pbrt.Pp.pp_option Pbrt.Pp.pp_float) fmt v.sum; + Pbrt.Pp.pp_record_field ~first:false "bucket_counts" (Pbrt.Pp.pp_list Pbrt.Pp.pp_int64) fmt v.bucket_counts; + Pbrt.Pp.pp_record_field ~first:false "explicit_bounds" (Pbrt.Pp.pp_list Pbrt.Pp.pp_float) fmt v.explicit_bounds; + Pbrt.Pp.pp_record_field ~first:false "exemplars" (Pbrt.Pp.pp_list pp_exemplar) fmt v.exemplars; + Pbrt.Pp.pp_record_field ~first:false "flags" Pbrt.Pp.pp_int32 fmt v.flags; + Pbrt.Pp.pp_record_field ~first:false "min" (Pbrt.Pp.pp_option Pbrt.Pp.pp_float) fmt v.min; + Pbrt.Pp.pp_record_field ~first:false "max" (Pbrt.Pp.pp_option Pbrt.Pp.pp_float) fmt v.max; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_histogram fmt (v:histogram) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "data_points" (Pbrt.Pp.pp_list pp_histogram_data_point) fmt v.data_points; + Pbrt.Pp.pp_record_field ~first:false "aggregation_temporality" pp_aggregation_temporality fmt v.aggregation_temporality; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_exponential_histogram_data_point_buckets fmt (v:exponential_histogram_data_point_buckets) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "offset" Pbrt.Pp.pp_int32 fmt v.offset; + Pbrt.Pp.pp_record_field ~first:false "bucket_counts" (Pbrt.Pp.pp_list Pbrt.Pp.pp_int64) fmt v.bucket_counts; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_exponential_histogram_data_point fmt (v:exponential_histogram_data_point) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "attributes" (Pbrt.Pp.pp_list Common.pp_key_value) fmt v.attributes; + Pbrt.Pp.pp_record_field ~first:false "start_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.start_time_unix_nano; + Pbrt.Pp.pp_record_field ~first:false "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.time_unix_nano; + Pbrt.Pp.pp_record_field ~first:false "count" Pbrt.Pp.pp_int64 fmt v.count; + Pbrt.Pp.pp_record_field ~first:false "sum" (Pbrt.Pp.pp_option Pbrt.Pp.pp_float) fmt v.sum; + Pbrt.Pp.pp_record_field ~first:false "scale" Pbrt.Pp.pp_int32 fmt v.scale; + Pbrt.Pp.pp_record_field ~first:false "zero_count" Pbrt.Pp.pp_int64 fmt v.zero_count; + Pbrt.Pp.pp_record_field ~first:false "positive" (Pbrt.Pp.pp_option pp_exponential_histogram_data_point_buckets) fmt v.positive; + Pbrt.Pp.pp_record_field ~first:false "negative" (Pbrt.Pp.pp_option pp_exponential_histogram_data_point_buckets) fmt v.negative; + Pbrt.Pp.pp_record_field ~first:false "flags" Pbrt.Pp.pp_int32 fmt v.flags; + Pbrt.Pp.pp_record_field ~first:false "exemplars" (Pbrt.Pp.pp_list pp_exemplar) fmt v.exemplars; + Pbrt.Pp.pp_record_field ~first:false "min" (Pbrt.Pp.pp_option Pbrt.Pp.pp_float) fmt v.min; + Pbrt.Pp.pp_record_field ~first:false "max" (Pbrt.Pp.pp_option Pbrt.Pp.pp_float) fmt v.max; + Pbrt.Pp.pp_record_field ~first:false "zero_threshold" Pbrt.Pp.pp_float fmt v.zero_threshold; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_exponential_histogram fmt (v: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.data_points; + Pbrt.Pp.pp_record_field ~first:false "aggregation_temporality" pp_aggregation_temporality fmt v.aggregation_temporality; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_summary_data_point_value_at_quantile fmt (v:summary_data_point_value_at_quantile) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "quantile" Pbrt.Pp.pp_float fmt v.quantile; + Pbrt.Pp.pp_record_field ~first:false "value" Pbrt.Pp.pp_float fmt v.value; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_summary_data_point fmt (v:summary_data_point) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "attributes" (Pbrt.Pp.pp_list Common.pp_key_value) fmt v.attributes; + Pbrt.Pp.pp_record_field ~first:false "start_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.start_time_unix_nano; + Pbrt.Pp.pp_record_field ~first:false "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.time_unix_nano; + Pbrt.Pp.pp_record_field ~first:false "count" Pbrt.Pp.pp_int64 fmt v.count; + Pbrt.Pp.pp_record_field ~first:false "sum" Pbrt.Pp.pp_float fmt v.sum; + Pbrt.Pp.pp_record_field ~first:false "quantile_values" (Pbrt.Pp.pp_list pp_summary_data_point_value_at_quantile) fmt v.quantile_values; + Pbrt.Pp.pp_record_field ~first:false "flags" Pbrt.Pp.pp_int32 fmt v.flags; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_summary fmt (v:summary) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "data_points" (Pbrt.Pp.pp_list pp_summary_data_point) fmt v.data_points; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_metric_data fmt (v:metric_data) = + match v with + | Gauge x -> Format.fprintf fmt "@[Gauge(@,%a)@]" pp_gauge x + | Sum x -> Format.fprintf fmt "@[Sum(@,%a)@]" pp_sum x + | Histogram x -> Format.fprintf fmt "@[Histogram(@,%a)@]" pp_histogram x + | Exponential_histogram x -> Format.fprintf fmt "@[Exponential_histogram(@,%a)@]" pp_exponential_histogram x + | Summary x -> Format.fprintf fmt "@[Summary(@,%a)@]" pp_summary x + +and pp_metric fmt (v:metric) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "name" Pbrt.Pp.pp_string fmt v.name; + Pbrt.Pp.pp_record_field ~first:false "description" Pbrt.Pp.pp_string fmt v.description; + Pbrt.Pp.pp_record_field ~first:false "unit_" Pbrt.Pp.pp_string fmt v.unit_; + Pbrt.Pp.pp_record_field ~first:false "data" pp_metric_data fmt v.data; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_scope_metrics fmt (v:scope_metrics) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "scope" (Pbrt.Pp.pp_option Common.pp_instrumentation_scope) fmt v.scope; + Pbrt.Pp.pp_record_field ~first:false "metrics" (Pbrt.Pp.pp_list pp_metric) fmt v.metrics; + Pbrt.Pp.pp_record_field ~first:false "schema_url" Pbrt.Pp.pp_string fmt v.schema_url; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_resource_metrics fmt (v:resource_metrics) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "resource" (Pbrt.Pp.pp_option Resource.pp_resource) fmt v.resource; + Pbrt.Pp.pp_record_field ~first:false "scope_metrics" (Pbrt.Pp.pp_list pp_scope_metrics) fmt v.scope_metrics; + Pbrt.Pp.pp_record_field ~first:false "schema_url" Pbrt.Pp.pp_string fmt v.schema_url; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_metrics_data fmt (v:metrics_data) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "resource_metrics" (Pbrt.Pp.pp_list pp_resource_metrics) fmt v.resource_metrics; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_data_point_flags fmt (v:data_point_flags) = + match v with + | Data_point_flags_do_not_use -> Format.fprintf fmt "Data_point_flags_do_not_use" + | Data_point_flags_no_recorded_value_mask -> Format.fprintf fmt "Data_point_flags_no_recorded_value_mask" + +[@@@ocaml.warning "-27-30-39"] + +(** {2 Protobuf Encoding} *) + +let rec encode_pb_exemplar_value (v:exemplar_value) encoder = + begin match v with + | As_double x -> + Pbrt.Encoder.float_as_bits64 x encoder; + Pbrt.Encoder.key 3 Pbrt.Bits64 encoder; + | As_int x -> + Pbrt.Encoder.int64_as_bits64 x encoder; + Pbrt.Encoder.key 6 Pbrt.Bits64 encoder; + end + +and encode_pb_exemplar (v:exemplar) encoder = + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested Common.encode_pb_key_value x encoder; + Pbrt.Encoder.key 7 Pbrt.Bytes encoder; + ) v.filtered_attributes encoder; + Pbrt.Encoder.int64_as_bits64 v.time_unix_nano encoder; + Pbrt.Encoder.key 2 Pbrt.Bits64 encoder; + begin match v.value with + | As_double x -> + Pbrt.Encoder.float_as_bits64 x encoder; + Pbrt.Encoder.key 3 Pbrt.Bits64 encoder; + | As_int x -> + Pbrt.Encoder.int64_as_bits64 x encoder; + Pbrt.Encoder.key 6 Pbrt.Bits64 encoder; + end; + Pbrt.Encoder.bytes v.span_id encoder; + Pbrt.Encoder.key 4 Pbrt.Bytes encoder; + Pbrt.Encoder.bytes v.trace_id encoder; + Pbrt.Encoder.key 5 Pbrt.Bytes encoder; + () + +let rec encode_pb_number_data_point_value (v:number_data_point_value) encoder = + begin match v with + | As_double x -> + Pbrt.Encoder.float_as_bits64 x encoder; + Pbrt.Encoder.key 4 Pbrt.Bits64 encoder; + | As_int x -> + Pbrt.Encoder.int64_as_bits64 x encoder; + Pbrt.Encoder.key 6 Pbrt.Bits64 encoder; + end + +and encode_pb_number_data_point (v:number_data_point) encoder = + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested Common.encode_pb_key_value x encoder; + Pbrt.Encoder.key 7 Pbrt.Bytes encoder; + ) v.attributes encoder; + Pbrt.Encoder.int64_as_bits64 v.start_time_unix_nano encoder; + Pbrt.Encoder.key 2 Pbrt.Bits64 encoder; + Pbrt.Encoder.int64_as_bits64 v.time_unix_nano encoder; + Pbrt.Encoder.key 3 Pbrt.Bits64 encoder; + begin match v.value with + | As_double x -> + Pbrt.Encoder.float_as_bits64 x encoder; + Pbrt.Encoder.key 4 Pbrt.Bits64 encoder; + | As_int x -> + Pbrt.Encoder.int64_as_bits64 x encoder; + Pbrt.Encoder.key 6 Pbrt.Bits64 encoder; + end; + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested encode_pb_exemplar x encoder; + Pbrt.Encoder.key 5 Pbrt.Bytes encoder; + ) v.exemplars encoder; + Pbrt.Encoder.int32_as_varint v.flags encoder; + Pbrt.Encoder.key 8 Pbrt.Varint encoder; + () + +let rec encode_pb_gauge (v:gauge) encoder = + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested encode_pb_number_data_point x encoder; + Pbrt.Encoder.key 1 Pbrt.Bytes encoder; + ) v.data_points encoder; + () + +let rec encode_pb_aggregation_temporality (v:aggregation_temporality) encoder = + match v with + | Aggregation_temporality_unspecified -> Pbrt.Encoder.int_as_varint (0) encoder + | Aggregation_temporality_delta -> Pbrt.Encoder.int_as_varint 1 encoder + | Aggregation_temporality_cumulative -> Pbrt.Encoder.int_as_varint 2 encoder + +let rec encode_pb_sum (v:sum) encoder = + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested encode_pb_number_data_point x encoder; + Pbrt.Encoder.key 1 Pbrt.Bytes encoder; + ) v.data_points encoder; + encode_pb_aggregation_temporality v.aggregation_temporality encoder; + Pbrt.Encoder.key 2 Pbrt.Varint encoder; + Pbrt.Encoder.bool v.is_monotonic encoder; + Pbrt.Encoder.key 3 Pbrt.Varint encoder; + () + +let rec encode_pb_histogram_data_point (v:histogram_data_point) encoder = + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested Common.encode_pb_key_value x encoder; + Pbrt.Encoder.key 9 Pbrt.Bytes encoder; + ) v.attributes encoder; + Pbrt.Encoder.int64_as_bits64 v.start_time_unix_nano encoder; + Pbrt.Encoder.key 2 Pbrt.Bits64 encoder; + Pbrt.Encoder.int64_as_bits64 v.time_unix_nano encoder; + Pbrt.Encoder.key 3 Pbrt.Bits64 encoder; + Pbrt.Encoder.int64_as_bits64 v.count encoder; + Pbrt.Encoder.key 4 Pbrt.Bits64 encoder; + begin match v.sum with + | Some x -> + Pbrt.Encoder.float_as_bits64 x encoder; + Pbrt.Encoder.key 5 Pbrt.Bits64 encoder; + | None -> (); + end; + Pbrt.Encoder.nested (fun lst encoder -> + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.int64_as_bits64 x encoder; + ) lst encoder; + ) v.bucket_counts encoder; + Pbrt.Encoder.key 6 Pbrt.Bytes encoder; + Pbrt.Encoder.nested (fun lst encoder -> + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.float_as_bits64 x encoder; + ) lst encoder; + ) v.explicit_bounds encoder; + Pbrt.Encoder.key 7 Pbrt.Bytes encoder; + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested encode_pb_exemplar x encoder; + Pbrt.Encoder.key 8 Pbrt.Bytes encoder; + ) v.exemplars encoder; + Pbrt.Encoder.int32_as_varint v.flags encoder; + Pbrt.Encoder.key 10 Pbrt.Varint encoder; + begin match v.min with + | Some x -> + Pbrt.Encoder.float_as_bits64 x encoder; + Pbrt.Encoder.key 11 Pbrt.Bits64 encoder; + | None -> (); + end; + begin match v.max with + | Some x -> + Pbrt.Encoder.float_as_bits64 x encoder; + Pbrt.Encoder.key 12 Pbrt.Bits64 encoder; + | None -> (); + end; + () + +let rec encode_pb_histogram (v:histogram) encoder = + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested encode_pb_histogram_data_point x encoder; + Pbrt.Encoder.key 1 Pbrt.Bytes encoder; + ) v.data_points encoder; + encode_pb_aggregation_temporality v.aggregation_temporality encoder; + Pbrt.Encoder.key 2 Pbrt.Varint encoder; + () + +let rec encode_pb_exponential_histogram_data_point_buckets (v:exponential_histogram_data_point_buckets) encoder = + Pbrt.Encoder.int32_as_zigzag v.offset encoder; + Pbrt.Encoder.key 1 Pbrt.Varint encoder; + Pbrt.Encoder.nested (fun lst encoder -> + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.int64_as_varint x encoder; + ) lst encoder; + ) v.bucket_counts encoder; + Pbrt.Encoder.key 2 Pbrt.Bytes encoder; + () + +let rec encode_pb_exponential_histogram_data_point (v:exponential_histogram_data_point) encoder = + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested Common.encode_pb_key_value x encoder; + Pbrt.Encoder.key 1 Pbrt.Bytes encoder; + ) v.attributes encoder; + Pbrt.Encoder.int64_as_bits64 v.start_time_unix_nano encoder; + Pbrt.Encoder.key 2 Pbrt.Bits64 encoder; + Pbrt.Encoder.int64_as_bits64 v.time_unix_nano encoder; + Pbrt.Encoder.key 3 Pbrt.Bits64 encoder; + Pbrt.Encoder.int64_as_bits64 v.count encoder; + Pbrt.Encoder.key 4 Pbrt.Bits64 encoder; + begin match v.sum with + | Some x -> + Pbrt.Encoder.float_as_bits64 x encoder; + Pbrt.Encoder.key 5 Pbrt.Bits64 encoder; + | None -> (); + end; + Pbrt.Encoder.int32_as_zigzag v.scale encoder; + Pbrt.Encoder.key 6 Pbrt.Varint encoder; + Pbrt.Encoder.int64_as_bits64 v.zero_count encoder; + Pbrt.Encoder.key 7 Pbrt.Bits64 encoder; + begin match v.positive with + | Some x -> + Pbrt.Encoder.nested encode_pb_exponential_histogram_data_point_buckets x encoder; + Pbrt.Encoder.key 8 Pbrt.Bytes encoder; + | None -> (); + end; + begin match v.negative with + | Some x -> + Pbrt.Encoder.nested encode_pb_exponential_histogram_data_point_buckets x encoder; + Pbrt.Encoder.key 9 Pbrt.Bytes encoder; + | None -> (); + end; + Pbrt.Encoder.int32_as_varint v.flags encoder; + Pbrt.Encoder.key 10 Pbrt.Varint encoder; + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested encode_pb_exemplar x encoder; + Pbrt.Encoder.key 11 Pbrt.Bytes encoder; + ) v.exemplars encoder; + begin match v.min with + | Some x -> + Pbrt.Encoder.float_as_bits64 x encoder; + Pbrt.Encoder.key 12 Pbrt.Bits64 encoder; + | None -> (); + end; + begin match v.max with + | Some x -> + Pbrt.Encoder.float_as_bits64 x encoder; + Pbrt.Encoder.key 13 Pbrt.Bits64 encoder; + | None -> (); + end; + Pbrt.Encoder.float_as_bits64 v.zero_threshold encoder; + Pbrt.Encoder.key 14 Pbrt.Bits64 encoder; + () + +let rec encode_pb_exponential_histogram (v:exponential_histogram) encoder = + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested encode_pb_exponential_histogram_data_point x encoder; + Pbrt.Encoder.key 1 Pbrt.Bytes encoder; + ) v.data_points encoder; + encode_pb_aggregation_temporality v.aggregation_temporality encoder; + Pbrt.Encoder.key 2 Pbrt.Varint encoder; + () + +let rec encode_pb_summary_data_point_value_at_quantile (v:summary_data_point_value_at_quantile) encoder = + Pbrt.Encoder.float_as_bits64 v.quantile encoder; + Pbrt.Encoder.key 1 Pbrt.Bits64 encoder; + Pbrt.Encoder.float_as_bits64 v.value encoder; + Pbrt.Encoder.key 2 Pbrt.Bits64 encoder; + () + +let rec encode_pb_summary_data_point (v:summary_data_point) encoder = + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested Common.encode_pb_key_value x encoder; + Pbrt.Encoder.key 7 Pbrt.Bytes encoder; + ) v.attributes encoder; + Pbrt.Encoder.int64_as_bits64 v.start_time_unix_nano encoder; + Pbrt.Encoder.key 2 Pbrt.Bits64 encoder; + Pbrt.Encoder.int64_as_bits64 v.time_unix_nano encoder; + Pbrt.Encoder.key 3 Pbrt.Bits64 encoder; + Pbrt.Encoder.int64_as_bits64 v.count encoder; + Pbrt.Encoder.key 4 Pbrt.Bits64 encoder; + Pbrt.Encoder.float_as_bits64 v.sum encoder; + Pbrt.Encoder.key 5 Pbrt.Bits64 encoder; + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested encode_pb_summary_data_point_value_at_quantile x encoder; + Pbrt.Encoder.key 6 Pbrt.Bytes encoder; + ) v.quantile_values encoder; + Pbrt.Encoder.int32_as_varint v.flags encoder; + Pbrt.Encoder.key 8 Pbrt.Varint encoder; + () + +let rec encode_pb_summary (v:summary) encoder = + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested encode_pb_summary_data_point x encoder; + Pbrt.Encoder.key 1 Pbrt.Bytes encoder; + ) v.data_points encoder; + () + +let rec encode_pb_metric_data (v:metric_data) encoder = + begin match v with + | Gauge x -> + Pbrt.Encoder.nested encode_pb_gauge x encoder; + Pbrt.Encoder.key 5 Pbrt.Bytes encoder; + | Sum x -> + Pbrt.Encoder.nested encode_pb_sum x encoder; + Pbrt.Encoder.key 7 Pbrt.Bytes encoder; + | Histogram x -> + Pbrt.Encoder.nested encode_pb_histogram x encoder; + Pbrt.Encoder.key 9 Pbrt.Bytes encoder; + | Exponential_histogram x -> + Pbrt.Encoder.nested encode_pb_exponential_histogram x encoder; + Pbrt.Encoder.key 10 Pbrt.Bytes encoder; + | Summary x -> + Pbrt.Encoder.nested encode_pb_summary x encoder; + Pbrt.Encoder.key 11 Pbrt.Bytes encoder; + end + +and encode_pb_metric (v:metric) encoder = + Pbrt.Encoder.string v.name encoder; + Pbrt.Encoder.key 1 Pbrt.Bytes encoder; + Pbrt.Encoder.string v.description encoder; + Pbrt.Encoder.key 2 Pbrt.Bytes encoder; + Pbrt.Encoder.string v.unit_ encoder; + Pbrt.Encoder.key 3 Pbrt.Bytes encoder; + begin match v.data with + | Gauge x -> + Pbrt.Encoder.nested encode_pb_gauge x encoder; + Pbrt.Encoder.key 5 Pbrt.Bytes encoder; + | Sum x -> + Pbrt.Encoder.nested encode_pb_sum x encoder; + Pbrt.Encoder.key 7 Pbrt.Bytes encoder; + | Histogram x -> + Pbrt.Encoder.nested encode_pb_histogram x encoder; + Pbrt.Encoder.key 9 Pbrt.Bytes encoder; + | Exponential_histogram x -> + Pbrt.Encoder.nested encode_pb_exponential_histogram x encoder; + Pbrt.Encoder.key 10 Pbrt.Bytes encoder; + | Summary x -> + Pbrt.Encoder.nested encode_pb_summary x encoder; + Pbrt.Encoder.key 11 Pbrt.Bytes encoder; + end; + () + +let rec encode_pb_scope_metrics (v:scope_metrics) encoder = + begin match v.scope with + | Some x -> + Pbrt.Encoder.nested Common.encode_pb_instrumentation_scope x encoder; + Pbrt.Encoder.key 1 Pbrt.Bytes encoder; + | None -> (); + end; + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested encode_pb_metric x encoder; + Pbrt.Encoder.key 2 Pbrt.Bytes encoder; + ) v.metrics encoder; + Pbrt.Encoder.string v.schema_url encoder; + Pbrt.Encoder.key 3 Pbrt.Bytes encoder; + () + +let rec encode_pb_resource_metrics (v:resource_metrics) encoder = + begin match v.resource with + | Some x -> + Pbrt.Encoder.nested Resource.encode_pb_resource x encoder; + Pbrt.Encoder.key 1 Pbrt.Bytes encoder; + | None -> (); + end; + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested encode_pb_scope_metrics x encoder; + Pbrt.Encoder.key 2 Pbrt.Bytes encoder; + ) v.scope_metrics encoder; + Pbrt.Encoder.string v.schema_url encoder; + Pbrt.Encoder.key 3 Pbrt.Bytes encoder; + () + +let rec encode_pb_metrics_data (v:metrics_data) encoder = + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested encode_pb_resource_metrics x encoder; + Pbrt.Encoder.key 1 Pbrt.Bytes encoder; + ) v.resource_metrics encoder; + () + +let rec encode_pb_data_point_flags (v:data_point_flags) encoder = + match v with + | Data_point_flags_do_not_use -> Pbrt.Encoder.int_as_varint (0) encoder + | Data_point_flags_no_recorded_value_mask -> Pbrt.Encoder.int_as_varint 1 encoder + +[@@@ocaml.warning "-27-30-39"] + +(** {2 Protobuf Decoding} *) + +let rec decode_pb_exemplar_value d = + let rec loop () = + let ret:exemplar_value = match Pbrt.Decoder.key d with + | None -> Pbrt.Decoder.malformed_variant "exemplar_value" + | Some (3, _) -> (As_double (Pbrt.Decoder.float_as_bits64 d) : exemplar_value) + | Some (6, _) -> (As_int (Pbrt.Decoder.int64_as_bits64 d) : exemplar_value) + | Some (n, payload_kind) -> ( + Pbrt.Decoder.skip d payload_kind; + loop () + ) + in + ret + in + loop () + +and decode_pb_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.decode_pb_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 <- 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 <- 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; + ({ + filtered_attributes = v.filtered_attributes; + time_unix_nano = v.time_unix_nano; + value = v.value; + span_id = v.span_id; + trace_id = v.trace_id; + } : exemplar) + +let rec decode_pb_number_data_point_value d = + let rec loop () = + let ret:number_data_point_value = match Pbrt.Decoder.key d with + | None -> Pbrt.Decoder.malformed_variant "number_data_point_value" + | Some (4, _) -> (As_double (Pbrt.Decoder.float_as_bits64 d) : number_data_point_value) + | Some (6, _) -> (As_int (Pbrt.Decoder.int64_as_bits64 d) : number_data_point_value) + | Some (n, payload_kind) -> ( + Pbrt.Decoder.skip d payload_kind; + loop () + ) + in + ret + in + loop () + +and decode_pb_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.decode_pb_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 <- 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 <- 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_pb_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; + ({ + attributes = v.attributes; + start_time_unix_nano = v.start_time_unix_nano; + time_unix_nano = v.time_unix_nano; + value = v.value; + exemplars = v.exemplars; + flags = v.flags; + } : number_data_point) + +let rec decode_pb_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_pb_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; + ({ + data_points = v.data_points; + } : gauge) + +let rec decode_pb_aggregation_temporality d = + match Pbrt.Decoder.int_as_varint d with + | 0 -> (Aggregation_temporality_unspecified:aggregation_temporality) + | 1 -> (Aggregation_temporality_delta:aggregation_temporality) + | 2 -> (Aggregation_temporality_cumulative:aggregation_temporality) + | _ -> Pbrt.Decoder.malformed_variant "aggregation_temporality" + +let rec decode_pb_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_pb_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_pb_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; + ({ + data_points = v.data_points; + aggregation_temporality = v.aggregation_temporality; + is_monotonic = v.is_monotonic; + } : sum) + +let rec decode_pb_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.decode_pb_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_pb_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; + ({ + attributes = v.attributes; + start_time_unix_nano = v.start_time_unix_nano; + time_unix_nano = v.time_unix_nano; + count = v.count; + sum = v.sum; + bucket_counts = v.bucket_counts; + explicit_bounds = v.explicit_bounds; + exemplars = v.exemplars; + flags = v.flags; + min = v.min; + max = v.max; + } : histogram_data_point) + +let rec decode_pb_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_pb_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_pb_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; + ({ + data_points = v.data_points; + aggregation_temporality = v.aggregation_temporality; + } : histogram) + +let rec decode_pb_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; + ({ + offset = v.offset; + bucket_counts = v.bucket_counts; + } : exponential_histogram_data_point_buckets) + +let rec decode_pb_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.decode_pb_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_pb_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_pb_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_pb_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; + ({ + attributes = v.attributes; + start_time_unix_nano = v.start_time_unix_nano; + time_unix_nano = v.time_unix_nano; + count = v.count; + sum = v.sum; + scale = v.scale; + zero_count = v.zero_count; + positive = v.positive; + negative = v.negative; + flags = v.flags; + exemplars = v.exemplars; + min = v.min; + max = v.max; + zero_threshold = v.zero_threshold; + } : exponential_histogram_data_point) + +let rec decode_pb_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_pb_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_pb_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; + ({ + data_points = v.data_points; + aggregation_temporality = v.aggregation_temporality; + } : exponential_histogram) + +let rec decode_pb_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; + ({ + quantile = v.quantile; + value = v.value; + } : summary_data_point_value_at_quantile) + +let rec decode_pb_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.decode_pb_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_pb_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; + ({ + attributes = v.attributes; + start_time_unix_nano = v.start_time_unix_nano; + time_unix_nano = v.time_unix_nano; + count = v.count; + sum = v.sum; + quantile_values = v.quantile_values; + flags = v.flags; + } : summary_data_point) + +let rec decode_pb_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_pb_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; + ({ + data_points = v.data_points; + } : summary) + +let rec decode_pb_metric_data d = + let rec loop () = + let ret:metric_data = match Pbrt.Decoder.key d with + | None -> Pbrt.Decoder.malformed_variant "metric_data" + | Some (5, _) -> (Gauge (decode_pb_gauge (Pbrt.Decoder.nested d)) : metric_data) + | Some (7, _) -> (Sum (decode_pb_sum (Pbrt.Decoder.nested d)) : metric_data) + | Some (9, _) -> (Histogram (decode_pb_histogram (Pbrt.Decoder.nested d)) : metric_data) + | Some (10, _) -> (Exponential_histogram (decode_pb_exponential_histogram (Pbrt.Decoder.nested d)) : metric_data) + | Some (11, _) -> (Summary (decode_pb_summary (Pbrt.Decoder.nested d)) : metric_data) + | Some (n, payload_kind) -> ( + Pbrt.Decoder.skip d payload_kind; + loop () + ) + in + ret + in + loop () + +and decode_pb_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 <- Gauge (decode_pb_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 <- Sum (decode_pb_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 <- Histogram (decode_pb_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 <- Exponential_histogram (decode_pb_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 <- Summary (decode_pb_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; + ({ + name = v.name; + description = v.description; + unit_ = v.unit_; + data = v.data; + } : metric) + +let rec decode_pb_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.decode_pb_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_pb_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; + ({ + scope = v.scope; + metrics = v.metrics; + schema_url = v.schema_url; + } : scope_metrics) + +let rec decode_pb_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.decode_pb_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_pb_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; + ({ + resource = v.resource; + scope_metrics = v.scope_metrics; + schema_url = v.schema_url; + } : resource_metrics) + +let rec decode_pb_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_pb_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; + ({ + resource_metrics = v.resource_metrics; + } : metrics_data) + +let rec decode_pb_data_point_flags d = + match Pbrt.Decoder.int_as_varint d with + | 0 -> (Data_point_flags_do_not_use:data_point_flags) + | 1 -> (Data_point_flags_no_recorded_value_mask:data_point_flags) + | _ -> Pbrt.Decoder.malformed_variant "data_point_flags" diff --git a/src/proto/metrics.mli b/src/proto/metrics.mli new file mode 100644 index 00000000..61030369 --- /dev/null +++ b/src/proto/metrics.mli @@ -0,0 +1,668 @@ + +(** Code for metrics.proto *) + +(* generated from "../../vendor/opentelemetry-proto/opentelemetry/proto/metrics/v1/metrics.proto", do not edit *) + + + +(** {2 Types} *) + +type exemplar_value = + | As_double of float + | As_int of int64 + +and exemplar = { + filtered_attributes : Common.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.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.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.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.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.instrumentation_scope option; + metrics : metric list; + schema_url : string; +} + +type resource_metrics = { + resource : Resource.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 Basic 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.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.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.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.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.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.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.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] *) + + +(** {2 Make functions} *) + + +val make_exemplar : + filtered_attributes:Common.key_value list -> + time_unix_nano:int64 -> + value:exemplar_value -> + span_id:bytes -> + trace_id:bytes -> + unit -> + exemplar +(** [make_exemplar … ()] is a builder for type [exemplar] *) + + +val make_number_data_point : + attributes:Common.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 +(** [make_number_data_point … ()] is a builder for type [number_data_point] *) + +val make_gauge : + data_points:number_data_point list -> + unit -> + gauge +(** [make_gauge … ()] is a builder for type [gauge] *) + + +val make_sum : + data_points:number_data_point list -> + aggregation_temporality:aggregation_temporality -> + is_monotonic:bool -> + unit -> + sum +(** [make_sum … ()] is a builder for type [sum] *) + +val make_histogram_data_point : + attributes:Common.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 +(** [make_histogram_data_point … ()] is a builder for type [histogram_data_point] *) + +val make_histogram : + data_points:histogram_data_point list -> + aggregation_temporality:aggregation_temporality -> + unit -> + histogram +(** [make_histogram … ()] is a builder for type [histogram] *) + +val make_exponential_histogram_data_point_buckets : + offset:int32 -> + bucket_counts:int64 list -> + unit -> + exponential_histogram_data_point_buckets +(** [make_exponential_histogram_data_point_buckets … ()] is a builder for type [exponential_histogram_data_point_buckets] *) + +val make_exponential_histogram_data_point : + attributes:Common.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 +(** [make_exponential_histogram_data_point … ()] is a builder for type [exponential_histogram_data_point] *) + +val make_exponential_histogram : + data_points:exponential_histogram_data_point list -> + aggregation_temporality:aggregation_temporality -> + unit -> + exponential_histogram +(** [make_exponential_histogram … ()] is a builder for type [exponential_histogram] *) + +val make_summary_data_point_value_at_quantile : + quantile:float -> + value:float -> + unit -> + summary_data_point_value_at_quantile +(** [make_summary_data_point_value_at_quantile … ()] is a builder for type [summary_data_point_value_at_quantile] *) + +val make_summary_data_point : + attributes:Common.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 +(** [make_summary_data_point … ()] is a builder for type [summary_data_point] *) + +val make_summary : + data_points:summary_data_point list -> + unit -> + summary +(** [make_summary … ()] is a builder for type [summary] *) + + +val make_metric : + name:string -> + description:string -> + unit_:string -> + data:metric_data -> + unit -> + metric +(** [make_metric … ()] is a builder for type [metric] *) + +val make_scope_metrics : + ?scope:Common.instrumentation_scope option -> + metrics:metric list -> + schema_url:string -> + unit -> + scope_metrics +(** [make_scope_metrics … ()] is a builder for type [scope_metrics] *) + +val make_resource_metrics : + ?resource:Resource.resource option -> + scope_metrics:scope_metrics list -> + schema_url:string -> + unit -> + resource_metrics +(** [make_resource_metrics … ()] is a builder for type [resource_metrics] *) + +val make_metrics_data : + resource_metrics:resource_metrics list -> + unit -> + metrics_data +(** [make_metrics_data … ()] is a builder for type [metrics_data] *) + + + +(** {2 Formatters} *) + +val pp_exemplar_value : Format.formatter -> exemplar_value -> unit +(** [pp_exemplar_value v] formats v *) + +val pp_exemplar : Format.formatter -> exemplar -> unit +(** [pp_exemplar v] formats v *) + +val pp_number_data_point_value : Format.formatter -> number_data_point_value -> unit +(** [pp_number_data_point_value v] formats v *) + +val pp_number_data_point : Format.formatter -> number_data_point -> unit +(** [pp_number_data_point v] formats v *) + +val pp_gauge : Format.formatter -> gauge -> unit +(** [pp_gauge v] formats v *) + +val pp_aggregation_temporality : Format.formatter -> aggregation_temporality -> unit +(** [pp_aggregation_temporality v] formats v *) + +val pp_sum : Format.formatter -> sum -> unit +(** [pp_sum v] formats v *) + +val pp_histogram_data_point : Format.formatter -> histogram_data_point -> unit +(** [pp_histogram_data_point v] formats v *) + +val pp_histogram : Format.formatter -> histogram -> unit +(** [pp_histogram v] formats v *) + +val pp_exponential_histogram_data_point_buckets : Format.formatter -> exponential_histogram_data_point_buckets -> unit +(** [pp_exponential_histogram_data_point_buckets v] formats v *) + +val pp_exponential_histogram_data_point : Format.formatter -> exponential_histogram_data_point -> unit +(** [pp_exponential_histogram_data_point v] formats v *) + +val pp_exponential_histogram : Format.formatter -> exponential_histogram -> unit +(** [pp_exponential_histogram v] formats v *) + +val pp_summary_data_point_value_at_quantile : Format.formatter -> summary_data_point_value_at_quantile -> unit +(** [pp_summary_data_point_value_at_quantile v] formats v *) + +val pp_summary_data_point : Format.formatter -> summary_data_point -> unit +(** [pp_summary_data_point v] formats v *) + +val pp_summary : Format.formatter -> summary -> unit +(** [pp_summary v] formats v *) + +val pp_metric_data : Format.formatter -> metric_data -> unit +(** [pp_metric_data v] formats v *) + +val pp_metric : Format.formatter -> metric -> unit +(** [pp_metric v] formats v *) + +val pp_scope_metrics : Format.formatter -> scope_metrics -> unit +(** [pp_scope_metrics v] formats v *) + +val pp_resource_metrics : Format.formatter -> resource_metrics -> unit +(** [pp_resource_metrics v] formats v *) + +val pp_metrics_data : Format.formatter -> metrics_data -> unit +(** [pp_metrics_data v] formats v *) + +val pp_data_point_flags : Format.formatter -> data_point_flags -> unit +(** [pp_data_point_flags v] formats v *) + + +(** {2 Protobuf Encoding} *) + +val encode_pb_exemplar_value : exemplar_value -> Pbrt.Encoder.t -> unit +(** [encode_pb_exemplar_value v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_exemplar : exemplar -> Pbrt.Encoder.t -> unit +(** [encode_pb_exemplar v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_number_data_point_value : number_data_point_value -> Pbrt.Encoder.t -> unit +(** [encode_pb_number_data_point_value v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_number_data_point : number_data_point -> Pbrt.Encoder.t -> unit +(** [encode_pb_number_data_point v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_gauge : gauge -> Pbrt.Encoder.t -> unit +(** [encode_pb_gauge v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_aggregation_temporality : aggregation_temporality -> Pbrt.Encoder.t -> unit +(** [encode_pb_aggregation_temporality v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_sum : sum -> Pbrt.Encoder.t -> unit +(** [encode_pb_sum v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_histogram_data_point : histogram_data_point -> Pbrt.Encoder.t -> unit +(** [encode_pb_histogram_data_point v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_histogram : histogram -> Pbrt.Encoder.t -> unit +(** [encode_pb_histogram v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_exponential_histogram_data_point_buckets : exponential_histogram_data_point_buckets -> Pbrt.Encoder.t -> unit +(** [encode_pb_exponential_histogram_data_point_buckets v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_exponential_histogram_data_point : exponential_histogram_data_point -> Pbrt.Encoder.t -> unit +(** [encode_pb_exponential_histogram_data_point v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_exponential_histogram : exponential_histogram -> Pbrt.Encoder.t -> unit +(** [encode_pb_exponential_histogram v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_summary_data_point_value_at_quantile : summary_data_point_value_at_quantile -> Pbrt.Encoder.t -> unit +(** [encode_pb_summary_data_point_value_at_quantile v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_summary_data_point : summary_data_point -> Pbrt.Encoder.t -> unit +(** [encode_pb_summary_data_point v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_summary : summary -> Pbrt.Encoder.t -> unit +(** [encode_pb_summary v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_metric_data : metric_data -> Pbrt.Encoder.t -> unit +(** [encode_pb_metric_data v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_metric : metric -> Pbrt.Encoder.t -> unit +(** [encode_pb_metric v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_scope_metrics : scope_metrics -> Pbrt.Encoder.t -> unit +(** [encode_pb_scope_metrics v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_resource_metrics : resource_metrics -> Pbrt.Encoder.t -> unit +(** [encode_pb_resource_metrics v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_metrics_data : metrics_data -> Pbrt.Encoder.t -> unit +(** [encode_pb_metrics_data v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_data_point_flags : data_point_flags -> Pbrt.Encoder.t -> unit +(** [encode_pb_data_point_flags v encoder] encodes [v] with the given [encoder] *) + + +(** {2 Protobuf Decoding} *) + +val decode_pb_exemplar_value : Pbrt.Decoder.t -> exemplar_value +(** [decode_pb_exemplar_value decoder] decodes a [exemplar_value] binary value from [decoder] *) + +val decode_pb_exemplar : Pbrt.Decoder.t -> exemplar +(** [decode_pb_exemplar decoder] decodes a [exemplar] binary value from [decoder] *) + +val decode_pb_number_data_point_value : Pbrt.Decoder.t -> number_data_point_value +(** [decode_pb_number_data_point_value decoder] decodes a [number_data_point_value] binary value from [decoder] *) + +val decode_pb_number_data_point : Pbrt.Decoder.t -> number_data_point +(** [decode_pb_number_data_point decoder] decodes a [number_data_point] binary value from [decoder] *) + +val decode_pb_gauge : Pbrt.Decoder.t -> gauge +(** [decode_pb_gauge decoder] decodes a [gauge] binary value from [decoder] *) + +val decode_pb_aggregation_temporality : Pbrt.Decoder.t -> aggregation_temporality +(** [decode_pb_aggregation_temporality decoder] decodes a [aggregation_temporality] binary value from [decoder] *) + +val decode_pb_sum : Pbrt.Decoder.t -> sum +(** [decode_pb_sum decoder] decodes a [sum] binary value from [decoder] *) + +val decode_pb_histogram_data_point : Pbrt.Decoder.t -> histogram_data_point +(** [decode_pb_histogram_data_point decoder] decodes a [histogram_data_point] binary value from [decoder] *) + +val decode_pb_histogram : Pbrt.Decoder.t -> histogram +(** [decode_pb_histogram decoder] decodes a [histogram] binary value from [decoder] *) + +val decode_pb_exponential_histogram_data_point_buckets : Pbrt.Decoder.t -> exponential_histogram_data_point_buckets +(** [decode_pb_exponential_histogram_data_point_buckets decoder] decodes a [exponential_histogram_data_point_buckets] binary value from [decoder] *) + +val decode_pb_exponential_histogram_data_point : Pbrt.Decoder.t -> exponential_histogram_data_point +(** [decode_pb_exponential_histogram_data_point decoder] decodes a [exponential_histogram_data_point] binary value from [decoder] *) + +val decode_pb_exponential_histogram : Pbrt.Decoder.t -> exponential_histogram +(** [decode_pb_exponential_histogram decoder] decodes a [exponential_histogram] binary value from [decoder] *) + +val decode_pb_summary_data_point_value_at_quantile : Pbrt.Decoder.t -> summary_data_point_value_at_quantile +(** [decode_pb_summary_data_point_value_at_quantile decoder] decodes a [summary_data_point_value_at_quantile] binary value from [decoder] *) + +val decode_pb_summary_data_point : Pbrt.Decoder.t -> summary_data_point +(** [decode_pb_summary_data_point decoder] decodes a [summary_data_point] binary value from [decoder] *) + +val decode_pb_summary : Pbrt.Decoder.t -> summary +(** [decode_pb_summary decoder] decodes a [summary] binary value from [decoder] *) + +val decode_pb_metric_data : Pbrt.Decoder.t -> metric_data +(** [decode_pb_metric_data decoder] decodes a [metric_data] binary value from [decoder] *) + +val decode_pb_metric : Pbrt.Decoder.t -> metric +(** [decode_pb_metric decoder] decodes a [metric] binary value from [decoder] *) + +val decode_pb_scope_metrics : Pbrt.Decoder.t -> scope_metrics +(** [decode_pb_scope_metrics decoder] decodes a [scope_metrics] binary value from [decoder] *) + +val decode_pb_resource_metrics : Pbrt.Decoder.t -> resource_metrics +(** [decode_pb_resource_metrics decoder] decodes a [resource_metrics] binary value from [decoder] *) + +val decode_pb_metrics_data : Pbrt.Decoder.t -> metrics_data +(** [decode_pb_metrics_data decoder] decodes a [metrics_data] binary value from [decoder] *) + +val decode_pb_data_point_flags : Pbrt.Decoder.t -> data_point_flags +(** [decode_pb_data_point_flags decoder] decodes a [data_point_flags] binary value from [decoder] *) + + +(** {2 Services} *) diff --git a/src/proto/metrics_pb.ml b/src/proto/metrics_pb.ml deleted file mode 100644 index d85e1e72..00000000 --- a/src/proto/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/proto/metrics_pb.mli b/src/proto/metrics_pb.mli deleted file mode 100644 index 6393cedd..00000000 --- a/src/proto/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/proto/metrics_pp.ml b/src/proto/metrics_pp.ml deleted file mode 100644 index 838343ff..00000000 --- a/src/proto/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/proto/metrics_pp.mli b/src/proto/metrics_pp.mli deleted file mode 100644 index c506e897..00000000 --- a/src/proto/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/proto/metrics_service.ml b/src/proto/metrics_service.ml new file mode 100644 index 00000000..04534bd3 --- /dev/null +++ b/src/proto/metrics_service.ml @@ -0,0 +1,243 @@ +[@@@ocaml.warning "-27-30-39"] + +type export_metrics_service_request = { + resource_metrics : Metrics.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.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; +} + +type export_metrics_service_request_mutable = { + mutable resource_metrics : Metrics.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 : export_metrics_partial_success option; +} + +let default_export_metrics_service_response_mutable () : export_metrics_service_response_mutable = { + partial_success = None; +} + + +(** {2 Make functions} *) + +let rec make_export_metrics_service_request + ~(resource_metrics:Metrics.resource_metrics list) + () : export_metrics_service_request = { + resource_metrics; +} + +let rec make_export_metrics_partial_success + ~(rejected_data_points:int64) + ~(error_message:string) + () : export_metrics_partial_success = { + rejected_data_points; + error_message; +} + +let rec make_export_metrics_service_response + ?partial_success:((partial_success:export_metrics_partial_success option) = None) + () : export_metrics_service_response = { + partial_success; +} + +[@@@ocaml.warning "-27-30-39"] + +(** {2 Formatters} *) + +let rec pp_export_metrics_service_request fmt (v:export_metrics_service_request) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "resource_metrics" (Pbrt.Pp.pp_list Metrics.pp_resource_metrics) fmt v.resource_metrics; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_export_metrics_partial_success fmt (v:export_metrics_partial_success) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "rejected_data_points" Pbrt.Pp.pp_int64 fmt v.rejected_data_points; + Pbrt.Pp.pp_record_field ~first:false "error_message" Pbrt.Pp.pp_string fmt v.error_message; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_export_metrics_service_response fmt (v: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.partial_success; + in + Pbrt.Pp.pp_brk pp_i fmt () + +[@@@ocaml.warning "-27-30-39"] + +(** {2 Protobuf Encoding} *) + +let rec encode_pb_export_metrics_service_request (v:export_metrics_service_request) encoder = + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested Metrics.encode_pb_resource_metrics x encoder; + Pbrt.Encoder.key 1 Pbrt.Bytes encoder; + ) v.resource_metrics encoder; + () + +let rec encode_pb_export_metrics_partial_success (v:export_metrics_partial_success) encoder = + Pbrt.Encoder.int64_as_varint v.rejected_data_points encoder; + Pbrt.Encoder.key 1 Pbrt.Varint encoder; + Pbrt.Encoder.string v.error_message encoder; + Pbrt.Encoder.key 2 Pbrt.Bytes encoder; + () + +let rec encode_pb_export_metrics_service_response (v:export_metrics_service_response) encoder = + begin match v.partial_success with + | Some x -> + Pbrt.Encoder.nested encode_pb_export_metrics_partial_success x encoder; + Pbrt.Encoder.key 1 Pbrt.Bytes encoder; + | None -> (); + end; + () + +[@@@ocaml.warning "-27-30-39"] + +(** {2 Protobuf Decoding} *) + +let rec decode_pb_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.decode_pb_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; + ({ + resource_metrics = v.resource_metrics; + } : export_metrics_service_request) + +let rec decode_pb_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; + ({ + rejected_data_points = v.rejected_data_points; + error_message = v.error_message; + } : export_metrics_partial_success) + +let rec decode_pb_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_pb_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; + ({ + partial_success = v.partial_success; + } : export_metrics_service_response) + +module MetricsService = struct + open Pbrt_services.Value_mode + module Client = struct + open Pbrt_services + + let export : (export_metrics_service_request, unary, export_metrics_service_response, unary) Client.rpc = + (Client.mk_rpc + ~package:["opentelemetry";"proto";"collector";"metrics";"v1"] + ~service_name:"MetricsService" ~rpc_name:"Export" + ~req_mode:Client.Unary + ~res_mode:Client.Unary + ~encode_json_req:encode_json_export_metrics_service_request + ~encode_pb_req:encode_pb_export_metrics_service_request + ~decode_json_res:decode_json_export_metrics_service_response + ~decode_pb_res:decode_pb_export_metrics_service_response + () : (export_metrics_service_request, unary, export_metrics_service_response, unary) Client.rpc) + end + + module Server = struct + open Pbrt_services + + let _rpc_export : (export_metrics_service_request,unary,export_metrics_service_response,unary) Server.rpc = + (Server.mk_rpc ~name:"Export" + ~req_mode:Server.Unary + ~res_mode:Server.Unary + ~encode_json_res:encode_json_export_metrics_service_response + ~encode_pb_res:encode_pb_export_metrics_service_response + ~decode_json_req:decode_json_export_metrics_service_request + ~decode_pb_req:decode_pb_export_metrics_service_request + () : _ Server.rpc) + + let make + ~export + () : _ Server.t = + { Server. + service_name="MetricsService"; + package=["opentelemetry";"proto";"collector";"metrics";"v1"]; + handlers=[ + (export _rpc_export); + ]; + } + end + +end diff --git a/src/proto/metrics_service.mli b/src/proto/metrics_service.mli new file mode 100644 index 00000000..0d244b82 --- /dev/null +++ b/src/proto/metrics_service.mli @@ -0,0 +1,122 @@ + +(** Code for metrics_service.proto *) + +(* generated from "../../vendor/opentelemetry-proto/opentelemetry/proto/collector/metrics/v1/metrics_service.proto", do not edit *) + + + +(** {2 Types} *) + +type export_metrics_service_request = { + resource_metrics : Metrics.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 Basic values} *) + +val default_export_metrics_service_request : + ?resource_metrics:Metrics.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] *) + + +(** {2 Make functions} *) + +val make_export_metrics_service_request : + resource_metrics:Metrics.resource_metrics list -> + unit -> + export_metrics_service_request +(** [make_export_metrics_service_request … ()] is a builder for type [export_metrics_service_request] *) + +val make_export_metrics_partial_success : + rejected_data_points:int64 -> + error_message:string -> + unit -> + export_metrics_partial_success +(** [make_export_metrics_partial_success … ()] is a builder for type [export_metrics_partial_success] *) + +val make_export_metrics_service_response : + ?partial_success:export_metrics_partial_success option -> + unit -> + export_metrics_service_response +(** [make_export_metrics_service_response … ()] is a builder for type [export_metrics_service_response] *) + + +(** {2 Formatters} *) + +val pp_export_metrics_service_request : Format.formatter -> export_metrics_service_request -> unit +(** [pp_export_metrics_service_request v] formats v *) + +val pp_export_metrics_partial_success : Format.formatter -> export_metrics_partial_success -> unit +(** [pp_export_metrics_partial_success v] formats v *) + +val pp_export_metrics_service_response : Format.formatter -> export_metrics_service_response -> unit +(** [pp_export_metrics_service_response v] formats v *) + + +(** {2 Protobuf Encoding} *) + +val encode_pb_export_metrics_service_request : export_metrics_service_request -> Pbrt.Encoder.t -> unit +(** [encode_pb_export_metrics_service_request v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_export_metrics_partial_success : export_metrics_partial_success -> Pbrt.Encoder.t -> unit +(** [encode_pb_export_metrics_partial_success v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_export_metrics_service_response : export_metrics_service_response -> Pbrt.Encoder.t -> unit +(** [encode_pb_export_metrics_service_response v encoder] encodes [v] with the given [encoder] *) + + +(** {2 Protobuf Decoding} *) + +val decode_pb_export_metrics_service_request : Pbrt.Decoder.t -> export_metrics_service_request +(** [decode_pb_export_metrics_service_request decoder] decodes a [export_metrics_service_request] binary value from [decoder] *) + +val decode_pb_export_metrics_partial_success : Pbrt.Decoder.t -> export_metrics_partial_success +(** [decode_pb_export_metrics_partial_success decoder] decodes a [export_metrics_partial_success] binary value from [decoder] *) + +val decode_pb_export_metrics_service_response : Pbrt.Decoder.t -> export_metrics_service_response +(** [decode_pb_export_metrics_service_response decoder] decodes a [export_metrics_service_response] binary value from [decoder] *) + + +(** {2 Services} *) + +(** MetricsService service *) +module MetricsService : sig + open Pbrt_services + open Pbrt_services.Value_mode + + module Client : sig + + val export : (export_metrics_service_request, unary, export_metrics_service_response, unary) Client.rpc + end + + module Server : sig + (** Produce a server implementation from handlers *) + val make : + export:((export_metrics_service_request, unary, export_metrics_service_response, unary) Server.rpc -> 'handler) -> + unit -> 'handler Pbrt_services.Server.t + end +end diff --git a/src/proto/metrics_service_pb.ml b/src/proto/metrics_service_pb.ml deleted file mode 100644 index dd839d9b..00000000 --- a/src/proto/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/proto/metrics_service_pb.mli b/src/proto/metrics_service_pb.mli deleted file mode 100644 index ed839b04..00000000 --- a/src/proto/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/proto/metrics_service_pp.ml b/src/proto/metrics_service_pp.ml deleted file mode 100644 index bb0f7a3b..00000000 --- a/src/proto/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/proto/metrics_service_pp.mli b/src/proto/metrics_service_pp.mli deleted file mode 100644 index 90301da8..00000000 --- a/src/proto/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/proto/metrics_service_types.ml b/src/proto/metrics_service_types.ml deleted file mode 100644 index 8b252a24..00000000 --- a/src/proto/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/proto/metrics_service_types.mli b/src/proto/metrics_service_types.mli deleted file mode 100644 index cbcddfed..00000000 --- a/src/proto/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/proto/metrics_types.ml b/src/proto/metrics_types.ml deleted file mode 100644 index 4cd9c09e..00000000 --- a/src/proto/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/proto/metrics_types.mli b/src/proto/metrics_types.mli deleted file mode 100644 index 8cf43dbf..00000000 --- a/src/proto/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/proto/resource.ml b/src/proto/resource.ml new file mode 100644 index 00000000..cd4b8808 --- /dev/null +++ b/src/proto/resource.ml @@ -0,0 +1,88 @@ +[@@@ocaml.warning "-27-30-39"] + +type resource = { + attributes : Common.key_value list; + dropped_attributes_count : int32; +} + +let rec default_resource + ?attributes:((attributes:Common.key_value list) = []) + ?dropped_attributes_count:((dropped_attributes_count:int32) = 0l) + () : resource = { + attributes; + dropped_attributes_count; +} + +type resource_mutable = { + mutable attributes : Common.key_value list; + mutable dropped_attributes_count : int32; +} + +let default_resource_mutable () : resource_mutable = { + attributes = []; + dropped_attributes_count = 0l; +} + + +(** {2 Make functions} *) + +let rec make_resource + ~(attributes:Common.key_value list) + ~(dropped_attributes_count:int32) + () : resource = { + attributes; + dropped_attributes_count; +} + +[@@@ocaml.warning "-27-30-39"] + +(** {2 Formatters} *) + +let rec pp_resource fmt (v:resource) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "attributes" (Pbrt.Pp.pp_list Common.pp_key_value) fmt v.attributes; + Pbrt.Pp.pp_record_field ~first:false "dropped_attributes_count" Pbrt.Pp.pp_int32 fmt v.dropped_attributes_count; + in + Pbrt.Pp.pp_brk pp_i fmt () + +[@@@ocaml.warning "-27-30-39"] + +(** {2 Protobuf Encoding} *) + +let rec encode_pb_resource (v:resource) encoder = + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested Common.encode_pb_key_value x encoder; + Pbrt.Encoder.key 1 Pbrt.Bytes encoder; + ) v.attributes encoder; + Pbrt.Encoder.int32_as_varint v.dropped_attributes_count encoder; + Pbrt.Encoder.key 2 Pbrt.Varint encoder; + () + +[@@@ocaml.warning "-27-30-39"] + +(** {2 Protobuf Decoding} *) + +let rec decode_pb_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.decode_pb_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; + ({ + attributes = v.attributes; + dropped_attributes_count = v.dropped_attributes_count; + } : resource) diff --git a/src/proto/resource.mli b/src/proto/resource.mli new file mode 100644 index 00000000..8f778015 --- /dev/null +++ b/src/proto/resource.mli @@ -0,0 +1,54 @@ + +(** Code for resource.proto *) + +(* generated from "../../vendor/opentelemetry-proto/opentelemetry/proto/resource/v1/resource.proto", do not edit *) + + + +(** {2 Types} *) + +type resource = { + attributes : Common.key_value list; + dropped_attributes_count : int32; +} + + +(** {2 Basic values} *) + +val default_resource : + ?attributes:Common.key_value list -> + ?dropped_attributes_count:int32 -> + unit -> + resource +(** [default_resource ()] is the default value for type [resource] *) + + +(** {2 Make functions} *) + +val make_resource : + attributes:Common.key_value list -> + dropped_attributes_count:int32 -> + unit -> + resource +(** [make_resource … ()] is a builder for type [resource] *) + + +(** {2 Formatters} *) + +val pp_resource : Format.formatter -> resource -> unit +(** [pp_resource v] formats v *) + + +(** {2 Protobuf Encoding} *) + +val encode_pb_resource : resource -> Pbrt.Encoder.t -> unit +(** [encode_pb_resource v encoder] encodes [v] with the given [encoder] *) + + +(** {2 Protobuf Decoding} *) + +val decode_pb_resource : Pbrt.Decoder.t -> resource +(** [decode_pb_resource decoder] decodes a [resource] binary value from [decoder] *) + + +(** {2 Services} *) diff --git a/src/proto/resource_pb.ml b/src/proto/resource_pb.ml deleted file mode 100644 index ac8a051f..00000000 --- a/src/proto/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/proto/resource_pb.mli b/src/proto/resource_pb.mli deleted file mode 100644 index 81136cbe..00000000 --- a/src/proto/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/proto/resource_pp.ml b/src/proto/resource_pp.ml deleted file mode 100644 index 299fcdfc..00000000 --- a/src/proto/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/proto/resource_pp.mli b/src/proto/resource_pp.mli deleted file mode 100644 index 60d1f43a..00000000 --- a/src/proto/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/proto/resource_types.ml b/src/proto/resource_types.ml deleted file mode 100644 index 74b42266..00000000 --- a/src/proto/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/proto/resource_types.mli b/src/proto/resource_types.mli deleted file mode 100644 index ff01acd2..00000000 --- a/src/proto/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/proto/status.ml b/src/proto/status.ml new file mode 100644 index 00000000..0bd0974b --- /dev/null +++ b/src/proto/status.ml @@ -0,0 +1,104 @@ +[@@@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; +} + +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 = []; +} + + +(** {2 Make functions} *) + +let rec make_status + ~(code:int32) + ~(message:bytes) + ~(details:bytes list) + () : status = { + code; + message; + details; +} + +[@@@ocaml.warning "-27-30-39"] + +(** {2 Formatters} *) + +let rec pp_status fmt (v:status) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "code" Pbrt.Pp.pp_int32 fmt v.code; + Pbrt.Pp.pp_record_field ~first:false "message" Pbrt.Pp.pp_bytes fmt v.message; + Pbrt.Pp.pp_record_field ~first:false "details" (Pbrt.Pp.pp_list Pbrt.Pp.pp_bytes) fmt v.details; + in + Pbrt.Pp.pp_brk pp_i fmt () + +[@@@ocaml.warning "-27-30-39"] + +(** {2 Protobuf Encoding} *) + +let rec encode_pb_status (v:status) encoder = + Pbrt.Encoder.int32_as_varint v.code encoder; + Pbrt.Encoder.key 1 Pbrt.Varint encoder; + Pbrt.Encoder.bytes v.message encoder; + Pbrt.Encoder.key 2 Pbrt.Bytes encoder; + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.bytes x encoder; + Pbrt.Encoder.key 3 Pbrt.Bytes encoder; + ) v.details encoder; + () + +[@@@ocaml.warning "-27-30-39"] + +(** {2 Protobuf Decoding} *) + +let rec decode_pb_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; + ({ + code = v.code; + message = v.message; + details = v.details; + } : status) diff --git a/src/proto/status.mli b/src/proto/status.mli new file mode 100644 index 00000000..1123c8bf --- /dev/null +++ b/src/proto/status.mli @@ -0,0 +1,57 @@ + +(** Code for status.proto *) + +(* generated from "status.proto", do not edit *) + + + +(** {2 Types} *) + +type status = { + code : int32; + message : bytes; + details : bytes list; +} + + +(** {2 Basic values} *) + +val default_status : + ?code:int32 -> + ?message:bytes -> + ?details:bytes list -> + unit -> + status +(** [default_status ()] is the default value for type [status] *) + + +(** {2 Make functions} *) + +val make_status : + code:int32 -> + message:bytes -> + details:bytes list -> + unit -> + status +(** [make_status … ()] is a builder for type [status] *) + + +(** {2 Formatters} *) + +val pp_status : Format.formatter -> status -> unit +(** [pp_status v] formats v *) + + +(** {2 Protobuf Encoding} *) + +val encode_pb_status : status -> Pbrt.Encoder.t -> unit +(** [encode_pb_status v encoder] encodes [v] with the given [encoder] *) + + +(** {2 Protobuf Decoding} *) + +val decode_pb_status : Pbrt.Decoder.t -> status +(** [decode_pb_status decoder] decodes a [status] binary value from [decoder] *) + + +(** {2 Services} *) diff --git a/src/proto/status_pb.ml b/src/proto/status_pb.ml deleted file mode 100644 index 3fba0000..00000000 --- a/src/proto/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/proto/status_pb.mli b/src/proto/status_pb.mli deleted file mode 100644 index e6bcfaed..00000000 --- a/src/proto/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/proto/status_pp.ml b/src/proto/status_pp.ml deleted file mode 100644 index c5df29d9..00000000 --- a/src/proto/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/proto/status_pp.mli b/src/proto/status_pp.mli deleted file mode 100644 index cb19e3bd..00000000 --- a/src/proto/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/proto/status_types.ml b/src/proto/status_types.ml deleted file mode 100644 index 14af622b..00000000 --- a/src/proto/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/proto/status_types.mli b/src/proto/status_types.mli deleted file mode 100644 index 9947bc58..00000000 --- a/src/proto/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/proto/trace.ml b/src/proto/trace.ml new file mode 100644 index 00000000..9e35831e --- /dev/null +++ b/src/proto/trace.ml @@ -0,0 +1,905 @@ +[@@@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.key_value list; + dropped_attributes_count : int32; +} + +type span_link = { + trace_id : bytes; + span_id : bytes; + trace_state : string; + attributes : Common.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.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.instrumentation_scope option; + spans : span list; + schema_url : string; +} + +type resource_spans = { + resource : Resource.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.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.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.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.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.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; +} + +type span_event_mutable = { + mutable time_unix_nano : int64; + mutable name : string; + mutable attributes : Common.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.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 : status_status_code; +} + +let default_status_mutable () : status_mutable = { + message = ""; + code = 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 : span_span_kind; + mutable start_time_unix_nano : int64; + mutable end_time_unix_nano : int64; + mutable attributes : Common.key_value list; + mutable dropped_attributes_count : int32; + mutable events : span_event list; + mutable dropped_events_count : int32; + mutable links : span_link list; + mutable dropped_links_count : int32; + mutable status : 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 = 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.instrumentation_scope option; + mutable spans : 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.resource option; + mutable scope_spans : 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 : resource_spans list; +} + +let default_traces_data_mutable () : traces_data_mutable = { + resource_spans = []; +} + + +(** {2 Make functions} *) + + +let rec make_span_event + ~(time_unix_nano:int64) + ~(name:string) + ~(attributes:Common.key_value list) + ~(dropped_attributes_count:int32) + () : span_event = { + time_unix_nano; + name; + attributes; + dropped_attributes_count; +} + +let rec make_span_link + ~(trace_id:bytes) + ~(span_id:bytes) + ~(trace_state:string) + ~(attributes:Common.key_value list) + ~(dropped_attributes_count:int32) + () : span_link = { + trace_id; + span_id; + trace_state; + attributes; + dropped_attributes_count; +} + + +let rec make_status + ~(message:string) + ~(code:status_status_code) + () : status = { + message; + code; +} + +let rec make_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.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: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 make_scope_spans + ?scope:((scope:Common.instrumentation_scope option) = None) + ~(spans:span list) + ~(schema_url:string) + () : scope_spans = { + scope; + spans; + schema_url; +} + +let rec make_resource_spans + ?resource:((resource:Resource.resource option) = None) + ~(scope_spans:scope_spans list) + ~(schema_url:string) + () : resource_spans = { + resource; + scope_spans; + schema_url; +} + +let rec make_traces_data + ~(resource_spans:resource_spans list) + () : traces_data = { + resource_spans; +} + +[@@@ocaml.warning "-27-30-39"] + +(** {2 Formatters} *) + +let rec pp_span_span_kind fmt (v:span_span_kind) = + match v with + | Span_kind_unspecified -> Format.fprintf fmt "Span_kind_unspecified" + | Span_kind_internal -> Format.fprintf fmt "Span_kind_internal" + | Span_kind_server -> Format.fprintf fmt "Span_kind_server" + | Span_kind_client -> Format.fprintf fmt "Span_kind_client" + | Span_kind_producer -> Format.fprintf fmt "Span_kind_producer" + | Span_kind_consumer -> Format.fprintf fmt "Span_kind_consumer" + +let rec pp_span_event fmt (v:span_event) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.time_unix_nano; + Pbrt.Pp.pp_record_field ~first:false "name" Pbrt.Pp.pp_string fmt v.name; + Pbrt.Pp.pp_record_field ~first:false "attributes" (Pbrt.Pp.pp_list Common.pp_key_value) fmt v.attributes; + Pbrt.Pp.pp_record_field ~first:false "dropped_attributes_count" Pbrt.Pp.pp_int32 fmt v.dropped_attributes_count; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_span_link fmt (v:span_link) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "trace_id" Pbrt.Pp.pp_bytes fmt v.trace_id; + Pbrt.Pp.pp_record_field ~first:false "span_id" Pbrt.Pp.pp_bytes fmt v.span_id; + Pbrt.Pp.pp_record_field ~first:false "trace_state" Pbrt.Pp.pp_string fmt v.trace_state; + Pbrt.Pp.pp_record_field ~first:false "attributes" (Pbrt.Pp.pp_list Common.pp_key_value) fmt v.attributes; + Pbrt.Pp.pp_record_field ~first:false "dropped_attributes_count" Pbrt.Pp.pp_int32 fmt v.dropped_attributes_count; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_status_status_code fmt (v:status_status_code) = + match v with + | Status_code_unset -> Format.fprintf fmt "Status_code_unset" + | Status_code_ok -> Format.fprintf fmt "Status_code_ok" + | Status_code_error -> Format.fprintf fmt "Status_code_error" + +let rec pp_status fmt (v:status) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "message" Pbrt.Pp.pp_string fmt v.message; + Pbrt.Pp.pp_record_field ~first:false "code" pp_status_status_code fmt v.code; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_span fmt (v:span) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "trace_id" Pbrt.Pp.pp_bytes fmt v.trace_id; + Pbrt.Pp.pp_record_field ~first:false "span_id" Pbrt.Pp.pp_bytes fmt v.span_id; + Pbrt.Pp.pp_record_field ~first:false "trace_state" Pbrt.Pp.pp_string fmt v.trace_state; + Pbrt.Pp.pp_record_field ~first:false "parent_span_id" Pbrt.Pp.pp_bytes fmt v.parent_span_id; + Pbrt.Pp.pp_record_field ~first:false "name" Pbrt.Pp.pp_string fmt v.name; + Pbrt.Pp.pp_record_field ~first:false "kind" pp_span_span_kind fmt v.kind; + Pbrt.Pp.pp_record_field ~first:false "start_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.start_time_unix_nano; + Pbrt.Pp.pp_record_field ~first:false "end_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.end_time_unix_nano; + Pbrt.Pp.pp_record_field ~first:false "attributes" (Pbrt.Pp.pp_list Common.pp_key_value) fmt v.attributes; + Pbrt.Pp.pp_record_field ~first:false "dropped_attributes_count" Pbrt.Pp.pp_int32 fmt v.dropped_attributes_count; + Pbrt.Pp.pp_record_field ~first:false "events" (Pbrt.Pp.pp_list pp_span_event) fmt v.events; + Pbrt.Pp.pp_record_field ~first:false "dropped_events_count" Pbrt.Pp.pp_int32 fmt v.dropped_events_count; + Pbrt.Pp.pp_record_field ~first:false "links" (Pbrt.Pp.pp_list pp_span_link) fmt v.links; + Pbrt.Pp.pp_record_field ~first:false "dropped_links_count" Pbrt.Pp.pp_int32 fmt v.dropped_links_count; + Pbrt.Pp.pp_record_field ~first:false "status" (Pbrt.Pp.pp_option pp_status) fmt v.status; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_scope_spans fmt (v:scope_spans) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "scope" (Pbrt.Pp.pp_option Common.pp_instrumentation_scope) fmt v.scope; + Pbrt.Pp.pp_record_field ~first:false "spans" (Pbrt.Pp.pp_list pp_span) fmt v.spans; + Pbrt.Pp.pp_record_field ~first:false "schema_url" Pbrt.Pp.pp_string fmt v.schema_url; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_resource_spans fmt (v:resource_spans) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "resource" (Pbrt.Pp.pp_option Resource.pp_resource) fmt v.resource; + Pbrt.Pp.pp_record_field ~first:false "scope_spans" (Pbrt.Pp.pp_list pp_scope_spans) fmt v.scope_spans; + Pbrt.Pp.pp_record_field ~first:false "schema_url" Pbrt.Pp.pp_string fmt v.schema_url; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_traces_data fmt (v:traces_data) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "resource_spans" (Pbrt.Pp.pp_list pp_resource_spans) fmt v.resource_spans; + in + Pbrt.Pp.pp_brk pp_i fmt () + +[@@@ocaml.warning "-27-30-39"] + +(** {2 Protobuf Encoding} *) + +let rec encode_pb_span_span_kind (v:span_span_kind) encoder = + match v with + | Span_kind_unspecified -> Pbrt.Encoder.int_as_varint (0) encoder + | Span_kind_internal -> Pbrt.Encoder.int_as_varint 1 encoder + | Span_kind_server -> Pbrt.Encoder.int_as_varint 2 encoder + | Span_kind_client -> Pbrt.Encoder.int_as_varint 3 encoder + | Span_kind_producer -> Pbrt.Encoder.int_as_varint 4 encoder + | Span_kind_consumer -> Pbrt.Encoder.int_as_varint 5 encoder + +let rec encode_pb_span_event (v:span_event) encoder = + Pbrt.Encoder.int64_as_bits64 v.time_unix_nano encoder; + Pbrt.Encoder.key 1 Pbrt.Bits64 encoder; + Pbrt.Encoder.string v.name encoder; + Pbrt.Encoder.key 2 Pbrt.Bytes encoder; + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested Common.encode_pb_key_value x encoder; + Pbrt.Encoder.key 3 Pbrt.Bytes encoder; + ) v.attributes encoder; + Pbrt.Encoder.int32_as_varint v.dropped_attributes_count encoder; + Pbrt.Encoder.key 4 Pbrt.Varint encoder; + () + +let rec encode_pb_span_link (v:span_link) encoder = + Pbrt.Encoder.bytes v.trace_id encoder; + Pbrt.Encoder.key 1 Pbrt.Bytes encoder; + Pbrt.Encoder.bytes v.span_id encoder; + Pbrt.Encoder.key 2 Pbrt.Bytes encoder; + Pbrt.Encoder.string v.trace_state encoder; + Pbrt.Encoder.key 3 Pbrt.Bytes encoder; + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested Common.encode_pb_key_value x encoder; + Pbrt.Encoder.key 4 Pbrt.Bytes encoder; + ) v.attributes encoder; + Pbrt.Encoder.int32_as_varint v.dropped_attributes_count encoder; + Pbrt.Encoder.key 5 Pbrt.Varint encoder; + () + +let rec encode_pb_status_status_code (v:status_status_code) encoder = + match v with + | Status_code_unset -> Pbrt.Encoder.int_as_varint (0) encoder + | Status_code_ok -> Pbrt.Encoder.int_as_varint 1 encoder + | Status_code_error -> Pbrt.Encoder.int_as_varint 2 encoder + +let rec encode_pb_status (v:status) encoder = + Pbrt.Encoder.string v.message encoder; + Pbrt.Encoder.key 2 Pbrt.Bytes encoder; + encode_pb_status_status_code v.code encoder; + Pbrt.Encoder.key 3 Pbrt.Varint encoder; + () + +let rec encode_pb_span (v:span) encoder = + Pbrt.Encoder.bytes v.trace_id encoder; + Pbrt.Encoder.key 1 Pbrt.Bytes encoder; + Pbrt.Encoder.bytes v.span_id encoder; + Pbrt.Encoder.key 2 Pbrt.Bytes encoder; + Pbrt.Encoder.string v.trace_state encoder; + Pbrt.Encoder.key 3 Pbrt.Bytes encoder; + Pbrt.Encoder.bytes v.parent_span_id encoder; + Pbrt.Encoder.key 4 Pbrt.Bytes encoder; + Pbrt.Encoder.string v.name encoder; + Pbrt.Encoder.key 5 Pbrt.Bytes encoder; + encode_pb_span_span_kind v.kind encoder; + Pbrt.Encoder.key 6 Pbrt.Varint encoder; + Pbrt.Encoder.int64_as_bits64 v.start_time_unix_nano encoder; + Pbrt.Encoder.key 7 Pbrt.Bits64 encoder; + Pbrt.Encoder.int64_as_bits64 v.end_time_unix_nano encoder; + Pbrt.Encoder.key 8 Pbrt.Bits64 encoder; + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested Common.encode_pb_key_value x encoder; + Pbrt.Encoder.key 9 Pbrt.Bytes encoder; + ) v.attributes encoder; + Pbrt.Encoder.int32_as_varint v.dropped_attributes_count encoder; + Pbrt.Encoder.key 10 Pbrt.Varint encoder; + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested encode_pb_span_event x encoder; + Pbrt.Encoder.key 11 Pbrt.Bytes encoder; + ) v.events encoder; + Pbrt.Encoder.int32_as_varint v.dropped_events_count encoder; + Pbrt.Encoder.key 12 Pbrt.Varint encoder; + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested encode_pb_span_link x encoder; + Pbrt.Encoder.key 13 Pbrt.Bytes encoder; + ) v.links encoder; + Pbrt.Encoder.int32_as_varint v.dropped_links_count encoder; + Pbrt.Encoder.key 14 Pbrt.Varint encoder; + begin match v.status with + | Some x -> + Pbrt.Encoder.nested encode_pb_status x encoder; + Pbrt.Encoder.key 15 Pbrt.Bytes encoder; + | None -> (); + end; + () + +let rec encode_pb_scope_spans (v:scope_spans) encoder = + begin match v.scope with + | Some x -> + Pbrt.Encoder.nested Common.encode_pb_instrumentation_scope x encoder; + Pbrt.Encoder.key 1 Pbrt.Bytes encoder; + | None -> (); + end; + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested encode_pb_span x encoder; + Pbrt.Encoder.key 2 Pbrt.Bytes encoder; + ) v.spans encoder; + Pbrt.Encoder.string v.schema_url encoder; + Pbrt.Encoder.key 3 Pbrt.Bytes encoder; + () + +let rec encode_pb_resource_spans (v:resource_spans) encoder = + begin match v.resource with + | Some x -> + Pbrt.Encoder.nested Resource.encode_pb_resource x encoder; + Pbrt.Encoder.key 1 Pbrt.Bytes encoder; + | None -> (); + end; + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested encode_pb_scope_spans x encoder; + Pbrt.Encoder.key 2 Pbrt.Bytes encoder; + ) v.scope_spans encoder; + Pbrt.Encoder.string v.schema_url encoder; + Pbrt.Encoder.key 3 Pbrt.Bytes encoder; + () + +let rec encode_pb_traces_data (v:traces_data) encoder = + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested encode_pb_resource_spans x encoder; + Pbrt.Encoder.key 1 Pbrt.Bytes encoder; + ) v.resource_spans encoder; + () + +[@@@ocaml.warning "-27-30-39"] + +(** {2 Protobuf Decoding} *) + +let rec decode_pb_span_span_kind d = + match Pbrt.Decoder.int_as_varint d with + | 0 -> (Span_kind_unspecified:span_span_kind) + | 1 -> (Span_kind_internal:span_span_kind) + | 2 -> (Span_kind_server:span_span_kind) + | 3 -> (Span_kind_client:span_span_kind) + | 4 -> (Span_kind_producer:span_span_kind) + | 5 -> (Span_kind_consumer:span_span_kind) + | _ -> Pbrt.Decoder.malformed_variant "span_span_kind" + +let rec decode_pb_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.decode_pb_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; + ({ + time_unix_nano = v.time_unix_nano; + name = v.name; + attributes = v.attributes; + dropped_attributes_count = v.dropped_attributes_count; + } : span_event) + +let rec decode_pb_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.decode_pb_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_id = v.trace_id; + span_id = v.span_id; + trace_state = v.trace_state; + attributes = v.attributes; + dropped_attributes_count = v.dropped_attributes_count; + } : span_link) + +let rec decode_pb_status_status_code d = + match Pbrt.Decoder.int_as_varint d with + | 0 -> (Status_code_unset:status_status_code) + | 1 -> (Status_code_ok:status_status_code) + | 2 -> (Status_code_error:status_status_code) + | _ -> Pbrt.Decoder.malformed_variant "status_status_code" + +let rec decode_pb_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_pb_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; + ({ + message = v.message; + code = v.code; + } : status) + +let rec decode_pb_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_pb_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.decode_pb_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_pb_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_pb_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_pb_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_id = v.trace_id; + span_id = v.span_id; + trace_state = v.trace_state; + parent_span_id = v.parent_span_id; + name = v.name; + kind = v.kind; + start_time_unix_nano = v.start_time_unix_nano; + end_time_unix_nano = v.end_time_unix_nano; + attributes = v.attributes; + dropped_attributes_count = v.dropped_attributes_count; + events = v.events; + dropped_events_count = v.dropped_events_count; + links = v.links; + dropped_links_count = v.dropped_links_count; + status = v.status; + } : span) + +let rec decode_pb_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.decode_pb_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_pb_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; + ({ + scope = v.scope; + spans = v.spans; + schema_url = v.schema_url; + } : scope_spans) + +let rec decode_pb_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.decode_pb_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_pb_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; + ({ + resource = v.resource; + scope_spans = v.scope_spans; + schema_url = v.schema_url; + } : resource_spans) + +let rec decode_pb_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_pb_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; + ({ + resource_spans = v.resource_spans; + } : traces_data) diff --git a/src/proto/trace.mli b/src/proto/trace.mli new file mode 100644 index 00000000..b405cbea --- /dev/null +++ b/src/proto/trace.mli @@ -0,0 +1,318 @@ + +(** Code for trace.proto *) + +(* generated from "../../vendor/opentelemetry-proto/opentelemetry/proto/trace/v1/trace.proto", do not edit *) + + + +(** {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.key_value list; + dropped_attributes_count : int32; +} + +type span_link = { + trace_id : bytes; + span_id : bytes; + trace_state : string; + attributes : Common.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.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.instrumentation_scope option; + spans : span list; + schema_url : string; +} + +type resource_spans = { + resource : Resource.resource option; + scope_spans : scope_spans list; + schema_url : string; +} + +type traces_data = { + resource_spans : resource_spans list; +} + + +(** {2 Basic 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.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.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.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.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.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] *) + + +(** {2 Make functions} *) + + +val make_span_event : + time_unix_nano:int64 -> + name:string -> + attributes:Common.key_value list -> + dropped_attributes_count:int32 -> + unit -> + span_event +(** [make_span_event … ()] is a builder for type [span_event] *) + +val make_span_link : + trace_id:bytes -> + span_id:bytes -> + trace_state:string -> + attributes:Common.key_value list -> + dropped_attributes_count:int32 -> + unit -> + span_link +(** [make_span_link … ()] is a builder for type [span_link] *) + + +val make_status : + message:string -> + code:status_status_code -> + unit -> + status +(** [make_status … ()] is a builder for type [status] *) + +val make_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.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 +(** [make_span … ()] is a builder for type [span] *) + +val make_scope_spans : + ?scope:Common.instrumentation_scope option -> + spans:span list -> + schema_url:string -> + unit -> + scope_spans +(** [make_scope_spans … ()] is a builder for type [scope_spans] *) + +val make_resource_spans : + ?resource:Resource.resource option -> + scope_spans:scope_spans list -> + schema_url:string -> + unit -> + resource_spans +(** [make_resource_spans … ()] is a builder for type [resource_spans] *) + +val make_traces_data : + resource_spans:resource_spans list -> + unit -> + traces_data +(** [make_traces_data … ()] is a builder for type [traces_data] *) + + +(** {2 Formatters} *) + +val pp_span_span_kind : Format.formatter -> span_span_kind -> unit +(** [pp_span_span_kind v] formats v *) + +val pp_span_event : Format.formatter -> span_event -> unit +(** [pp_span_event v] formats v *) + +val pp_span_link : Format.formatter -> span_link -> unit +(** [pp_span_link v] formats v *) + +val pp_status_status_code : Format.formatter -> status_status_code -> unit +(** [pp_status_status_code v] formats v *) + +val pp_status : Format.formatter -> status -> unit +(** [pp_status v] formats v *) + +val pp_span : Format.formatter -> span -> unit +(** [pp_span v] formats v *) + +val pp_scope_spans : Format.formatter -> scope_spans -> unit +(** [pp_scope_spans v] formats v *) + +val pp_resource_spans : Format.formatter -> resource_spans -> unit +(** [pp_resource_spans v] formats v *) + +val pp_traces_data : Format.formatter -> traces_data -> unit +(** [pp_traces_data v] formats v *) + + +(** {2 Protobuf Encoding} *) + +val encode_pb_span_span_kind : span_span_kind -> Pbrt.Encoder.t -> unit +(** [encode_pb_span_span_kind v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_span_event : span_event -> Pbrt.Encoder.t -> unit +(** [encode_pb_span_event v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_span_link : span_link -> Pbrt.Encoder.t -> unit +(** [encode_pb_span_link v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_status_status_code : status_status_code -> Pbrt.Encoder.t -> unit +(** [encode_pb_status_status_code v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_status : status -> Pbrt.Encoder.t -> unit +(** [encode_pb_status v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_span : span -> Pbrt.Encoder.t -> unit +(** [encode_pb_span v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_scope_spans : scope_spans -> Pbrt.Encoder.t -> unit +(** [encode_pb_scope_spans v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_resource_spans : resource_spans -> Pbrt.Encoder.t -> unit +(** [encode_pb_resource_spans v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_traces_data : traces_data -> Pbrt.Encoder.t -> unit +(** [encode_pb_traces_data v encoder] encodes [v] with the given [encoder] *) + + +(** {2 Protobuf Decoding} *) + +val decode_pb_span_span_kind : Pbrt.Decoder.t -> span_span_kind +(** [decode_pb_span_span_kind decoder] decodes a [span_span_kind] binary value from [decoder] *) + +val decode_pb_span_event : Pbrt.Decoder.t -> span_event +(** [decode_pb_span_event decoder] decodes a [span_event] binary value from [decoder] *) + +val decode_pb_span_link : Pbrt.Decoder.t -> span_link +(** [decode_pb_span_link decoder] decodes a [span_link] binary value from [decoder] *) + +val decode_pb_status_status_code : Pbrt.Decoder.t -> status_status_code +(** [decode_pb_status_status_code decoder] decodes a [status_status_code] binary value from [decoder] *) + +val decode_pb_status : Pbrt.Decoder.t -> status +(** [decode_pb_status decoder] decodes a [status] binary value from [decoder] *) + +val decode_pb_span : Pbrt.Decoder.t -> span +(** [decode_pb_span decoder] decodes a [span] binary value from [decoder] *) + +val decode_pb_scope_spans : Pbrt.Decoder.t -> scope_spans +(** [decode_pb_scope_spans decoder] decodes a [scope_spans] binary value from [decoder] *) + +val decode_pb_resource_spans : Pbrt.Decoder.t -> resource_spans +(** [decode_pb_resource_spans decoder] decodes a [resource_spans] binary value from [decoder] *) + +val decode_pb_traces_data : Pbrt.Decoder.t -> traces_data +(** [decode_pb_traces_data decoder] decodes a [traces_data] binary value from [decoder] *) + + +(** {2 Services} *) diff --git a/src/proto/trace_pb.ml b/src/proto/trace_pb.ml deleted file mode 100644 index 1d2acfd9..00000000 --- a/src/proto/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/proto/trace_pb.mli b/src/proto/trace_pb.mli deleted file mode 100644 index 8e93dba6..00000000 --- a/src/proto/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/proto/trace_pp.ml b/src/proto/trace_pp.ml deleted file mode 100644 index 97faa78b..00000000 --- a/src/proto/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/proto/trace_pp.mli b/src/proto/trace_pp.mli deleted file mode 100644 index 047f5207..00000000 --- a/src/proto/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/proto/trace_service.ml b/src/proto/trace_service.ml new file mode 100644 index 00000000..faab8ffc --- /dev/null +++ b/src/proto/trace_service.ml @@ -0,0 +1,243 @@ +[@@@ocaml.warning "-27-30-39"] + +type export_trace_service_request = { + resource_spans : Trace.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.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; +} + +type export_trace_service_request_mutable = { + mutable resource_spans : Trace.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 : export_trace_partial_success option; +} + +let default_export_trace_service_response_mutable () : export_trace_service_response_mutable = { + partial_success = None; +} + + +(** {2 Make functions} *) + +let rec make_export_trace_service_request + ~(resource_spans:Trace.resource_spans list) + () : export_trace_service_request = { + resource_spans; +} + +let rec make_export_trace_partial_success + ~(rejected_spans:int64) + ~(error_message:string) + () : export_trace_partial_success = { + rejected_spans; + error_message; +} + +let rec make_export_trace_service_response + ?partial_success:((partial_success:export_trace_partial_success option) = None) + () : export_trace_service_response = { + partial_success; +} + +[@@@ocaml.warning "-27-30-39"] + +(** {2 Formatters} *) + +let rec pp_export_trace_service_request fmt (v:export_trace_service_request) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "resource_spans" (Pbrt.Pp.pp_list Trace.pp_resource_spans) fmt v.resource_spans; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_export_trace_partial_success fmt (v:export_trace_partial_success) = + let pp_i fmt () = + Pbrt.Pp.pp_record_field ~first:true "rejected_spans" Pbrt.Pp.pp_int64 fmt v.rejected_spans; + Pbrt.Pp.pp_record_field ~first:false "error_message" Pbrt.Pp.pp_string fmt v.error_message; + in + Pbrt.Pp.pp_brk pp_i fmt () + +let rec pp_export_trace_service_response fmt (v: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.partial_success; + in + Pbrt.Pp.pp_brk pp_i fmt () + +[@@@ocaml.warning "-27-30-39"] + +(** {2 Protobuf Encoding} *) + +let rec encode_pb_export_trace_service_request (v:export_trace_service_request) encoder = + Pbrt.List_util.rev_iter_with (fun x encoder -> + Pbrt.Encoder.nested Trace.encode_pb_resource_spans x encoder; + Pbrt.Encoder.key 1 Pbrt.Bytes encoder; + ) v.resource_spans encoder; + () + +let rec encode_pb_export_trace_partial_success (v:export_trace_partial_success) encoder = + Pbrt.Encoder.int64_as_varint v.rejected_spans encoder; + Pbrt.Encoder.key 1 Pbrt.Varint encoder; + Pbrt.Encoder.string v.error_message encoder; + Pbrt.Encoder.key 2 Pbrt.Bytes encoder; + () + +let rec encode_pb_export_trace_service_response (v:export_trace_service_response) encoder = + begin match v.partial_success with + | Some x -> + Pbrt.Encoder.nested encode_pb_export_trace_partial_success x encoder; + Pbrt.Encoder.key 1 Pbrt.Bytes encoder; + | None -> (); + end; + () + +[@@@ocaml.warning "-27-30-39"] + +(** {2 Protobuf Decoding} *) + +let rec decode_pb_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.decode_pb_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; + ({ + resource_spans = v.resource_spans; + } : export_trace_service_request) + +let rec decode_pb_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; + ({ + rejected_spans = v.rejected_spans; + error_message = v.error_message; + } : export_trace_partial_success) + +let rec decode_pb_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_pb_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; + ({ + partial_success = v.partial_success; + } : export_trace_service_response) + +module TraceService = struct + open Pbrt_services.Value_mode + module Client = struct + open Pbrt_services + + let export : (export_trace_service_request, unary, export_trace_service_response, unary) Client.rpc = + (Client.mk_rpc + ~package:["opentelemetry";"proto";"collector";"trace";"v1"] + ~service_name:"TraceService" ~rpc_name:"Export" + ~req_mode:Client.Unary + ~res_mode:Client.Unary + ~encode_json_req:encode_json_export_trace_service_request + ~encode_pb_req:encode_pb_export_trace_service_request + ~decode_json_res:decode_json_export_trace_service_response + ~decode_pb_res:decode_pb_export_trace_service_response + () : (export_trace_service_request, unary, export_trace_service_response, unary) Client.rpc) + end + + module Server = struct + open Pbrt_services + + let _rpc_export : (export_trace_service_request,unary,export_trace_service_response,unary) Server.rpc = + (Server.mk_rpc ~name:"Export" + ~req_mode:Server.Unary + ~res_mode:Server.Unary + ~encode_json_res:encode_json_export_trace_service_response + ~encode_pb_res:encode_pb_export_trace_service_response + ~decode_json_req:decode_json_export_trace_service_request + ~decode_pb_req:decode_pb_export_trace_service_request + () : _ Server.rpc) + + let make + ~export + () : _ Server.t = + { Server. + service_name="TraceService"; + package=["opentelemetry";"proto";"collector";"trace";"v1"]; + handlers=[ + (export _rpc_export); + ]; + } + end + +end diff --git a/src/proto/trace_service.mli b/src/proto/trace_service.mli new file mode 100644 index 00000000..f563aba3 --- /dev/null +++ b/src/proto/trace_service.mli @@ -0,0 +1,122 @@ + +(** Code for trace_service.proto *) + +(* generated from "../../vendor/opentelemetry-proto/opentelemetry/proto/collector/trace/v1/trace_service.proto", do not edit *) + + + +(** {2 Types} *) + +type export_trace_service_request = { + resource_spans : Trace.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 Basic values} *) + +val default_export_trace_service_request : + ?resource_spans:Trace.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] *) + + +(** {2 Make functions} *) + +val make_export_trace_service_request : + resource_spans:Trace.resource_spans list -> + unit -> + export_trace_service_request +(** [make_export_trace_service_request … ()] is a builder for type [export_trace_service_request] *) + +val make_export_trace_partial_success : + rejected_spans:int64 -> + error_message:string -> + unit -> + export_trace_partial_success +(** [make_export_trace_partial_success … ()] is a builder for type [export_trace_partial_success] *) + +val make_export_trace_service_response : + ?partial_success:export_trace_partial_success option -> + unit -> + export_trace_service_response +(** [make_export_trace_service_response … ()] is a builder for type [export_trace_service_response] *) + + +(** {2 Formatters} *) + +val pp_export_trace_service_request : Format.formatter -> export_trace_service_request -> unit +(** [pp_export_trace_service_request v] formats v *) + +val pp_export_trace_partial_success : Format.formatter -> export_trace_partial_success -> unit +(** [pp_export_trace_partial_success v] formats v *) + +val pp_export_trace_service_response : Format.formatter -> export_trace_service_response -> unit +(** [pp_export_trace_service_response v] formats v *) + + +(** {2 Protobuf Encoding} *) + +val encode_pb_export_trace_service_request : export_trace_service_request -> Pbrt.Encoder.t -> unit +(** [encode_pb_export_trace_service_request v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_export_trace_partial_success : export_trace_partial_success -> Pbrt.Encoder.t -> unit +(** [encode_pb_export_trace_partial_success v encoder] encodes [v] with the given [encoder] *) + +val encode_pb_export_trace_service_response : export_trace_service_response -> Pbrt.Encoder.t -> unit +(** [encode_pb_export_trace_service_response v encoder] encodes [v] with the given [encoder] *) + + +(** {2 Protobuf Decoding} *) + +val decode_pb_export_trace_service_request : Pbrt.Decoder.t -> export_trace_service_request +(** [decode_pb_export_trace_service_request decoder] decodes a [export_trace_service_request] binary value from [decoder] *) + +val decode_pb_export_trace_partial_success : Pbrt.Decoder.t -> export_trace_partial_success +(** [decode_pb_export_trace_partial_success decoder] decodes a [export_trace_partial_success] binary value from [decoder] *) + +val decode_pb_export_trace_service_response : Pbrt.Decoder.t -> export_trace_service_response +(** [decode_pb_export_trace_service_response decoder] decodes a [export_trace_service_response] binary value from [decoder] *) + + +(** {2 Services} *) + +(** TraceService service *) +module TraceService : sig + open Pbrt_services + open Pbrt_services.Value_mode + + module Client : sig + + val export : (export_trace_service_request, unary, export_trace_service_response, unary) Client.rpc + end + + module Server : sig + (** Produce a server implementation from handlers *) + val make : + export:((export_trace_service_request, unary, export_trace_service_response, unary) Server.rpc -> 'handler) -> + unit -> 'handler Pbrt_services.Server.t + end +end diff --git a/src/proto/trace_service_pb.ml b/src/proto/trace_service_pb.ml deleted file mode 100644 index 68733bcf..00000000 --- a/src/proto/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/proto/trace_service_pb.mli b/src/proto/trace_service_pb.mli deleted file mode 100644 index afd94a31..00000000 --- a/src/proto/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/proto/trace_service_pp.ml b/src/proto/trace_service_pp.ml deleted file mode 100644 index edc069f2..00000000 --- a/src/proto/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/proto/trace_service_pp.mli b/src/proto/trace_service_pp.mli deleted file mode 100644 index d7d52f99..00000000 --- a/src/proto/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/proto/trace_service_types.ml b/src/proto/trace_service_types.ml deleted file mode 100644 index 6476d53c..00000000 --- a/src/proto/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/proto/trace_service_types.mli b/src/proto/trace_service_types.mli deleted file mode 100644 index e7480e77..00000000 --- a/src/proto/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/proto/trace_types.ml b/src/proto/trace_types.ml deleted file mode 100644 index 3e51df35..00000000 --- a/src/proto/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/proto/trace_types.mli b/src/proto/trace_types.mli deleted file mode 100644 index ef7ac6dc..00000000 --- a/src/proto/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 f6afc3df1ca99adb272a4c433571b090d4f89c08 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Mon, 11 Dec 2023 16:51:49 -0500 Subject: [PATCH 3/6] use ocaml-protoc 3.0.1 for codegen --- .../opentelemetry_client_cohttp_lwt.ml | 8 +- .../opentelemetry_client_ocurl.ml | 8 +- src/core/opentelemetry.ml | 78 +++---------------- src/proto/common.mli | 3 - src/proto/logs.mli | 3 - src/proto/logs_service.ml | 45 ----------- src/proto/logs_service.mli | 21 ----- src/proto/metrics.mli | 3 - src/proto/metrics_service.ml | 45 ----------- src/proto/metrics_service.mli | 21 ----- src/proto/resource.mli | 3 - src/proto/status.mli | 3 - src/proto/trace.mli | 3 - src/proto/trace_service.ml | 45 ----------- src/proto/trace_service.mli | 21 ----- 15 files changed, 19 insertions(+), 291 deletions(-) diff --git a/src/client-cohttp-lwt/opentelemetry_client_cohttp_lwt.ml b/src/client-cohttp-lwt/opentelemetry_client_cohttp_lwt.ml index d86e5279..5b4f0453 100644 --- a/src/client-cohttp-lwt/opentelemetry_client_cohttp_lwt.ml +++ b/src/client-cohttp-lwt/opentelemetry_client_cohttp_lwt.ml @@ -147,7 +147,7 @@ end = struct let r = try - let status = Status.decode_status dec in + let status = Status.decode_pb_status dec in Error (`Status (code, status)) with e -> let bt = Printexc.get_backtrace () in @@ -318,7 +318,7 @@ let mk_emitter ~stop ~(config : Config.t) () : (module EMITTER) = ~resource_metrics:l () in send_http_ curl encoder ~path:"/v1/metrics" - ~encode:Metrics_service.encode_export_metrics_service_request x + ~encode:Metrics_service.encode_pb_export_metrics_service_request x let send_traces_http curl encoder (l : Trace.resource_spans list list) = let l = List.fold_left (fun acc l -> List.rev_append l acc) [] l in @@ -326,7 +326,7 @@ let mk_emitter ~stop ~(config : Config.t) () : (module EMITTER) = Trace_service.default_export_trace_service_request ~resource_spans:l () in send_http_ curl encoder ~path:"/v1/traces" - ~encode:Trace_service.encode_export_trace_service_request x + ~encode:Trace_service.encode_pb_export_trace_service_request x let send_logs_http curl encoder (l : Logs.resource_logs list list) = let l = List.fold_left (fun acc l -> List.rev_append l acc) [] l in @@ -334,7 +334,7 @@ let mk_emitter ~stop ~(config : Config.t) () : (module EMITTER) = Logs_service.default_export_logs_service_request ~resource_logs:l () in send_http_ curl encoder ~path:"/v1/logs" - ~encode:Logs_service.encode_export_logs_service_request x + ~encode:Logs_service.encode_pb_export_logs_service_request x (* emit metrics, if the batch is full or timeout lapsed *) let emit_metrics_maybe ~now ?force httpc encoder : bool Lwt.t = diff --git a/src/client-ocurl/opentelemetry_client_ocurl.ml b/src/client-ocurl/opentelemetry_client_ocurl.ml index c8396d06..29e11fa4 100644 --- a/src/client-ocurl/opentelemetry_client_ocurl.ml +++ b/src/client-ocurl/opentelemetry_client_ocurl.ml @@ -147,7 +147,7 @@ end = struct let dec = Pbrt.Decoder.of_string body in let body = try - let status = Status.decode_status dec in + let status = Status.decode_pb_status dec in Format.asprintf "%a" Status.pp_status status with _ -> spf "(could not decode status)\nraw bytes: %s" (str_to_hex body) @@ -175,7 +175,7 @@ end = struct Logs_service.default_export_logs_service_request ~resource_logs:l () in send_http_ ~stop ~config client encoder ~path:"/v1/logs" - ~encode:Logs_service.encode_export_logs_service_request x + ~encode:Logs_service.encode_pb_export_logs_service_request x let send_metrics_http ~stop ~config curl encoder (l : Metrics.resource_metrics list list) : unit = @@ -185,7 +185,7 @@ end = struct () in send_http_ ~stop ~config curl encoder ~path:"/v1/metrics" - ~encode:Metrics_service.encode_export_metrics_service_request x + ~encode:Metrics_service.encode_pb_export_metrics_service_request x let send_traces_http ~stop ~config curl encoder (l : Trace.resource_spans list list) : unit = @@ -194,7 +194,7 @@ end = struct Trace_service.default_export_trace_service_request ~resource_spans:l () in send_http_ ~stop ~config curl encoder ~path:"/v1/traces" - ~encode:Trace_service.encode_export_trace_service_request x + ~encode:Trace_service.encode_pb_export_trace_service_request x let[@inline] send_event (self : t) ev : unit = B_queue.push self.q ev diff --git a/src/core/opentelemetry.ml b/src/core/opentelemetry.ml index 983ca128..cc5186e2 100644 --- a/src/core/opentelemetry.ml +++ b/src/core/opentelemetry.ml @@ -15,66 +15,10 @@ end (** {2 Wire format} *) +module Proto = Opentelemetry_proto (** Protobuf types. 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 - include Common_pb - end - - module Resource = struct - include Resource_types - include Resource_pp - include Resource_pb - end - - module Trace = struct - include Trace_types - include Trace_pp - include Trace_pb - end - - module Metrics = struct - include Metrics_types - include Metrics_pp - include Metrics_pb - end - - module Trace_service = struct - include Trace_service_types - include Trace_service_pb - include Trace_service_pp - end - - module Metrics_service = struct - include Metrics_service_types - include Metrics_service_pp - include Metrics_service_pb - end - - module Status = struct - include Status_types - include Status_pp - include Status_pb - end - - module Logs = struct - include Logs_types - include Logs_pb - include Logs_pp - end - - module Logs_service = struct - include Logs_service_types - include Logs_service_pb - include Logs_service_pp - end -end (** {2 Timestamps} *) @@ -105,7 +49,7 @@ end Note: most users will not need to touch this module *) module Collector = struct - open Proto + open Opentelemetry_proto type 'msg sender = { send: 'a. 'msg -> ret:(unit -> 'a) -> 'a } (** Sender interface for a message of type [msg]. @@ -889,10 +833,10 @@ end See {{: https://opentelemetry.io/docs/reference/specification/overview/#metric-signal} the spec} *) module Metrics = struct - open Opentelemetry_proto - open Metrics_types + open Proto + open Proto.Metrics - type t = Metrics_types.metric + type t = Metrics.metric (** A single metric, measuring some time-varying quantity or statistical distribution. It is composed of one or more data points that have precise values and time stamps. Each distinct metric should have a @@ -925,7 +869,7 @@ module Metrics = struct let data = Gauge (default_gauge ~data_points:l ()) in default_metric ~name ?description ?unit_ ~data () - type aggregation_temporality = Metrics_types.aggregation_temporality = + type aggregation_temporality = Metrics.aggregation_temporality = | Aggregation_temporality_unspecified | Aggregation_temporality_delta | Aggregation_temporality_cumulative @@ -993,12 +937,12 @@ end See {{: https://opentelemetry.io/docs/reference/specification/overview/#log-signal} the spec} *) module Logs = struct open Opentelemetry_proto - open Logs_types + open Logs type t = log_record (** Severity level of a log event *) - type severity = Logs_types.severity_number = + type severity = Logs.severity_number = | Severity_number_unspecified | Severity_number_trace | Severity_number_trace2 @@ -1025,13 +969,13 @@ module Logs = struct | Severity_number_fatal3 | Severity_number_fatal4 - let pp_severity = Logs_pp.pp_severity_number + let pp_severity = Logs.pp_severity_number - type flags = Logs_types.log_record_flags = + type flags = Logs.log_record_flags = | Log_record_flags_do_not_use | Log_record_flags_trace_flags_mask - let pp_flags = Logs_pp.pp_log_record_flags + let pp_flags = Logs.pp_log_record_flags (** Make a single log entry *) let make ?time ?(observed_time_unix_nano = Timestamp_ns.now_unix_ns ()) diff --git a/src/proto/common.mli b/src/proto/common.mli index fcbc7999..eb1114cd 100644 --- a/src/proto/common.mli +++ b/src/proto/common.mli @@ -155,6 +155,3 @@ val decode_pb_key_value : Pbrt.Decoder.t -> key_value val decode_pb_instrumentation_scope : Pbrt.Decoder.t -> instrumentation_scope (** [decode_pb_instrumentation_scope decoder] decodes a [instrumentation_scope] binary value from [decoder] *) - - -(** {2 Services} *) diff --git a/src/proto/logs.mli b/src/proto/logs.mli index f1a17d69..84dd9c0c 100644 --- a/src/proto/logs.mli +++ b/src/proto/logs.mli @@ -217,6 +217,3 @@ val decode_pb_logs_data : Pbrt.Decoder.t -> logs_data val decode_pb_log_record_flags : Pbrt.Decoder.t -> log_record_flags (** [decode_pb_log_record_flags decoder] decodes a [log_record_flags] binary value from [decoder] *) - - -(** {2 Services} *) diff --git a/src/proto/logs_service.ml b/src/proto/logs_service.ml index 7958071b..8e271c59 100644 --- a/src/proto/logs_service.ml +++ b/src/proto/logs_service.ml @@ -196,48 +196,3 @@ let rec decode_pb_export_logs_service_response d = ({ partial_success = v.partial_success; } : export_logs_service_response) - -module LogsService = struct - open Pbrt_services.Value_mode - module Client = struct - open Pbrt_services - - let export : (export_logs_service_request, unary, export_logs_service_response, unary) Client.rpc = - (Client.mk_rpc - ~package:["opentelemetry";"proto";"collector";"logs";"v1"] - ~service_name:"LogsService" ~rpc_name:"Export" - ~req_mode:Client.Unary - ~res_mode:Client.Unary - ~encode_json_req:encode_json_export_logs_service_request - ~encode_pb_req:encode_pb_export_logs_service_request - ~decode_json_res:decode_json_export_logs_service_response - ~decode_pb_res:decode_pb_export_logs_service_response - () : (export_logs_service_request, unary, export_logs_service_response, unary) Client.rpc) - end - - module Server = struct - open Pbrt_services - - let _rpc_export : (export_logs_service_request,unary,export_logs_service_response,unary) Server.rpc = - (Server.mk_rpc ~name:"Export" - ~req_mode:Server.Unary - ~res_mode:Server.Unary - ~encode_json_res:encode_json_export_logs_service_response - ~encode_pb_res:encode_pb_export_logs_service_response - ~decode_json_req:decode_json_export_logs_service_request - ~decode_pb_req:decode_pb_export_logs_service_request - () : _ Server.rpc) - - let make - ~export - () : _ Server.t = - { Server. - service_name="LogsService"; - package=["opentelemetry";"proto";"collector";"logs";"v1"]; - handlers=[ - (export _rpc_export); - ]; - } - end - -end diff --git a/src/proto/logs_service.mli b/src/proto/logs_service.mli index cb477313..5e3f24d9 100644 --- a/src/proto/logs_service.mli +++ b/src/proto/logs_service.mli @@ -99,24 +99,3 @@ val decode_pb_export_logs_partial_success : Pbrt.Decoder.t -> export_logs_partia val decode_pb_export_logs_service_response : Pbrt.Decoder.t -> export_logs_service_response (** [decode_pb_export_logs_service_response decoder] decodes a [export_logs_service_response] binary value from [decoder] *) - - -(** {2 Services} *) - -(** LogsService service *) -module LogsService : sig - open Pbrt_services - open Pbrt_services.Value_mode - - module Client : sig - - val export : (export_logs_service_request, unary, export_logs_service_response, unary) Client.rpc - end - - module Server : sig - (** Produce a server implementation from handlers *) - val make : - export:((export_logs_service_request, unary, export_logs_service_response, unary) Server.rpc -> 'handler) -> - unit -> 'handler Pbrt_services.Server.t - end -end diff --git a/src/proto/metrics.mli b/src/proto/metrics.mli index 61030369..d9626883 100644 --- a/src/proto/metrics.mli +++ b/src/proto/metrics.mli @@ -663,6 +663,3 @@ val decode_pb_metrics_data : Pbrt.Decoder.t -> metrics_data val decode_pb_data_point_flags : Pbrt.Decoder.t -> data_point_flags (** [decode_pb_data_point_flags decoder] decodes a [data_point_flags] binary value from [decoder] *) - - -(** {2 Services} *) diff --git a/src/proto/metrics_service.ml b/src/proto/metrics_service.ml index 04534bd3..6d1fa094 100644 --- a/src/proto/metrics_service.ml +++ b/src/proto/metrics_service.ml @@ -196,48 +196,3 @@ let rec decode_pb_export_metrics_service_response d = ({ partial_success = v.partial_success; } : export_metrics_service_response) - -module MetricsService = struct - open Pbrt_services.Value_mode - module Client = struct - open Pbrt_services - - let export : (export_metrics_service_request, unary, export_metrics_service_response, unary) Client.rpc = - (Client.mk_rpc - ~package:["opentelemetry";"proto";"collector";"metrics";"v1"] - ~service_name:"MetricsService" ~rpc_name:"Export" - ~req_mode:Client.Unary - ~res_mode:Client.Unary - ~encode_json_req:encode_json_export_metrics_service_request - ~encode_pb_req:encode_pb_export_metrics_service_request - ~decode_json_res:decode_json_export_metrics_service_response - ~decode_pb_res:decode_pb_export_metrics_service_response - () : (export_metrics_service_request, unary, export_metrics_service_response, unary) Client.rpc) - end - - module Server = struct - open Pbrt_services - - let _rpc_export : (export_metrics_service_request,unary,export_metrics_service_response,unary) Server.rpc = - (Server.mk_rpc ~name:"Export" - ~req_mode:Server.Unary - ~res_mode:Server.Unary - ~encode_json_res:encode_json_export_metrics_service_response - ~encode_pb_res:encode_pb_export_metrics_service_response - ~decode_json_req:decode_json_export_metrics_service_request - ~decode_pb_req:decode_pb_export_metrics_service_request - () : _ Server.rpc) - - let make - ~export - () : _ Server.t = - { Server. - service_name="MetricsService"; - package=["opentelemetry";"proto";"collector";"metrics";"v1"]; - handlers=[ - (export _rpc_export); - ]; - } - end - -end diff --git a/src/proto/metrics_service.mli b/src/proto/metrics_service.mli index 0d244b82..f3357d87 100644 --- a/src/proto/metrics_service.mli +++ b/src/proto/metrics_service.mli @@ -99,24 +99,3 @@ val decode_pb_export_metrics_partial_success : Pbrt.Decoder.t -> export_metrics_ val decode_pb_export_metrics_service_response : Pbrt.Decoder.t -> export_metrics_service_response (** [decode_pb_export_metrics_service_response decoder] decodes a [export_metrics_service_response] binary value from [decoder] *) - - -(** {2 Services} *) - -(** MetricsService service *) -module MetricsService : sig - open Pbrt_services - open Pbrt_services.Value_mode - - module Client : sig - - val export : (export_metrics_service_request, unary, export_metrics_service_response, unary) Client.rpc - end - - module Server : sig - (** Produce a server implementation from handlers *) - val make : - export:((export_metrics_service_request, unary, export_metrics_service_response, unary) Server.rpc -> 'handler) -> - unit -> 'handler Pbrt_services.Server.t - end -end diff --git a/src/proto/resource.mli b/src/proto/resource.mli index 8f778015..88f7cb9c 100644 --- a/src/proto/resource.mli +++ b/src/proto/resource.mli @@ -49,6 +49,3 @@ val encode_pb_resource : resource -> Pbrt.Encoder.t -> unit val decode_pb_resource : Pbrt.Decoder.t -> resource (** [decode_pb_resource decoder] decodes a [resource] binary value from [decoder] *) - - -(** {2 Services} *) diff --git a/src/proto/status.mli b/src/proto/status.mli index 1123c8bf..622f1256 100644 --- a/src/proto/status.mli +++ b/src/proto/status.mli @@ -52,6 +52,3 @@ val encode_pb_status : status -> Pbrt.Encoder.t -> unit val decode_pb_status : Pbrt.Decoder.t -> status (** [decode_pb_status decoder] decodes a [status] binary value from [decoder] *) - - -(** {2 Services} *) diff --git a/src/proto/trace.mli b/src/proto/trace.mli index b405cbea..bd7598e2 100644 --- a/src/proto/trace.mli +++ b/src/proto/trace.mli @@ -313,6 +313,3 @@ val decode_pb_resource_spans : Pbrt.Decoder.t -> resource_spans val decode_pb_traces_data : Pbrt.Decoder.t -> traces_data (** [decode_pb_traces_data decoder] decodes a [traces_data] binary value from [decoder] *) - - -(** {2 Services} *) diff --git a/src/proto/trace_service.ml b/src/proto/trace_service.ml index faab8ffc..79f5fe8d 100644 --- a/src/proto/trace_service.ml +++ b/src/proto/trace_service.ml @@ -196,48 +196,3 @@ let rec decode_pb_export_trace_service_response d = ({ partial_success = v.partial_success; } : export_trace_service_response) - -module TraceService = struct - open Pbrt_services.Value_mode - module Client = struct - open Pbrt_services - - let export : (export_trace_service_request, unary, export_trace_service_response, unary) Client.rpc = - (Client.mk_rpc - ~package:["opentelemetry";"proto";"collector";"trace";"v1"] - ~service_name:"TraceService" ~rpc_name:"Export" - ~req_mode:Client.Unary - ~res_mode:Client.Unary - ~encode_json_req:encode_json_export_trace_service_request - ~encode_pb_req:encode_pb_export_trace_service_request - ~decode_json_res:decode_json_export_trace_service_response - ~decode_pb_res:decode_pb_export_trace_service_response - () : (export_trace_service_request, unary, export_trace_service_response, unary) Client.rpc) - end - - module Server = struct - open Pbrt_services - - let _rpc_export : (export_trace_service_request,unary,export_trace_service_response,unary) Server.rpc = - (Server.mk_rpc ~name:"Export" - ~req_mode:Server.Unary - ~res_mode:Server.Unary - ~encode_json_res:encode_json_export_trace_service_response - ~encode_pb_res:encode_pb_export_trace_service_response - ~decode_json_req:decode_json_export_trace_service_request - ~decode_pb_req:decode_pb_export_trace_service_request - () : _ Server.rpc) - - let make - ~export - () : _ Server.t = - { Server. - service_name="TraceService"; - package=["opentelemetry";"proto";"collector";"trace";"v1"]; - handlers=[ - (export _rpc_export); - ]; - } - end - -end diff --git a/src/proto/trace_service.mli b/src/proto/trace_service.mli index f563aba3..4b555371 100644 --- a/src/proto/trace_service.mli +++ b/src/proto/trace_service.mli @@ -99,24 +99,3 @@ val decode_pb_export_trace_partial_success : Pbrt.Decoder.t -> export_trace_part val decode_pb_export_trace_service_response : Pbrt.Decoder.t -> export_trace_service_response (** [decode_pb_export_trace_service_response decoder] decodes a [export_trace_service_response] binary value from [decoder] *) - - -(** {2 Services} *) - -(** TraceService service *) -module TraceService : sig - open Pbrt_services - open Pbrt_services.Value_mode - - module Client : sig - - val export : (export_trace_service_request, unary, export_trace_service_response, unary) Client.rpc - end - - module Server : sig - (** Produce a server implementation from handlers *) - val make : - export:((export_trace_service_request, unary, export_trace_service_response, unary) Server.rpc -> 'handler) -> - unit -> 'handler Pbrt_services.Server.t - end -end From e6405ef7b6fc78d1d3f1b43ef9c3a71e74b9bdd4 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Mon, 11 Dec 2023 17:13:51 -0500 Subject: [PATCH 4/6] 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 47f93677..71b7c121 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.4 -y + - run: opam pin ocaml-protoc --dev -y - run: opam exec -- dune build @lint From 936c74ea36bdb02c5eecc5a25995c363a516d5cc Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Mon, 11 Dec 2023 17:14:06 -0500 Subject: [PATCH 5/6] fast CI --- .github/workflows/main.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 71b7c121..c6c3f11d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -35,13 +35,18 @@ jobs: with: ocaml-compiler: ${{ matrix.ocaml-compiler }} opam-depext-flags: --with-test + dune-cache: true + allow-prerelease-opam: true + + - run: | + opam pin ocaml-protoc 3.0.1 -y -n + opam pin pbrt 3.0.1 -y -n + opam install ocaml-protoc pbrt -y - run: opam install . --deps-only --with-test - 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 --dev -y - - run: opam exec -- dune build @lint # check that nothing changed From 8164ae55b8e25c45d49f6dbfb8b1d9514c26b6f9 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Thu, 14 Dec 2023 10:13:15 -0500 Subject: [PATCH 6/6] CI: only on push to main --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c6c3f11d..32053654 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,6 +3,8 @@ name: build on: pull_request: push: + branches: + - main jobs: build: