diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8c4a0552..e2ac881a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -42,7 +42,7 @@ jobs: allow-prerelease-opam: true - run: | - opam pin https://github.com/mransan/ocaml-protoc.git#82f345027a2ff2e8f09f6882fe9a93e0b863731d -y -n + opam pin https://github.com/mransan/ocaml-protoc.git#5510694deffde13283742b8ad116fab61b65dfbc -y -n opam install pbrt -y # We cannot install packages that need eio on ocaml versions before 5 diff --git a/flake.nix b/flake.nix index 5ef43c11..c2992db4 100644 --- a/flake.nix +++ b/flake.nix @@ -26,7 +26,7 @@ pbrt = prev.pbrt.overrideAttrs (oldAttrs: { src = pkgs.fetchgit { url = "https://github.com/mransan/ocaml-protoc.git"; - rev = "82f345027a2ff2e8f09f6882fe9a93e0b863731d"; + rev = "5510694deffde13283742b8ad116fab61b65dfbc"; sha256 = "sha256-KPctDwJIGi2W3HJEZBPwu9qRUrqK0azfW7VKCPxzCOU="; }; }); diff --git a/src/proto/common.ml b/src/proto/common.ml index d32367ab..d9cf40a4 100644 --- a/src/proto/common.ml +++ b/src/proto/common.ml @@ -80,7 +80,6 @@ let default_entity_ref (): entity_ref = (** {2 Make functions} *) - let[@inline] array_value_set_values (self:array_value) (x:any_value list) : unit = self.values <- x @@ -226,30 +225,24 @@ and pp_key_value_list fmt (v:key_value_list) = 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; - if not (key_value_has_key v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (key_value_has_key v)) ~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; - if not (instrumentation_scope_has_name v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "version" Pbrt.Pp.pp_string fmt v.version; - if not (instrumentation_scope_has_version v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (instrumentation_scope_has_name v)) ~first:true "name" Pbrt.Pp.pp_string fmt v.name; + Pbrt.Pp.pp_record_field ~absent:(not (instrumentation_scope_has_version v)) ~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; - if not (instrumentation_scope_has_dropped_attributes_count v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (instrumentation_scope_has_dropped_attributes_count v)) ~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_entity_ref fmt (v:entity_ref) = let pp_i fmt () = - Pbrt.Pp.pp_record_field ~first:true "schema_url" Pbrt.Pp.pp_string fmt v.schema_url; - if not (entity_ref_has_schema_url v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "type_" Pbrt.Pp.pp_string fmt v.type_; - if not (entity_ref_has_type_ v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (entity_ref_has_schema_url v)) ~first:true "schema_url" Pbrt.Pp.pp_string fmt v.schema_url; + Pbrt.Pp.pp_record_field ~absent:(not (entity_ref_has_type_ v)) ~first:false "type_" Pbrt.Pp.pp_string fmt v.type_; Pbrt.Pp.pp_record_field ~first:false "id_keys" (Pbrt.Pp.pp_list Pbrt.Pp.pp_string) fmt v.id_keys; Pbrt.Pp.pp_record_field ~first:false "description_keys" (Pbrt.Pp.pp_list Pbrt.Pp.pp_string) fmt v.description_keys; in @@ -386,7 +379,7 @@ and decode_pb_array_value d = array_value_set_values v ((decode_pb_any_value (Pbrt.Decoder.nested d)) :: v.values); end | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(array_value), field(1)" pk + Pbrt.Decoder.unexpected_payload_message "array_value" 1 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : array_value) @@ -404,7 +397,7 @@ and decode_pb_key_value_list d = key_value_list_set_values v ((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 + Pbrt.Decoder.unexpected_payload_message "key_value_list" 1 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : key_value_list) @@ -420,12 +413,12 @@ and decode_pb_key_value d = key_value_set_key v (Pbrt.Decoder.string d); end | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(key_value), field(1)" pk + Pbrt.Decoder.unexpected_payload_message "key_value" 1 pk | Some (2, Pbrt.Bytes) -> begin key_value_set_value v (decode_pb_any_value (Pbrt.Decoder.nested d)); end | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(key_value), field(2)" pk + Pbrt.Decoder.unexpected_payload_message "key_value" 2 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : key_value) @@ -443,22 +436,22 @@ let rec decode_pb_instrumentation_scope d = instrumentation_scope_set_name v (Pbrt.Decoder.string d); end | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(instrumentation_scope), field(1)" pk + Pbrt.Decoder.unexpected_payload_message "instrumentation_scope" 1 pk | Some (2, Pbrt.Bytes) -> begin instrumentation_scope_set_version v (Pbrt.Decoder.string d); end | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(instrumentation_scope), field(2)" pk + Pbrt.Decoder.unexpected_payload_message "instrumentation_scope" 2 pk | Some (3, Pbrt.Bytes) -> begin instrumentation_scope_set_attributes v ((decode_pb_key_value (Pbrt.Decoder.nested d)) :: v.attributes); end | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(instrumentation_scope), field(3)" pk + Pbrt.Decoder.unexpected_payload_message "instrumentation_scope" 3 pk | Some (4, Pbrt.Varint) -> begin instrumentation_scope_set_dropped_attributes_count v (Pbrt.Decoder.int32_as_varint d); end | Some (4, pk) -> - Pbrt.Decoder.unexpected_payload "Message(instrumentation_scope), field(4)" pk + Pbrt.Decoder.unexpected_payload_message "instrumentation_scope" 4 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : instrumentation_scope) @@ -477,22 +470,22 @@ let rec decode_pb_entity_ref d = entity_ref_set_schema_url v (Pbrt.Decoder.string d); end | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(entity_ref), field(1)" pk + Pbrt.Decoder.unexpected_payload_message "entity_ref" 1 pk | Some (2, Pbrt.Bytes) -> begin entity_ref_set_type_ v (Pbrt.Decoder.string d); end | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(entity_ref), field(2)" pk + Pbrt.Decoder.unexpected_payload_message "entity_ref" 2 pk | Some (3, Pbrt.Bytes) -> begin entity_ref_set_id_keys v ((Pbrt.Decoder.string d) :: v.id_keys); end | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(entity_ref), field(3)" pk + Pbrt.Decoder.unexpected_payload_message "entity_ref" 3 pk | Some (4, Pbrt.Bytes) -> begin entity_ref_set_description_keys v ((Pbrt.Decoder.string d) :: v.description_keys); end | Some (4, pk) -> - Pbrt.Decoder.unexpected_payload "Message(entity_ref), field(4)" pk + Pbrt.Decoder.unexpected_payload_message "entity_ref" 4 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : entity_ref) diff --git a/src/proto/common.mli b/src/proto/common.mli index 1dcda6f5..04318fe7 100644 --- a/src/proto/common.mli +++ b/src/proto/common.mli @@ -70,7 +70,6 @@ val default_entity_ref : unit -> entity_ref (** {2 Make functions} *) - val make_array_value : ?values:any_value list -> unit -> diff --git a/src/proto/logs.ml b/src/proto/logs.ml index 7916b015..6916c264 100644 --- a/src/proto/logs.ml +++ b/src/proto/logs.ml @@ -108,7 +108,6 @@ let default_log_record_flags () = (Log_record_flags_do_not_use:log_record_flags) (** {2 Make functions} *) - let[@inline] log_record_has_time_unix_nano (self:log_record) : bool = (Pbrt.Bitfield.get self._presence 0) let[@inline] log_record_has_observed_time_unix_nano (self:log_record) : bool = (Pbrt.Bitfield.get self._presence 1) let[@inline] log_record_has_severity_number (self:log_record) : bool = (Pbrt.Bitfield.get self._presence 2) @@ -260,7 +259,6 @@ let make_logs_data logs_data_set_resource_logs _res resource_logs; _res - [@@@ocaml.warning "-23-27-30-39"] (** {2 Formatters} *) @@ -295,26 +293,17 @@ let rec pp_severity_number fmt (v:severity_number) = 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; - if not (log_record_has_time_unix_nano v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "observed_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.observed_time_unix_nano; - if not (log_record_has_observed_time_unix_nano v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "severity_number" pp_severity_number fmt v.severity_number; - if not (log_record_has_severity_number v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "severity_text" Pbrt.Pp.pp_string fmt v.severity_text; - if not (log_record_has_severity_text v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (log_record_has_time_unix_nano v)) ~first:true "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.time_unix_nano; + Pbrt.Pp.pp_record_field ~absent:(not (log_record_has_observed_time_unix_nano v)) ~first:false "observed_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.observed_time_unix_nano; + Pbrt.Pp.pp_record_field ~absent:(not (log_record_has_severity_number v)) ~first:false "severity_number" pp_severity_number fmt v.severity_number; + Pbrt.Pp.pp_record_field ~absent:(not (log_record_has_severity_text v)) ~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; - if not (log_record_has_dropped_attributes_count v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "flags" Pbrt.Pp.pp_int32 fmt v.flags; - if not (log_record_has_flags v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "trace_id" Pbrt.Pp.pp_bytes fmt v.trace_id; - if not (log_record_has_trace_id v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "span_id" Pbrt.Pp.pp_bytes fmt v.span_id; - if not (log_record_has_span_id v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "event_name" Pbrt.Pp.pp_string fmt v.event_name; - if not (log_record_has_event_name v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (log_record_has_dropped_attributes_count v)) ~first:false "dropped_attributes_count" Pbrt.Pp.pp_int32 fmt v.dropped_attributes_count; + Pbrt.Pp.pp_record_field ~absent:(not (log_record_has_flags v)) ~first:false "flags" Pbrt.Pp.pp_int32 fmt v.flags; + Pbrt.Pp.pp_record_field ~absent:(not (log_record_has_trace_id v)) ~first:false "trace_id" Pbrt.Pp.pp_bytes fmt v.trace_id; + Pbrt.Pp.pp_record_field ~absent:(not (log_record_has_span_id v)) ~first:false "span_id" Pbrt.Pp.pp_bytes fmt v.span_id; + Pbrt.Pp.pp_record_field ~absent:(not (log_record_has_event_name v)) ~first:false "event_name" Pbrt.Pp.pp_string fmt v.event_name; in Pbrt.Pp.pp_brk pp_i fmt () @@ -322,8 +311,7 @@ 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; - if not (scope_logs_has_schema_url v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (scope_logs_has_schema_url v)) ~first:false "schema_url" Pbrt.Pp.pp_string fmt v.schema_url; in Pbrt.Pp.pp_brk pp_i fmt () @@ -331,8 +319,7 @@ 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; - if not (resource_logs_has_schema_url v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (resource_logs_has_schema_url v)) ~first:false "schema_url" Pbrt.Pp.pp_string fmt v.schema_url; in Pbrt.Pp.pp_brk pp_i fmt () @@ -478,33 +465,33 @@ let rec encode_pb_log_record_flags (v:log_record_flags) encoder = (** {2 Protobuf Decoding} *) -let rec decode_pb_severity_number d = +let rec decode_pb_severity_number d : severity_number = 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) + | 0 -> Severity_number_unspecified + | 1 -> Severity_number_trace + | 2 -> Severity_number_trace2 + | 3 -> Severity_number_trace3 + | 4 -> Severity_number_trace4 + | 5 -> Severity_number_debug + | 6 -> Severity_number_debug2 + | 7 -> Severity_number_debug3 + | 8 -> Severity_number_debug4 + | 9 -> Severity_number_info + | 10 -> Severity_number_info2 + | 11 -> Severity_number_info3 + | 12 -> Severity_number_info4 + | 13 -> Severity_number_warn + | 14 -> Severity_number_warn2 + | 15 -> Severity_number_warn3 + | 16 -> Severity_number_warn4 + | 17 -> Severity_number_error + | 18 -> Severity_number_error2 + | 19 -> Severity_number_error3 + | 20 -> Severity_number_error4 + | 21 -> Severity_number_fatal + | 22 -> Severity_number_fatal2 + | 23 -> Severity_number_fatal3 + | 24 -> Severity_number_fatal4 | _ -> Pbrt.Decoder.malformed_variant "severity_number" let rec decode_pb_log_record d = @@ -520,57 +507,57 @@ let rec decode_pb_log_record d = log_record_set_time_unix_nano v (Pbrt.Decoder.int64_as_bits64 d); end | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(log_record), field(1)" pk + Pbrt.Decoder.unexpected_payload_message "log_record" 1 pk | Some (11, Pbrt.Bits64) -> begin log_record_set_observed_time_unix_nano v (Pbrt.Decoder.int64_as_bits64 d); end | Some (11, pk) -> - Pbrt.Decoder.unexpected_payload "Message(log_record), field(11)" pk + Pbrt.Decoder.unexpected_payload_message "log_record" 11 pk | Some (2, Pbrt.Varint) -> begin log_record_set_severity_number v (decode_pb_severity_number d); end | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(log_record), field(2)" pk + Pbrt.Decoder.unexpected_payload_message "log_record" 2 pk | Some (3, Pbrt.Bytes) -> begin log_record_set_severity_text v (Pbrt.Decoder.string d); end | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(log_record), field(3)" pk + Pbrt.Decoder.unexpected_payload_message "log_record" 3 pk | Some (5, Pbrt.Bytes) -> begin log_record_set_body v (Common.decode_pb_any_value (Pbrt.Decoder.nested d)); end | Some (5, pk) -> - Pbrt.Decoder.unexpected_payload "Message(log_record), field(5)" pk + Pbrt.Decoder.unexpected_payload_message "log_record" 5 pk | Some (6, Pbrt.Bytes) -> begin log_record_set_attributes v ((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 + Pbrt.Decoder.unexpected_payload_message "log_record" 6 pk | Some (7, Pbrt.Varint) -> begin log_record_set_dropped_attributes_count v (Pbrt.Decoder.int32_as_varint d); end | Some (7, pk) -> - Pbrt.Decoder.unexpected_payload "Message(log_record), field(7)" pk + Pbrt.Decoder.unexpected_payload_message "log_record" 7 pk | Some (8, Pbrt.Bits32) -> begin log_record_set_flags v (Pbrt.Decoder.int32_as_bits32 d); end | Some (8, pk) -> - Pbrt.Decoder.unexpected_payload "Message(log_record), field(8)" pk + Pbrt.Decoder.unexpected_payload_message "log_record" 8 pk | Some (9, Pbrt.Bytes) -> begin log_record_set_trace_id v (Pbrt.Decoder.bytes d); end | Some (9, pk) -> - Pbrt.Decoder.unexpected_payload "Message(log_record), field(9)" pk + Pbrt.Decoder.unexpected_payload_message "log_record" 9 pk | Some (10, Pbrt.Bytes) -> begin log_record_set_span_id v (Pbrt.Decoder.bytes d); end | Some (10, pk) -> - Pbrt.Decoder.unexpected_payload "Message(log_record), field(10)" pk + Pbrt.Decoder.unexpected_payload_message "log_record" 10 pk | Some (12, Pbrt.Bytes) -> begin log_record_set_event_name v (Pbrt.Decoder.string d); end | Some (12, pk) -> - Pbrt.Decoder.unexpected_payload "Message(log_record), field(12)" pk + Pbrt.Decoder.unexpected_payload_message "log_record" 12 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : log_record) @@ -588,17 +575,17 @@ let rec decode_pb_scope_logs d = scope_logs_set_scope v (Common.decode_pb_instrumentation_scope (Pbrt.Decoder.nested d)); end | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(scope_logs), field(1)" pk + Pbrt.Decoder.unexpected_payload_message "scope_logs" 1 pk | Some (2, Pbrt.Bytes) -> begin scope_logs_set_log_records v ((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 + Pbrt.Decoder.unexpected_payload_message "scope_logs" 2 pk | Some (3, Pbrt.Bytes) -> begin scope_logs_set_schema_url v (Pbrt.Decoder.string d); end | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(scope_logs), field(3)" pk + Pbrt.Decoder.unexpected_payload_message "scope_logs" 3 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : scope_logs) @@ -616,17 +603,17 @@ let rec decode_pb_resource_logs d = resource_logs_set_resource v (Resource.decode_pb_resource (Pbrt.Decoder.nested d)); end | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(resource_logs), field(1)" pk + Pbrt.Decoder.unexpected_payload_message "resource_logs" 1 pk | Some (2, Pbrt.Bytes) -> begin resource_logs_set_scope_logs v ((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 + Pbrt.Decoder.unexpected_payload_message "resource_logs" 2 pk | Some (3, Pbrt.Bytes) -> begin resource_logs_set_schema_url v (Pbrt.Decoder.string d); end | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(resource_logs), field(3)" pk + Pbrt.Decoder.unexpected_payload_message "resource_logs" 3 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : resource_logs) @@ -644,13 +631,13 @@ let rec decode_pb_logs_data d = logs_data_set_resource_logs v ((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 + Pbrt.Decoder.unexpected_payload_message "logs_data" 1 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : logs_data) -let rec decode_pb_log_record_flags d = +let rec decode_pb_log_record_flags d : log_record_flags = 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) + | 0 -> Log_record_flags_do_not_use + | 255 -> Log_record_flags_trace_flags_mask | _ -> Pbrt.Decoder.malformed_variant "log_record_flags" diff --git a/src/proto/logs.mli b/src/proto/logs.mli index cacafa94..c291480b 100644 --- a/src/proto/logs.mli +++ b/src/proto/logs.mli @@ -95,7 +95,6 @@ val default_log_record_flags : unit -> log_record_flags (** {2 Make functions} *) - val make_log_record : ?time_unix_nano:int64 -> ?observed_time_unix_nano:int64 -> @@ -230,7 +229,6 @@ val logs_data_set_resource_logs : logs_data -> resource_logs list -> unit (** set field resource_logs in logs_data *) - (** {2 Formatters} *) val pp_severity_number : Format.formatter -> severity_number -> unit diff --git a/src/proto/logs_service.ml b/src/proto/logs_service.ml index 50ce1d82..d7050174 100644 --- a/src/proto/logs_service.ml +++ b/src/proto/logs_service.ml @@ -100,10 +100,8 @@ let rec pp_export_logs_service_request fmt (v:export_logs_service_request) = 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; - if not (export_logs_partial_success_has_rejected_log_records v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "error_message" Pbrt.Pp.pp_string fmt v.error_message; - if not (export_logs_partial_success_has_error_message v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (export_logs_partial_success_has_rejected_log_records v)) ~first:true "rejected_log_records" Pbrt.Pp.pp_int64 fmt v.rejected_log_records; + Pbrt.Pp.pp_record_field ~absent:(not (export_logs_partial_success_has_error_message v)) ~first:false "error_message" Pbrt.Pp.pp_string fmt v.error_message; in Pbrt.Pp.pp_brk pp_i fmt () @@ -161,7 +159,7 @@ let rec decode_pb_export_logs_service_request d = export_logs_service_request_set_resource_logs v ((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 + Pbrt.Decoder.unexpected_payload_message "export_logs_service_request" 1 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : export_logs_service_request) @@ -177,12 +175,12 @@ let rec decode_pb_export_logs_partial_success d = export_logs_partial_success_set_rejected_log_records v (Pbrt.Decoder.int64_as_varint d); end | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(export_logs_partial_success), field(1)" pk + Pbrt.Decoder.unexpected_payload_message "export_logs_partial_success" 1 pk | Some (2, Pbrt.Bytes) -> begin export_logs_partial_success_set_error_message v (Pbrt.Decoder.string d); end | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(export_logs_partial_success), field(2)" pk + Pbrt.Decoder.unexpected_payload_message "export_logs_partial_success" 2 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : export_logs_partial_success) @@ -198,7 +196,7 @@ let rec decode_pb_export_logs_service_response d = export_logs_service_response_set_partial_success v (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 + Pbrt.Decoder.unexpected_payload_message "export_logs_service_response" 1 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : export_logs_service_response) diff --git a/src/proto/metrics.ml b/src/proto/metrics.ml index ef242c3c..df9093b2 100644 --- a/src/proto/metrics.ml +++ b/src/proto/metrics.ml @@ -44,18 +44,18 @@ type sum = { } type histogram_data_point = { - mutable _presence: Pbrt.Bitfield.t; (** presence for 4 fields *) + mutable _presence: Pbrt.Bitfield.t; (** presence for 7 fields *) 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 sum : float; 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; + mutable min : float; + mutable max : float; } type histogram = { @@ -71,20 +71,20 @@ type exponential_histogram_data_point_buckets = { } type exponential_histogram_data_point = { - mutable _presence: Pbrt.Bitfield.t; (** presence for 7 fields *) + mutable _presence: Pbrt.Bitfield.t; (** presence for 10 fields *) 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 sum : float; 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 min : float; + mutable max : float; mutable zero_threshold : float; } @@ -200,13 +200,13 @@ let default_histogram_data_point (): histogram_data_point = start_time_unix_nano=0L; time_unix_nano=0L; count=0L; - sum=None; + sum=0.; bucket_counts=[]; explicit_bounds=[]; exemplars=[]; flags=0l; - min=None; - max=None; + min=0.; + max=0.; } let default_histogram (): histogram = @@ -230,15 +230,15 @@ let default_exponential_histogram_data_point (): exponential_histogram_data_poin start_time_unix_nano=0L; time_unix_nano=0L; count=0L; - sum=None; + sum=0.; scale=0l; zero_count=0L; positive=None; negative=None; flags=0l; exemplars=[]; - min=None; - max=None; + min=0.; + max=0.; zero_threshold=0.; } @@ -311,7 +311,6 @@ let default_data_point_flags () = (Data_point_flags_do_not_use:data_point_flags) (** {2 Make functions} *) - let[@inline] exemplar_has_time_unix_nano (self:exemplar) : bool = (Pbrt.Bitfield.get self._presence 0) let[@inline] exemplar_has_span_id (self:exemplar) : bool = (Pbrt.Bitfield.get self._presence 1) let[@inline] exemplar_has_trace_id (self:exemplar) : bool = (Pbrt.Bitfield.get self._presence 2) @@ -353,7 +352,6 @@ let make_exemplar | Some v -> exemplar_set_trace_id _res v); _res - let[@inline] number_data_point_has_start_time_unix_nano (self:number_data_point) : bool = (Pbrt.Bitfield.get self._presence 0) let[@inline] number_data_point_has_time_unix_nano (self:number_data_point) : bool = (Pbrt.Bitfield.get self._presence 1) let[@inline] number_data_point_has_flags (self:number_data_point) : bool = (Pbrt.Bitfield.get self._presence 2) @@ -413,7 +411,6 @@ let make_gauge gauge_set_data_points _res data_points; _res - let[@inline] sum_has_aggregation_temporality (self:sum) : bool = (Pbrt.Bitfield.get self._presence 0) let[@inline] sum_has_is_monotonic (self:sum) : bool = (Pbrt.Bitfield.get self._presence 1) @@ -445,7 +442,10 @@ let make_sum let[@inline] histogram_data_point_has_start_time_unix_nano (self:histogram_data_point) : bool = (Pbrt.Bitfield.get self._presence 0) let[@inline] histogram_data_point_has_time_unix_nano (self:histogram_data_point) : bool = (Pbrt.Bitfield.get self._presence 1) let[@inline] histogram_data_point_has_count (self:histogram_data_point) : bool = (Pbrt.Bitfield.get self._presence 2) -let[@inline] histogram_data_point_has_flags (self:histogram_data_point) : bool = (Pbrt.Bitfield.get self._presence 3) +let[@inline] histogram_data_point_has_sum (self:histogram_data_point) : bool = (Pbrt.Bitfield.get self._presence 3) +let[@inline] histogram_data_point_has_flags (self:histogram_data_point) : bool = (Pbrt.Bitfield.get self._presence 4) +let[@inline] histogram_data_point_has_min (self:histogram_data_point) : bool = (Pbrt.Bitfield.get self._presence 5) +let[@inline] histogram_data_point_has_max (self:histogram_data_point) : bool = (Pbrt.Bitfield.get self._presence 6) let[@inline] histogram_data_point_set_attributes (self:histogram_data_point) (x:Common.key_value list) : unit = self.attributes <- x @@ -456,7 +456,7 @@ let[@inline] histogram_data_point_set_time_unix_nano (self:histogram_data_point) let[@inline] histogram_data_point_set_count (self:histogram_data_point) (x:int64) : unit = self._presence <- (Pbrt.Bitfield.set self._presence 2); self.count <- x let[@inline] histogram_data_point_set_sum (self:histogram_data_point) (x:float) : unit = - self.sum <- Some x + self._presence <- (Pbrt.Bitfield.set self._presence 3); self.sum <- x let[@inline] histogram_data_point_set_bucket_counts (self:histogram_data_point) (x:int64 list) : unit = self.bucket_counts <- x let[@inline] histogram_data_point_set_explicit_bounds (self:histogram_data_point) (x:float list) : unit = @@ -464,11 +464,11 @@ let[@inline] histogram_data_point_set_explicit_bounds (self:histogram_data_point let[@inline] histogram_data_point_set_exemplars (self:histogram_data_point) (x:exemplar list) : unit = self.exemplars <- x let[@inline] histogram_data_point_set_flags (self:histogram_data_point) (x:int32) : unit = - self._presence <- (Pbrt.Bitfield.set self._presence 3); self.flags <- x + self._presence <- (Pbrt.Bitfield.set self._presence 4); self.flags <- x let[@inline] histogram_data_point_set_min (self:histogram_data_point) (x:float) : unit = - self.min <- Some x + self._presence <- (Pbrt.Bitfield.set self._presence 5); self.min <- x let[@inline] histogram_data_point_set_max (self:histogram_data_point) (x:float) : unit = - self.max <- Some x + self._presence <- (Pbrt.Bitfield.set self._presence 6); self.max <- x let copy_histogram_data_point (self:histogram_data_point) : histogram_data_point = { self with attributes = self.attributes } @@ -559,10 +559,13 @@ let make_exponential_histogram_data_point_buckets let[@inline] exponential_histogram_data_point_has_start_time_unix_nano (self:exponential_histogram_data_point) : bool = (Pbrt.Bitfield.get self._presence 0) let[@inline] exponential_histogram_data_point_has_time_unix_nano (self:exponential_histogram_data_point) : bool = (Pbrt.Bitfield.get self._presence 1) let[@inline] exponential_histogram_data_point_has_count (self:exponential_histogram_data_point) : bool = (Pbrt.Bitfield.get self._presence 2) -let[@inline] exponential_histogram_data_point_has_scale (self:exponential_histogram_data_point) : bool = (Pbrt.Bitfield.get self._presence 3) -let[@inline] exponential_histogram_data_point_has_zero_count (self:exponential_histogram_data_point) : bool = (Pbrt.Bitfield.get self._presence 4) -let[@inline] exponential_histogram_data_point_has_flags (self:exponential_histogram_data_point) : bool = (Pbrt.Bitfield.get self._presence 5) -let[@inline] exponential_histogram_data_point_has_zero_threshold (self:exponential_histogram_data_point) : bool = (Pbrt.Bitfield.get self._presence 6) +let[@inline] exponential_histogram_data_point_has_sum (self:exponential_histogram_data_point) : bool = (Pbrt.Bitfield.get self._presence 3) +let[@inline] exponential_histogram_data_point_has_scale (self:exponential_histogram_data_point) : bool = (Pbrt.Bitfield.get self._presence 4) +let[@inline] exponential_histogram_data_point_has_zero_count (self:exponential_histogram_data_point) : bool = (Pbrt.Bitfield.get self._presence 5) +let[@inline] exponential_histogram_data_point_has_flags (self:exponential_histogram_data_point) : bool = (Pbrt.Bitfield.get self._presence 6) +let[@inline] exponential_histogram_data_point_has_min (self:exponential_histogram_data_point) : bool = (Pbrt.Bitfield.get self._presence 7) +let[@inline] exponential_histogram_data_point_has_max (self:exponential_histogram_data_point) : bool = (Pbrt.Bitfield.get self._presence 8) +let[@inline] exponential_histogram_data_point_has_zero_threshold (self:exponential_histogram_data_point) : bool = (Pbrt.Bitfield.get self._presence 9) let[@inline] exponential_histogram_data_point_set_attributes (self:exponential_histogram_data_point) (x:Common.key_value list) : unit = self.attributes <- x @@ -573,25 +576,25 @@ let[@inline] exponential_histogram_data_point_set_time_unix_nano (self:exponenti let[@inline] exponential_histogram_data_point_set_count (self:exponential_histogram_data_point) (x:int64) : unit = self._presence <- (Pbrt.Bitfield.set self._presence 2); self.count <- x let[@inline] exponential_histogram_data_point_set_sum (self:exponential_histogram_data_point) (x:float) : unit = - self.sum <- Some x + self._presence <- (Pbrt.Bitfield.set self._presence 3); self.sum <- x let[@inline] exponential_histogram_data_point_set_scale (self:exponential_histogram_data_point) (x:int32) : unit = - self._presence <- (Pbrt.Bitfield.set self._presence 3); self.scale <- x + self._presence <- (Pbrt.Bitfield.set self._presence 4); self.scale <- x let[@inline] exponential_histogram_data_point_set_zero_count (self:exponential_histogram_data_point) (x:int64) : unit = - self._presence <- (Pbrt.Bitfield.set self._presence 4); self.zero_count <- x + self._presence <- (Pbrt.Bitfield.set self._presence 5); self.zero_count <- x let[@inline] exponential_histogram_data_point_set_positive (self:exponential_histogram_data_point) (x:exponential_histogram_data_point_buckets) : unit = self.positive <- Some x let[@inline] exponential_histogram_data_point_set_negative (self:exponential_histogram_data_point) (x:exponential_histogram_data_point_buckets) : unit = self.negative <- Some x let[@inline] exponential_histogram_data_point_set_flags (self:exponential_histogram_data_point) (x:int32) : unit = - self._presence <- (Pbrt.Bitfield.set self._presence 5); self.flags <- x + self._presence <- (Pbrt.Bitfield.set self._presence 6); self.flags <- x let[@inline] exponential_histogram_data_point_set_exemplars (self:exponential_histogram_data_point) (x:exemplar list) : unit = self.exemplars <- x let[@inline] exponential_histogram_data_point_set_min (self:exponential_histogram_data_point) (x:float) : unit = - self.min <- Some x + self._presence <- (Pbrt.Bitfield.set self._presence 7); self.min <- x let[@inline] exponential_histogram_data_point_set_max (self:exponential_histogram_data_point) (x:float) : unit = - self.max <- Some x + self._presence <- (Pbrt.Bitfield.set self._presence 8); self.max <- x let[@inline] exponential_histogram_data_point_set_zero_threshold (self:exponential_histogram_data_point) (x:float) : unit = - self._presence <- (Pbrt.Bitfield.set self._presence 6); self.zero_threshold <- x + self._presence <- (Pbrt.Bitfield.set self._presence 9); self.zero_threshold <- x let copy_exponential_histogram_data_point (self:exponential_histogram_data_point) : exponential_histogram_data_point = { self with attributes = self.attributes } @@ -765,7 +768,6 @@ let make_summary summary_set_data_points _res data_points; _res - let[@inline] metric_has_name (self:metric) : bool = (Pbrt.Bitfield.get self._presence 0) let[@inline] metric_has_description (self:metric) : bool = (Pbrt.Bitfield.get self._presence 1) let[@inline] metric_has_unit_ (self:metric) : bool = (Pbrt.Bitfield.get self._presence 2) @@ -875,7 +877,6 @@ let make_metrics_data metrics_data_set_resource_metrics _res resource_metrics; _res - [@@@ocaml.warning "-23-27-30-39"] (** {2 Formatters} *) @@ -888,13 +889,10 @@ let rec pp_exemplar_value fmt (v:exemplar_value) = 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; - if not (exemplar_has_time_unix_nano v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (exemplar_has_time_unix_nano v)) ~first:false "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.time_unix_nano; Pbrt.Pp.pp_record_field ~first:false "value" (Pbrt.Pp.pp_option pp_exemplar_value) fmt v.value; - Pbrt.Pp.pp_record_field ~first:false "span_id" Pbrt.Pp.pp_bytes fmt v.span_id; - if not (exemplar_has_span_id v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "trace_id" Pbrt.Pp.pp_bytes fmt v.trace_id; - if not (exemplar_has_trace_id v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (exemplar_has_span_id v)) ~first:false "span_id" Pbrt.Pp.pp_bytes fmt v.span_id; + Pbrt.Pp.pp_record_field ~absent:(not (exemplar_has_trace_id v)) ~first:false "trace_id" Pbrt.Pp.pp_bytes fmt v.trace_id; in Pbrt.Pp.pp_brk pp_i fmt () @@ -906,14 +904,11 @@ let rec pp_number_data_point_value fmt (v:number_data_point_value) = 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; - if not (number_data_point_has_start_time_unix_nano v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.time_unix_nano; - if not (number_data_point_has_time_unix_nano v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (number_data_point_has_start_time_unix_nano v)) ~first:false "start_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.start_time_unix_nano; + Pbrt.Pp.pp_record_field ~absent:(not (number_data_point_has_time_unix_nano v)) ~first:false "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.time_unix_nano; Pbrt.Pp.pp_record_field ~first:false "value" (Pbrt.Pp.pp_option 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; - if not (number_data_point_has_flags v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (number_data_point_has_flags v)) ~first:false "flags" Pbrt.Pp.pp_int32 fmt v.flags; in Pbrt.Pp.pp_brk pp_i fmt () @@ -932,45 +927,37 @@ let rec pp_aggregation_temporality fmt (v:aggregation_temporality) = 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; - if not (sum_has_aggregation_temporality v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "is_monotonic" Pbrt.Pp.pp_bool fmt v.is_monotonic; - if not (sum_has_is_monotonic v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (sum_has_aggregation_temporality v)) ~first:false "aggregation_temporality" pp_aggregation_temporality fmt v.aggregation_temporality; + Pbrt.Pp.pp_record_field ~absent:(not (sum_has_is_monotonic v)) ~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; - if not (histogram_data_point_has_start_time_unix_nano v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.time_unix_nano; - if not (histogram_data_point_has_time_unix_nano v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "count" Pbrt.Pp.pp_int64 fmt v.count; - if not (histogram_data_point_has_count v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "sum" (Pbrt.Pp.pp_option Pbrt.Pp.pp_float) fmt v.sum; + Pbrt.Pp.pp_record_field ~absent:(not (histogram_data_point_has_start_time_unix_nano v)) ~first:false "start_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.start_time_unix_nano; + Pbrt.Pp.pp_record_field ~absent:(not (histogram_data_point_has_time_unix_nano v)) ~first:false "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.time_unix_nano; + Pbrt.Pp.pp_record_field ~absent:(not (histogram_data_point_has_count v)) ~first:false "count" Pbrt.Pp.pp_int64 fmt v.count; + Pbrt.Pp.pp_record_field ~absent:(not (histogram_data_point_has_sum v)) ~first:false "sum" 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; - if not (histogram_data_point_has_flags v) then Format.pp_print_string fmt "(* absent *)"; - 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 ~absent:(not (histogram_data_point_has_flags v)) ~first:false "flags" Pbrt.Pp.pp_int32 fmt v.flags; + Pbrt.Pp.pp_record_field ~absent:(not (histogram_data_point_has_min v)) ~first:false "min" Pbrt.Pp.pp_float fmt v.min; + Pbrt.Pp.pp_record_field ~absent:(not (histogram_data_point_has_max v)) ~first:false "max" 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; - if not (histogram_has_aggregation_temporality v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (histogram_has_aggregation_temporality v)) ~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; - if not (exponential_histogram_data_point_buckets_has_offset v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (exponential_histogram_data_point_buckets_has_offset v)) ~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 () @@ -978,60 +965,45 @@ let rec pp_exponential_histogram_data_point_buckets fmt (v:exponential_histogram 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; - if not (exponential_histogram_data_point_has_start_time_unix_nano v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.time_unix_nano; - if not (exponential_histogram_data_point_has_time_unix_nano v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "count" Pbrt.Pp.pp_int64 fmt v.count; - if not (exponential_histogram_data_point_has_count v) then Format.pp_print_string fmt "(* absent *)"; - 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; - if not (exponential_histogram_data_point_has_scale v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "zero_count" Pbrt.Pp.pp_int64 fmt v.zero_count; - if not (exponential_histogram_data_point_has_zero_count v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (exponential_histogram_data_point_has_start_time_unix_nano v)) ~first:false "start_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.start_time_unix_nano; + Pbrt.Pp.pp_record_field ~absent:(not (exponential_histogram_data_point_has_time_unix_nano v)) ~first:false "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.time_unix_nano; + Pbrt.Pp.pp_record_field ~absent:(not (exponential_histogram_data_point_has_count v)) ~first:false "count" Pbrt.Pp.pp_int64 fmt v.count; + Pbrt.Pp.pp_record_field ~absent:(not (exponential_histogram_data_point_has_sum v)) ~first:false "sum" Pbrt.Pp.pp_float fmt v.sum; + Pbrt.Pp.pp_record_field ~absent:(not (exponential_histogram_data_point_has_scale v)) ~first:false "scale" Pbrt.Pp.pp_int32 fmt v.scale; + Pbrt.Pp.pp_record_field ~absent:(not (exponential_histogram_data_point_has_zero_count v)) ~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; - if not (exponential_histogram_data_point_has_flags v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (exponential_histogram_data_point_has_flags v)) ~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; - if not (exponential_histogram_data_point_has_zero_threshold v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (exponential_histogram_data_point_has_min v)) ~first:false "min" Pbrt.Pp.pp_float fmt v.min; + Pbrt.Pp.pp_record_field ~absent:(not (exponential_histogram_data_point_has_max v)) ~first:false "max" Pbrt.Pp.pp_float fmt v.max; + Pbrt.Pp.pp_record_field ~absent:(not (exponential_histogram_data_point_has_zero_threshold v)) ~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; - if not (exponential_histogram_has_aggregation_temporality v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (exponential_histogram_has_aggregation_temporality v)) ~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; - if not (summary_data_point_value_at_quantile_has_quantile v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "value" Pbrt.Pp.pp_float fmt v.value; - if not (summary_data_point_value_at_quantile_has_value v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (summary_data_point_value_at_quantile_has_quantile v)) ~first:true "quantile" Pbrt.Pp.pp_float fmt v.quantile; + Pbrt.Pp.pp_record_field ~absent:(not (summary_data_point_value_at_quantile_has_value v)) ~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; - if not (summary_data_point_has_start_time_unix_nano v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.time_unix_nano; - if not (summary_data_point_has_time_unix_nano v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "count" Pbrt.Pp.pp_int64 fmt v.count; - if not (summary_data_point_has_count v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "sum" Pbrt.Pp.pp_float fmt v.sum; - if not (summary_data_point_has_sum v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (summary_data_point_has_start_time_unix_nano v)) ~first:false "start_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.start_time_unix_nano; + Pbrt.Pp.pp_record_field ~absent:(not (summary_data_point_has_time_unix_nano v)) ~first:false "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.time_unix_nano; + Pbrt.Pp.pp_record_field ~absent:(not (summary_data_point_has_count v)) ~first:false "count" Pbrt.Pp.pp_int64 fmt v.count; + Pbrt.Pp.pp_record_field ~absent:(not (summary_data_point_has_sum v)) ~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; - if not (summary_data_point_has_flags v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (summary_data_point_has_flags v)) ~first:false "flags" Pbrt.Pp.pp_int32 fmt v.flags; in Pbrt.Pp.pp_brk pp_i fmt () @@ -1051,12 +1023,9 @@ let rec pp_metric_data fmt (v:metric_data) = 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; - if not (metric_has_name v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "description" Pbrt.Pp.pp_string fmt v.description; - if not (metric_has_description v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "unit_" Pbrt.Pp.pp_string fmt v.unit_; - if not (metric_has_unit_ v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (metric_has_name v)) ~first:true "name" Pbrt.Pp.pp_string fmt v.name; + Pbrt.Pp.pp_record_field ~absent:(not (metric_has_description v)) ~first:false "description" Pbrt.Pp.pp_string fmt v.description; + Pbrt.Pp.pp_record_field ~absent:(not (metric_has_unit_ v)) ~first:false "unit_" Pbrt.Pp.pp_string fmt v.unit_; Pbrt.Pp.pp_record_field ~first:false "data" (Pbrt.Pp.pp_option pp_metric_data) fmt v.data; Pbrt.Pp.pp_record_field ~first:false "metadata" (Pbrt.Pp.pp_list Common.pp_key_value) fmt v.metadata; in @@ -1066,8 +1035,7 @@ 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; - if not (scope_metrics_has_schema_url v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (scope_metrics_has_schema_url v)) ~first:false "schema_url" Pbrt.Pp.pp_string fmt v.schema_url; in Pbrt.Pp.pp_brk pp_i fmt () @@ -1075,8 +1043,7 @@ 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; - if not (resource_metrics_has_schema_url v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (resource_metrics_has_schema_url v)) ~first:false "schema_url" Pbrt.Pp.pp_string fmt v.schema_url; in Pbrt.Pp.pp_brk pp_i fmt () @@ -1220,12 +1187,10 @@ let rec encode_pb_histogram_data_point (v:histogram_data_point) 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; + if histogram_data_point_has_sum v then ( + Pbrt.Encoder.float_as_bits64 v.sum 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; @@ -1246,18 +1211,14 @@ let rec encode_pb_histogram_data_point (v:histogram_data_point) 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; + if histogram_data_point_has_min v then ( + Pbrt.Encoder.float_as_bits64 v.min encoder; Pbrt.Encoder.key 11 Pbrt.Bits64 encoder; - | None -> (); - end; - begin match v.max with - | Some x -> - Pbrt.Encoder.float_as_bits64 x encoder; + ); + if histogram_data_point_has_max v then ( + Pbrt.Encoder.float_as_bits64 v.max encoder; Pbrt.Encoder.key 12 Pbrt.Bits64 encoder; - | None -> (); - end; + ); () let rec encode_pb_histogram (v:histogram) encoder = @@ -1301,12 +1262,10 @@ let rec encode_pb_exponential_histogram_data_point (v:exponential_histogram_data 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; + if exponential_histogram_data_point_has_sum v then ( + Pbrt.Encoder.float_as_bits64 v.sum encoder; Pbrt.Encoder.key 5 Pbrt.Bits64 encoder; - | None -> (); - end; + ); if exponential_histogram_data_point_has_scale v then ( Pbrt.Encoder.int32_as_zigzag v.scale encoder; Pbrt.Encoder.key 6 Pbrt.Varint encoder; @@ -1335,18 +1294,14 @@ let rec encode_pb_exponential_histogram_data_point (v:exponential_histogram_data 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; + if exponential_histogram_data_point_has_min v then ( + Pbrt.Encoder.float_as_bits64 v.min encoder; Pbrt.Encoder.key 12 Pbrt.Bits64 encoder; - | None -> (); - end; - begin match v.max with - | Some x -> - Pbrt.Encoder.float_as_bits64 x encoder; + ); + if exponential_histogram_data_point_has_max v then ( + Pbrt.Encoder.float_as_bits64 v.max encoder; Pbrt.Encoder.key 13 Pbrt.Bits64 encoder; - | None -> (); - end; + ); if exponential_histogram_data_point_has_zero_threshold v then ( Pbrt.Encoder.float_as_bits64 v.zero_threshold encoder; Pbrt.Encoder.key 14 Pbrt.Bits64 encoder; @@ -1547,32 +1502,32 @@ and decode_pb_exemplar d = exemplar_set_filtered_attributes v ((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 + Pbrt.Decoder.unexpected_payload_message "exemplar" 7 pk | Some (2, Pbrt.Bits64) -> begin exemplar_set_time_unix_nano v (Pbrt.Decoder.int64_as_bits64 d); end | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exemplar), field(2)" pk + Pbrt.Decoder.unexpected_payload_message "exemplar" 2 pk | Some (3, Pbrt.Bits64) -> begin exemplar_set_value v (As_double (Pbrt.Decoder.float_as_bits64 d)); end | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exemplar), field(3)" pk + Pbrt.Decoder.unexpected_payload_message "exemplar" 3 pk | Some (6, Pbrt.Bits64) -> begin exemplar_set_value v (As_int (Pbrt.Decoder.int64_as_bits64 d)); end | Some (6, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exemplar), field(6)" pk + Pbrt.Decoder.unexpected_payload_message "exemplar" 6 pk | Some (4, Pbrt.Bytes) -> begin exemplar_set_span_id v (Pbrt.Decoder.bytes d); end | Some (4, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exemplar), field(4)" pk + Pbrt.Decoder.unexpected_payload_message "exemplar" 4 pk | Some (5, Pbrt.Bytes) -> begin exemplar_set_trace_id v (Pbrt.Decoder.bytes d); end | Some (5, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exemplar), field(5)" pk + Pbrt.Decoder.unexpected_payload_message "exemplar" 5 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : exemplar) @@ -1606,37 +1561,37 @@ and decode_pb_number_data_point d = number_data_point_set_attributes v ((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 + Pbrt.Decoder.unexpected_payload_message "number_data_point" 7 pk | Some (2, Pbrt.Bits64) -> begin number_data_point_set_start_time_unix_nano v (Pbrt.Decoder.int64_as_bits64 d); end | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(2)" pk + Pbrt.Decoder.unexpected_payload_message "number_data_point" 2 pk | Some (3, Pbrt.Bits64) -> begin number_data_point_set_time_unix_nano v (Pbrt.Decoder.int64_as_bits64 d); end | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(3)" pk + Pbrt.Decoder.unexpected_payload_message "number_data_point" 3 pk | Some (4, Pbrt.Bits64) -> begin number_data_point_set_value v (As_double (Pbrt.Decoder.float_as_bits64 d)); end | Some (4, pk) -> - Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(4)" pk + Pbrt.Decoder.unexpected_payload_message "number_data_point" 4 pk | Some (6, Pbrt.Bits64) -> begin number_data_point_set_value v (As_int (Pbrt.Decoder.int64_as_bits64 d)); end | Some (6, pk) -> - Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(6)" pk + Pbrt.Decoder.unexpected_payload_message "number_data_point" 6 pk | Some (5, Pbrt.Bytes) -> begin number_data_point_set_exemplars v ((decode_pb_exemplar (Pbrt.Decoder.nested d)) :: v.exemplars); end | Some (5, pk) -> - Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(5)" pk + Pbrt.Decoder.unexpected_payload_message "number_data_point" 5 pk | Some (8, Pbrt.Varint) -> begin number_data_point_set_flags v (Pbrt.Decoder.int32_as_varint d); end | Some (8, pk) -> - Pbrt.Decoder.unexpected_payload "Message(number_data_point), field(8)" pk + Pbrt.Decoder.unexpected_payload_message "number_data_point" 8 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : number_data_point) @@ -1654,16 +1609,16 @@ let rec decode_pb_gauge d = gauge_set_data_points v ((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 + Pbrt.Decoder.unexpected_payload_message "gauge" 1 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : gauge) -let rec decode_pb_aggregation_temporality d = +let rec decode_pb_aggregation_temporality d : aggregation_temporality = 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) + | 0 -> Aggregation_temporality_unspecified + | 1 -> Aggregation_temporality_delta + | 2 -> Aggregation_temporality_cumulative | _ -> Pbrt.Decoder.malformed_variant "aggregation_temporality" let rec decode_pb_sum d = @@ -1679,17 +1634,17 @@ let rec decode_pb_sum d = sum_set_data_points v ((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 + Pbrt.Decoder.unexpected_payload_message "sum" 1 pk | Some (2, Pbrt.Varint) -> begin sum_set_aggregation_temporality v (decode_pb_aggregation_temporality d); end | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(sum), field(2)" pk + Pbrt.Decoder.unexpected_payload_message "sum" 2 pk | Some (3, Pbrt.Varint) -> begin sum_set_is_monotonic v (Pbrt.Decoder.bool d); end | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(sum), field(3)" pk + Pbrt.Decoder.unexpected_payload_message "sum" 3 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : sum) @@ -1710,57 +1665,57 @@ let rec decode_pb_histogram_data_point d = histogram_data_point_set_attributes v ((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 + Pbrt.Decoder.unexpected_payload_message "histogram_data_point" 9 pk | Some (2, Pbrt.Bits64) -> begin histogram_data_point_set_start_time_unix_nano v (Pbrt.Decoder.int64_as_bits64 d); end | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(2)" pk + Pbrt.Decoder.unexpected_payload_message "histogram_data_point" 2 pk | Some (3, Pbrt.Bits64) -> begin histogram_data_point_set_time_unix_nano v (Pbrt.Decoder.int64_as_bits64 d); end | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(3)" pk + Pbrt.Decoder.unexpected_payload_message "histogram_data_point" 3 pk | Some (4, Pbrt.Bits64) -> begin histogram_data_point_set_count v (Pbrt.Decoder.int64_as_bits64 d); end | Some (4, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(4)" pk + Pbrt.Decoder.unexpected_payload_message "histogram_data_point" 4 pk | Some (5, Pbrt.Bits64) -> begin histogram_data_point_set_sum v (Pbrt.Decoder.float_as_bits64 d); end | Some (5, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(5)" pk + Pbrt.Decoder.unexpected_payload_message "histogram_data_point" 5 pk | Some (6, Pbrt.Bytes) -> begin histogram_data_point_set_bucket_counts v @@ 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 + Pbrt.Decoder.unexpected_payload_message "histogram_data_point" 6 pk | Some (7, Pbrt.Bytes) -> begin histogram_data_point_set_explicit_bounds v @@ 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 + Pbrt.Decoder.unexpected_payload_message "histogram_data_point" 7 pk | Some (8, Pbrt.Bytes) -> begin histogram_data_point_set_exemplars v ((decode_pb_exemplar (Pbrt.Decoder.nested d)) :: v.exemplars); end | Some (8, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(8)" pk + Pbrt.Decoder.unexpected_payload_message "histogram_data_point" 8 pk | Some (10, Pbrt.Varint) -> begin histogram_data_point_set_flags v (Pbrt.Decoder.int32_as_varint d); end | Some (10, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(10)" pk + Pbrt.Decoder.unexpected_payload_message "histogram_data_point" 10 pk | Some (11, Pbrt.Bits64) -> begin histogram_data_point_set_min v (Pbrt.Decoder.float_as_bits64 d); end | Some (11, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(11)" pk + Pbrt.Decoder.unexpected_payload_message "histogram_data_point" 11 pk | Some (12, Pbrt.Bits64) -> begin histogram_data_point_set_max v (Pbrt.Decoder.float_as_bits64 d); end | Some (12, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram_data_point), field(12)" pk + Pbrt.Decoder.unexpected_payload_message "histogram_data_point" 12 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : histogram_data_point) @@ -1778,12 +1733,12 @@ let rec decode_pb_histogram d = histogram_set_data_points v ((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 + Pbrt.Decoder.unexpected_payload_message "histogram" 1 pk | Some (2, Pbrt.Varint) -> begin histogram_set_aggregation_temporality v (decode_pb_aggregation_temporality d); end | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(histogram), field(2)" pk + Pbrt.Decoder.unexpected_payload_message "histogram" 2 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : histogram) @@ -1801,12 +1756,12 @@ let rec decode_pb_exponential_histogram_data_point_buckets d = exponential_histogram_data_point_buckets_set_offset v (Pbrt.Decoder.int32_as_zigzag d); end | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point_buckets), field(1)" pk + Pbrt.Decoder.unexpected_payload_message "exponential_histogram_data_point_buckets" 1 pk | Some (2, Pbrt.Bytes) -> begin exponential_histogram_data_point_buckets_set_bucket_counts v @@ 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 + Pbrt.Decoder.unexpected_payload_message "exponential_histogram_data_point_buckets" 2 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : exponential_histogram_data_point_buckets) @@ -1825,72 +1780,72 @@ let rec decode_pb_exponential_histogram_data_point d = exponential_histogram_data_point_set_attributes v ((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 + Pbrt.Decoder.unexpected_payload_message "exponential_histogram_data_point" 1 pk | Some (2, Pbrt.Bits64) -> begin exponential_histogram_data_point_set_start_time_unix_nano v (Pbrt.Decoder.int64_as_bits64 d); end | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(2)" pk + Pbrt.Decoder.unexpected_payload_message "exponential_histogram_data_point" 2 pk | Some (3, Pbrt.Bits64) -> begin exponential_histogram_data_point_set_time_unix_nano v (Pbrt.Decoder.int64_as_bits64 d); end | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(3)" pk + Pbrt.Decoder.unexpected_payload_message "exponential_histogram_data_point" 3 pk | Some (4, Pbrt.Bits64) -> begin exponential_histogram_data_point_set_count v (Pbrt.Decoder.int64_as_bits64 d); end | Some (4, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(4)" pk + Pbrt.Decoder.unexpected_payload_message "exponential_histogram_data_point" 4 pk | Some (5, Pbrt.Bits64) -> begin exponential_histogram_data_point_set_sum v (Pbrt.Decoder.float_as_bits64 d); end | Some (5, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(5)" pk + Pbrt.Decoder.unexpected_payload_message "exponential_histogram_data_point" 5 pk | Some (6, Pbrt.Varint) -> begin exponential_histogram_data_point_set_scale v (Pbrt.Decoder.int32_as_zigzag d); end | Some (6, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(6)" pk + Pbrt.Decoder.unexpected_payload_message "exponential_histogram_data_point" 6 pk | Some (7, Pbrt.Bits64) -> begin exponential_histogram_data_point_set_zero_count v (Pbrt.Decoder.int64_as_bits64 d); end | Some (7, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(7)" pk + Pbrt.Decoder.unexpected_payload_message "exponential_histogram_data_point" 7 pk | Some (8, Pbrt.Bytes) -> begin exponential_histogram_data_point_set_positive v (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 + Pbrt.Decoder.unexpected_payload_message "exponential_histogram_data_point" 8 pk | Some (9, Pbrt.Bytes) -> begin exponential_histogram_data_point_set_negative v (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 + Pbrt.Decoder.unexpected_payload_message "exponential_histogram_data_point" 9 pk | Some (10, Pbrt.Varint) -> begin exponential_histogram_data_point_set_flags v (Pbrt.Decoder.int32_as_varint d); end | Some (10, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(10)" pk + Pbrt.Decoder.unexpected_payload_message "exponential_histogram_data_point" 10 pk | Some (11, Pbrt.Bytes) -> begin exponential_histogram_data_point_set_exemplars v ((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 + Pbrt.Decoder.unexpected_payload_message "exponential_histogram_data_point" 11 pk | Some (12, Pbrt.Bits64) -> begin exponential_histogram_data_point_set_min v (Pbrt.Decoder.float_as_bits64 d); end | Some (12, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(12)" pk + Pbrt.Decoder.unexpected_payload_message "exponential_histogram_data_point" 12 pk | Some (13, Pbrt.Bits64) -> begin exponential_histogram_data_point_set_max v (Pbrt.Decoder.float_as_bits64 d); end | Some (13, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(13)" pk + Pbrt.Decoder.unexpected_payload_message "exponential_histogram_data_point" 13 pk | Some (14, Pbrt.Bits64) -> begin exponential_histogram_data_point_set_zero_threshold v (Pbrt.Decoder.float_as_bits64 d); end | Some (14, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(14)" pk + Pbrt.Decoder.unexpected_payload_message "exponential_histogram_data_point" 14 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : exponential_histogram_data_point) @@ -1908,12 +1863,12 @@ let rec decode_pb_exponential_histogram d = exponential_histogram_set_data_points v ((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 + Pbrt.Decoder.unexpected_payload_message "exponential_histogram" 1 pk | Some (2, Pbrt.Varint) -> begin exponential_histogram_set_aggregation_temporality v (decode_pb_aggregation_temporality d); end | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(exponential_histogram), field(2)" pk + Pbrt.Decoder.unexpected_payload_message "exponential_histogram" 2 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : exponential_histogram) @@ -1929,12 +1884,12 @@ let rec decode_pb_summary_data_point_value_at_quantile d = summary_data_point_value_at_quantile_set_quantile v (Pbrt.Decoder.float_as_bits64 d); end | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(summary_data_point_value_at_quantile), field(1)" pk + Pbrt.Decoder.unexpected_payload_message "summary_data_point_value_at_quantile" 1 pk | Some (2, Pbrt.Bits64) -> begin summary_data_point_value_at_quantile_set_value v (Pbrt.Decoder.float_as_bits64 d); end | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(summary_data_point_value_at_quantile), field(2)" pk + Pbrt.Decoder.unexpected_payload_message "summary_data_point_value_at_quantile" 2 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : summary_data_point_value_at_quantile) @@ -1953,37 +1908,37 @@ let rec decode_pb_summary_data_point d = summary_data_point_set_attributes v ((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 + Pbrt.Decoder.unexpected_payload_message "summary_data_point" 7 pk | Some (2, Pbrt.Bits64) -> begin summary_data_point_set_start_time_unix_nano v (Pbrt.Decoder.int64_as_bits64 d); end | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(2)" pk + Pbrt.Decoder.unexpected_payload_message "summary_data_point" 2 pk | Some (3, Pbrt.Bits64) -> begin summary_data_point_set_time_unix_nano v (Pbrt.Decoder.int64_as_bits64 d); end | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(3)" pk + Pbrt.Decoder.unexpected_payload_message "summary_data_point" 3 pk | Some (4, Pbrt.Bits64) -> begin summary_data_point_set_count v (Pbrt.Decoder.int64_as_bits64 d); end | Some (4, pk) -> - Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(4)" pk + Pbrt.Decoder.unexpected_payload_message "summary_data_point" 4 pk | Some (5, Pbrt.Bits64) -> begin summary_data_point_set_sum v (Pbrt.Decoder.float_as_bits64 d); end | Some (5, pk) -> - Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(5)" pk + Pbrt.Decoder.unexpected_payload_message "summary_data_point" 5 pk | Some (6, Pbrt.Bytes) -> begin summary_data_point_set_quantile_values v ((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 + Pbrt.Decoder.unexpected_payload_message "summary_data_point" 6 pk | Some (8, Pbrt.Varint) -> begin summary_data_point_set_flags v (Pbrt.Decoder.int32_as_varint d); end | Some (8, pk) -> - Pbrt.Decoder.unexpected_payload "Message(summary_data_point), field(8)" pk + Pbrt.Decoder.unexpected_payload_message "summary_data_point" 8 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : summary_data_point) @@ -2001,7 +1956,7 @@ let rec decode_pb_summary d = summary_set_data_points v ((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 + Pbrt.Decoder.unexpected_payload_message "summary" 1 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : summary) @@ -2037,47 +1992,47 @@ and decode_pb_metric d = metric_set_name v (Pbrt.Decoder.string d); end | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(metric), field(1)" pk + Pbrt.Decoder.unexpected_payload_message "metric" 1 pk | Some (2, Pbrt.Bytes) -> begin metric_set_description v (Pbrt.Decoder.string d); end | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(metric), field(2)" pk + Pbrt.Decoder.unexpected_payload_message "metric" 2 pk | Some (3, Pbrt.Bytes) -> begin metric_set_unit_ v (Pbrt.Decoder.string d); end | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(metric), field(3)" pk + Pbrt.Decoder.unexpected_payload_message "metric" 3 pk | Some (5, Pbrt.Bytes) -> begin metric_set_data v (Gauge (decode_pb_gauge (Pbrt.Decoder.nested d))); end | Some (5, pk) -> - Pbrt.Decoder.unexpected_payload "Message(metric), field(5)" pk + Pbrt.Decoder.unexpected_payload_message "metric" 5 pk | Some (7, Pbrt.Bytes) -> begin metric_set_data v (Sum (decode_pb_sum (Pbrt.Decoder.nested d))); end | Some (7, pk) -> - Pbrt.Decoder.unexpected_payload "Message(metric), field(7)" pk + Pbrt.Decoder.unexpected_payload_message "metric" 7 pk | Some (9, Pbrt.Bytes) -> begin metric_set_data v (Histogram (decode_pb_histogram (Pbrt.Decoder.nested d))); end | Some (9, pk) -> - Pbrt.Decoder.unexpected_payload "Message(metric), field(9)" pk + Pbrt.Decoder.unexpected_payload_message "metric" 9 pk | Some (10, Pbrt.Bytes) -> begin metric_set_data v (Exponential_histogram (decode_pb_exponential_histogram (Pbrt.Decoder.nested d))); end | Some (10, pk) -> - Pbrt.Decoder.unexpected_payload "Message(metric), field(10)" pk + Pbrt.Decoder.unexpected_payload_message "metric" 10 pk | Some (11, Pbrt.Bytes) -> begin metric_set_data v (Summary (decode_pb_summary (Pbrt.Decoder.nested d))); end | Some (11, pk) -> - Pbrt.Decoder.unexpected_payload "Message(metric), field(11)" pk + Pbrt.Decoder.unexpected_payload_message "metric" 11 pk | Some (12, Pbrt.Bytes) -> begin metric_set_metadata v ((Common.decode_pb_key_value (Pbrt.Decoder.nested d)) :: v.metadata); end | Some (12, pk) -> - Pbrt.Decoder.unexpected_payload "Message(metric), field(12)" pk + Pbrt.Decoder.unexpected_payload_message "metric" 12 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : metric) @@ -2095,17 +2050,17 @@ let rec decode_pb_scope_metrics d = scope_metrics_set_scope v (Common.decode_pb_instrumentation_scope (Pbrt.Decoder.nested d)); end | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(scope_metrics), field(1)" pk + Pbrt.Decoder.unexpected_payload_message "scope_metrics" 1 pk | Some (2, Pbrt.Bytes) -> begin scope_metrics_set_metrics v ((decode_pb_metric (Pbrt.Decoder.nested d)) :: v.metrics); end | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(scope_metrics), field(2)" pk + Pbrt.Decoder.unexpected_payload_message "scope_metrics" 2 pk | Some (3, Pbrt.Bytes) -> begin scope_metrics_set_schema_url v (Pbrt.Decoder.string d); end | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(scope_metrics), field(3)" pk + Pbrt.Decoder.unexpected_payload_message "scope_metrics" 3 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : scope_metrics) @@ -2123,17 +2078,17 @@ let rec decode_pb_resource_metrics d = resource_metrics_set_resource v (Resource.decode_pb_resource (Pbrt.Decoder.nested d)); end | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(resource_metrics), field(1)" pk + Pbrt.Decoder.unexpected_payload_message "resource_metrics" 1 pk | Some (2, Pbrt.Bytes) -> begin resource_metrics_set_scope_metrics v ((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 + Pbrt.Decoder.unexpected_payload_message "resource_metrics" 2 pk | Some (3, Pbrt.Bytes) -> begin resource_metrics_set_schema_url v (Pbrt.Decoder.string d); end | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(resource_metrics), field(3)" pk + Pbrt.Decoder.unexpected_payload_message "resource_metrics" 3 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : resource_metrics) @@ -2151,13 +2106,13 @@ let rec decode_pb_metrics_data d = metrics_data_set_resource_metrics v ((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 + Pbrt.Decoder.unexpected_payload_message "metrics_data" 1 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : metrics_data) -let rec decode_pb_data_point_flags d = +let rec decode_pb_data_point_flags d : data_point_flags = 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) + | 0 -> Data_point_flags_do_not_use + | 1 -> Data_point_flags_no_recorded_value_mask | _ -> Pbrt.Decoder.malformed_variant "data_point_flags" diff --git a/src/proto/metrics.mli b/src/proto/metrics.mli index 167c0fd4..92c678a2 100644 --- a/src/proto/metrics.mli +++ b/src/proto/metrics.mli @@ -51,18 +51,18 @@ type sum = private { } type histogram_data_point = private { - mutable _presence: Pbrt.Bitfield.t; (** presence for 4 fields *) + mutable _presence: Pbrt.Bitfield.t; (** presence for 7 fields *) 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 sum : float; 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; + mutable min : float; + mutable max : float; } type histogram = private { @@ -78,20 +78,20 @@ type exponential_histogram_data_point_buckets = private { } type exponential_histogram_data_point = private { - mutable _presence: Pbrt.Bitfield.t; (** presence for 7 fields *) + mutable _presence: Pbrt.Bitfield.t; (** presence for 10 fields *) 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 sum : float; 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 min : float; + mutable max : float; mutable zero_threshold : float; } @@ -229,7 +229,6 @@ val default_data_point_flags : unit -> data_point_flags (** {2 Make functions} *) - val make_exemplar : ?filtered_attributes:Common.key_value list -> ?time_unix_nano:int64 -> @@ -266,7 +265,6 @@ val exemplar_has_trace_id : exemplar -> bool val exemplar_set_trace_id : exemplar -> bytes -> unit (** set field trace_id in exemplar *) - val make_number_data_point : ?attributes:Common.key_value list -> ?start_time_unix_nano:int64 -> @@ -318,7 +316,6 @@ val copy_gauge : gauge -> gauge val gauge_set_data_points : gauge -> number_data_point list -> unit (** set field data_points in gauge *) - val make_sum : ?data_points:number_data_point list -> ?aggregation_temporality:aggregation_temporality -> @@ -383,6 +380,9 @@ val histogram_data_point_has_count : histogram_data_point -> bool val histogram_data_point_set_count : histogram_data_point -> int64 -> unit (** set field count in histogram_data_point *) +val histogram_data_point_has_sum : histogram_data_point -> bool + (** presence of field "sum" in [histogram_data_point] *) + val histogram_data_point_set_sum : histogram_data_point -> float -> unit (** set field sum in histogram_data_point *) @@ -401,9 +401,15 @@ val histogram_data_point_has_flags : histogram_data_point -> bool val histogram_data_point_set_flags : histogram_data_point -> int32 -> unit (** set field flags in histogram_data_point *) +val histogram_data_point_has_min : histogram_data_point -> bool + (** presence of field "min" in [histogram_data_point] *) + val histogram_data_point_set_min : histogram_data_point -> float -> unit (** set field min in histogram_data_point *) +val histogram_data_point_has_max : histogram_data_point -> bool + (** presence of field "max" in [histogram_data_point] *) + val histogram_data_point_set_max : histogram_data_point -> float -> unit (** set field max in histogram_data_point *) @@ -485,6 +491,9 @@ val exponential_histogram_data_point_has_count : exponential_histogram_data_poin val exponential_histogram_data_point_set_count : exponential_histogram_data_point -> int64 -> unit (** set field count in exponential_histogram_data_point *) +val exponential_histogram_data_point_has_sum : exponential_histogram_data_point -> bool + (** presence of field "sum" in [exponential_histogram_data_point] *) + val exponential_histogram_data_point_set_sum : exponential_histogram_data_point -> float -> unit (** set field sum in exponential_histogram_data_point *) @@ -515,9 +524,15 @@ val exponential_histogram_data_point_set_flags : exponential_histogram_data_poin val exponential_histogram_data_point_set_exemplars : exponential_histogram_data_point -> exemplar list -> unit (** set field exemplars in exponential_histogram_data_point *) +val exponential_histogram_data_point_has_min : exponential_histogram_data_point -> bool + (** presence of field "min" in [exponential_histogram_data_point] *) + val exponential_histogram_data_point_set_min : exponential_histogram_data_point -> float -> unit (** set field min in exponential_histogram_data_point *) +val exponential_histogram_data_point_has_max : exponential_histogram_data_point -> bool + (** presence of field "max" in [exponential_histogram_data_point] *) + val exponential_histogram_data_point_set_max : exponential_histogram_data_point -> float -> unit (** set field max in exponential_histogram_data_point *) @@ -627,7 +642,6 @@ val copy_summary : summary -> summary val summary_set_data_points : summary -> summary_data_point list -> unit (** set field data_points in summary *) - val make_metric : ?name:string -> ?description:string -> @@ -720,7 +734,6 @@ val metrics_data_set_resource_metrics : metrics_data -> resource_metrics list -> (** set field resource_metrics in metrics_data *) - (** {2 Formatters} *) val pp_exemplar_value : Format.formatter -> exemplar_value -> unit diff --git a/src/proto/metrics_service.ml b/src/proto/metrics_service.ml index 8aeeb8a0..1d39a204 100644 --- a/src/proto/metrics_service.ml +++ b/src/proto/metrics_service.ml @@ -100,10 +100,8 @@ let rec pp_export_metrics_service_request fmt (v:export_metrics_service_request) 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; - if not (export_metrics_partial_success_has_rejected_data_points v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "error_message" Pbrt.Pp.pp_string fmt v.error_message; - if not (export_metrics_partial_success_has_error_message v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (export_metrics_partial_success_has_rejected_data_points v)) ~first:true "rejected_data_points" Pbrt.Pp.pp_int64 fmt v.rejected_data_points; + Pbrt.Pp.pp_record_field ~absent:(not (export_metrics_partial_success_has_error_message v)) ~first:false "error_message" Pbrt.Pp.pp_string fmt v.error_message; in Pbrt.Pp.pp_brk pp_i fmt () @@ -161,7 +159,7 @@ let rec decode_pb_export_metrics_service_request d = export_metrics_service_request_set_resource_metrics v ((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 + Pbrt.Decoder.unexpected_payload_message "export_metrics_service_request" 1 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : export_metrics_service_request) @@ -177,12 +175,12 @@ let rec decode_pb_export_metrics_partial_success d = export_metrics_partial_success_set_rejected_data_points v (Pbrt.Decoder.int64_as_varint d); end | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(export_metrics_partial_success), field(1)" pk + Pbrt.Decoder.unexpected_payload_message "export_metrics_partial_success" 1 pk | Some (2, Pbrt.Bytes) -> begin export_metrics_partial_success_set_error_message v (Pbrt.Decoder.string d); end | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(export_metrics_partial_success), field(2)" pk + Pbrt.Decoder.unexpected_payload_message "export_metrics_partial_success" 2 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : export_metrics_partial_success) @@ -198,7 +196,7 @@ let rec decode_pb_export_metrics_service_response d = export_metrics_service_response_set_partial_success v (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 + Pbrt.Decoder.unexpected_payload_message "export_metrics_service_response" 1 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : export_metrics_service_response) diff --git a/src/proto/resource.ml b/src/proto/resource.ml index 0bb9d9cb..913110fd 100644 --- a/src/proto/resource.ml +++ b/src/proto/resource.ml @@ -50,8 +50,7 @@ let make_resource 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; - if not (resource_has_dropped_attributes_count v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (resource_has_dropped_attributes_count v)) ~first:false "dropped_attributes_count" Pbrt.Pp.pp_int32 fmt v.dropped_attributes_count; Pbrt.Pp.pp_record_field ~first:false "entity_refs" (Pbrt.Pp.pp_list Common.pp_entity_ref) fmt v.entity_refs; in Pbrt.Pp.pp_brk pp_i fmt () @@ -93,17 +92,17 @@ let rec decode_pb_resource d = resource_set_attributes v ((Common.decode_pb_key_value (Pbrt.Decoder.nested d)) :: v.attributes); end | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(resource), field(1)" pk + Pbrt.Decoder.unexpected_payload_message "resource" 1 pk | Some (2, Pbrt.Varint) -> begin resource_set_dropped_attributes_count v (Pbrt.Decoder.int32_as_varint d); end | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(resource), field(2)" pk + Pbrt.Decoder.unexpected_payload_message "resource" 2 pk | Some (3, Pbrt.Bytes) -> begin resource_set_entity_refs v ((Common.decode_pb_entity_ref (Pbrt.Decoder.nested d)) :: v.entity_refs); end | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(resource), field(3)" pk + Pbrt.Decoder.unexpected_payload_message "resource" 3 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : resource) diff --git a/src/proto/status.ml b/src/proto/status.ml index 433a1747..64b4943f 100644 --- a/src/proto/status.ml +++ b/src/proto/status.ml @@ -52,10 +52,8 @@ let make_status 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; - if not (status_has_code v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "message" Pbrt.Pp.pp_bytes fmt v.message; - if not (status_has_message v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (status_has_code v)) ~first:true "code" Pbrt.Pp.pp_int32 fmt v.code; + Pbrt.Pp.pp_record_field ~absent:(not (status_has_message v)) ~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 () @@ -96,17 +94,17 @@ let rec decode_pb_status d = status_set_code v (Pbrt.Decoder.int32_as_varint d); end | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(status), field(1)" pk + Pbrt.Decoder.unexpected_payload_message "status" 1 pk | Some (2, Pbrt.Bytes) -> begin status_set_message v (Pbrt.Decoder.bytes d); end | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(status), field(2)" pk + Pbrt.Decoder.unexpected_payload_message "status" 2 pk | Some (3, Pbrt.Bytes) -> begin status_set_details v ((Pbrt.Decoder.bytes d) :: v.details); end | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(status), field(3)" pk + Pbrt.Decoder.unexpected_payload_message "status" 3 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : status) diff --git a/src/proto/trace.ml b/src/proto/trace.ml index 85a7ca26..60c421f5 100644 --- a/src/proto/trace.ml +++ b/src/proto/trace.ml @@ -159,7 +159,6 @@ let default_span_flags () = (Span_flags_do_not_use:span_flags) (** {2 Make functions} *) - let[@inline] span_event_has_time_unix_nano (self:span_event) : bool = (Pbrt.Bitfield.get self._presence 0) let[@inline] span_event_has_name (self:span_event) : bool = (Pbrt.Bitfield.get self._presence 1) let[@inline] span_event_has_dropped_attributes_count (self:span_event) : bool = (Pbrt.Bitfield.get self._presence 2) @@ -244,7 +243,6 @@ let make_span_link | Some v -> span_link_set_flags _res v); _res - let[@inline] status_has_message (self:status) : bool = (Pbrt.Bitfield.get self._presence 0) let[@inline] status_has_code (self:status) : bool = (Pbrt.Bitfield.get self._presence 1) @@ -449,7 +447,6 @@ let make_traces_data traces_data_set_resource_spans _res resource_spans; _res - [@@@ocaml.warning "-23-27-30-39"] (** {2 Formatters} *) @@ -465,29 +462,21 @@ let rec pp_span_span_kind fmt (v:span_span_kind) = 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; - if not (span_event_has_time_unix_nano v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "name" Pbrt.Pp.pp_string fmt v.name; - if not (span_event_has_name v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (span_event_has_time_unix_nano v)) ~first:true "time_unix_nano" Pbrt.Pp.pp_int64 fmt v.time_unix_nano; + Pbrt.Pp.pp_record_field ~absent:(not (span_event_has_name v)) ~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; - if not (span_event_has_dropped_attributes_count v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (span_event_has_dropped_attributes_count v)) ~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; - if not (span_link_has_trace_id v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "span_id" Pbrt.Pp.pp_bytes fmt v.span_id; - if not (span_link_has_span_id v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "trace_state" Pbrt.Pp.pp_string fmt v.trace_state; - if not (span_link_has_trace_state v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (span_link_has_trace_id v)) ~first:true "trace_id" Pbrt.Pp.pp_bytes fmt v.trace_id; + Pbrt.Pp.pp_record_field ~absent:(not (span_link_has_span_id v)) ~first:false "span_id" Pbrt.Pp.pp_bytes fmt v.span_id; + Pbrt.Pp.pp_record_field ~absent:(not (span_link_has_trace_state v)) ~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; - if not (span_link_has_dropped_attributes_count v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "flags" Pbrt.Pp.pp_int32 fmt v.flags; - if not (span_link_has_flags v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (span_link_has_dropped_attributes_count v)) ~first:false "dropped_attributes_count" Pbrt.Pp.pp_int32 fmt v.dropped_attributes_count; + Pbrt.Pp.pp_record_field ~absent:(not (span_link_has_flags v)) ~first:false "flags" Pbrt.Pp.pp_int32 fmt v.flags; in Pbrt.Pp.pp_brk pp_i fmt () @@ -499,42 +488,28 @@ let rec pp_status_status_code fmt (v:status_status_code) = 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; - if not (status_has_message v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "code" pp_status_status_code fmt v.code; - if not (status_has_code v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (status_has_message v)) ~first:true "message" Pbrt.Pp.pp_string fmt v.message; + Pbrt.Pp.pp_record_field ~absent:(not (status_has_code v)) ~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; - if not (span_has_trace_id v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "span_id" Pbrt.Pp.pp_bytes fmt v.span_id; - if not (span_has_span_id v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "trace_state" Pbrt.Pp.pp_string fmt v.trace_state; - if not (span_has_trace_state v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "parent_span_id" Pbrt.Pp.pp_bytes fmt v.parent_span_id; - if not (span_has_parent_span_id v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "flags" Pbrt.Pp.pp_int32 fmt v.flags; - if not (span_has_flags v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "name" Pbrt.Pp.pp_string fmt v.name; - if not (span_has_name v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "kind" pp_span_span_kind fmt v.kind; - if not (span_has_kind v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "start_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.start_time_unix_nano; - if not (span_has_start_time_unix_nano v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "end_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.end_time_unix_nano; - if not (span_has_end_time_unix_nano v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (span_has_trace_id v)) ~first:true "trace_id" Pbrt.Pp.pp_bytes fmt v.trace_id; + Pbrt.Pp.pp_record_field ~absent:(not (span_has_span_id v)) ~first:false "span_id" Pbrt.Pp.pp_bytes fmt v.span_id; + Pbrt.Pp.pp_record_field ~absent:(not (span_has_trace_state v)) ~first:false "trace_state" Pbrt.Pp.pp_string fmt v.trace_state; + Pbrt.Pp.pp_record_field ~absent:(not (span_has_parent_span_id v)) ~first:false "parent_span_id" Pbrt.Pp.pp_bytes fmt v.parent_span_id; + Pbrt.Pp.pp_record_field ~absent:(not (span_has_flags v)) ~first:false "flags" Pbrt.Pp.pp_int32 fmt v.flags; + Pbrt.Pp.pp_record_field ~absent:(not (span_has_name v)) ~first:false "name" Pbrt.Pp.pp_string fmt v.name; + Pbrt.Pp.pp_record_field ~absent:(not (span_has_kind v)) ~first:false "kind" pp_span_span_kind fmt v.kind; + Pbrt.Pp.pp_record_field ~absent:(not (span_has_start_time_unix_nano v)) ~first:false "start_time_unix_nano" Pbrt.Pp.pp_int64 fmt v.start_time_unix_nano; + Pbrt.Pp.pp_record_field ~absent:(not (span_has_end_time_unix_nano v)) ~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; - if not (span_has_dropped_attributes_count v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (span_has_dropped_attributes_count v)) ~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; - if not (span_has_dropped_events_count v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (span_has_dropped_events_count v)) ~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; - if not (span_has_dropped_links_count v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (span_has_dropped_links_count v)) ~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 () @@ -543,8 +518,7 @@ 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; - if not (scope_spans_has_schema_url v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (scope_spans_has_schema_url v)) ~first:false "schema_url" Pbrt.Pp.pp_string fmt v.schema_url; in Pbrt.Pp.pp_brk pp_i fmt () @@ -552,8 +526,7 @@ 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; - if not (resource_spans_has_schema_url v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (resource_spans_has_schema_url v)) ~first:false "schema_url" Pbrt.Pp.pp_string fmt v.schema_url; in Pbrt.Pp.pp_brk pp_i fmt () @@ -767,14 +740,14 @@ let rec encode_pb_span_flags (v:span_flags) encoder = (** {2 Protobuf Decoding} *) -let rec decode_pb_span_span_kind d = +let rec decode_pb_span_span_kind d : span_span_kind = 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) + | 0 -> Span_kind_unspecified + | 1 -> Span_kind_internal + | 2 -> Span_kind_server + | 3 -> Span_kind_client + | 4 -> Span_kind_producer + | 5 -> Span_kind_consumer | _ -> Pbrt.Decoder.malformed_variant "span_span_kind" let rec decode_pb_span_event d = @@ -790,22 +763,22 @@ let rec decode_pb_span_event d = span_event_set_time_unix_nano v (Pbrt.Decoder.int64_as_bits64 d); end | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span_event), field(1)" pk + Pbrt.Decoder.unexpected_payload_message "span_event" 1 pk | Some (2, Pbrt.Bytes) -> begin span_event_set_name v (Pbrt.Decoder.string d); end | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span_event), field(2)" pk + Pbrt.Decoder.unexpected_payload_message "span_event" 2 pk | Some (3, Pbrt.Bytes) -> begin span_event_set_attributes v ((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 + Pbrt.Decoder.unexpected_payload_message "span_event" 3 pk | Some (4, Pbrt.Varint) -> begin span_event_set_dropped_attributes_count v (Pbrt.Decoder.int32_as_varint d); end | Some (4, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span_event), field(4)" pk + Pbrt.Decoder.unexpected_payload_message "span_event" 4 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : span_event) @@ -823,41 +796,41 @@ let rec decode_pb_span_link d = span_link_set_trace_id v (Pbrt.Decoder.bytes d); end | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span_link), field(1)" pk + Pbrt.Decoder.unexpected_payload_message "span_link" 1 pk | Some (2, Pbrt.Bytes) -> begin span_link_set_span_id v (Pbrt.Decoder.bytes d); end | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span_link), field(2)" pk + Pbrt.Decoder.unexpected_payload_message "span_link" 2 pk | Some (3, Pbrt.Bytes) -> begin span_link_set_trace_state v (Pbrt.Decoder.string d); end | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span_link), field(3)" pk + Pbrt.Decoder.unexpected_payload_message "span_link" 3 pk | Some (4, Pbrt.Bytes) -> begin span_link_set_attributes v ((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 + Pbrt.Decoder.unexpected_payload_message "span_link" 4 pk | Some (5, Pbrt.Varint) -> begin span_link_set_dropped_attributes_count v (Pbrt.Decoder.int32_as_varint d); end | Some (5, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span_link), field(5)" pk + Pbrt.Decoder.unexpected_payload_message "span_link" 5 pk | Some (6, Pbrt.Bits32) -> begin span_link_set_flags v (Pbrt.Decoder.int32_as_bits32 d); end | Some (6, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span_link), field(6)" pk + Pbrt.Decoder.unexpected_payload_message "span_link" 6 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : span_link) -let rec decode_pb_status_status_code d = +let rec decode_pb_status_status_code d : status_status_code = 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) + | 0 -> Status_code_unset + | 1 -> Status_code_ok + | 2 -> Status_code_error | _ -> Pbrt.Decoder.malformed_variant "status_status_code" let rec decode_pb_status d = @@ -871,12 +844,12 @@ let rec decode_pb_status d = status_set_message v (Pbrt.Decoder.string d); end | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(status), field(2)" pk + Pbrt.Decoder.unexpected_payload_message "status" 2 pk | Some (3, Pbrt.Varint) -> begin status_set_code v (decode_pb_status_status_code d); end | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(status), field(3)" pk + Pbrt.Decoder.unexpected_payload_message "status" 3 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : status) @@ -896,82 +869,82 @@ let rec decode_pb_span d = span_set_trace_id v (Pbrt.Decoder.bytes d); end | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span), field(1)" pk + Pbrt.Decoder.unexpected_payload_message "span" 1 pk | Some (2, Pbrt.Bytes) -> begin span_set_span_id v (Pbrt.Decoder.bytes d); end | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span), field(2)" pk + Pbrt.Decoder.unexpected_payload_message "span" 2 pk | Some (3, Pbrt.Bytes) -> begin span_set_trace_state v (Pbrt.Decoder.string d); end | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span), field(3)" pk + Pbrt.Decoder.unexpected_payload_message "span" 3 pk | Some (4, Pbrt.Bytes) -> begin span_set_parent_span_id v (Pbrt.Decoder.bytes d); end | Some (4, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span), field(4)" pk + Pbrt.Decoder.unexpected_payload_message "span" 4 pk | Some (16, Pbrt.Bits32) -> begin span_set_flags v (Pbrt.Decoder.int32_as_bits32 d); end | Some (16, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span), field(16)" pk + Pbrt.Decoder.unexpected_payload_message "span" 16 pk | Some (5, Pbrt.Bytes) -> begin span_set_name v (Pbrt.Decoder.string d); end | Some (5, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span), field(5)" pk + Pbrt.Decoder.unexpected_payload_message "span" 5 pk | Some (6, Pbrt.Varint) -> begin span_set_kind v (decode_pb_span_span_kind d); end | Some (6, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span), field(6)" pk + Pbrt.Decoder.unexpected_payload_message "span" 6 pk | Some (7, Pbrt.Bits64) -> begin span_set_start_time_unix_nano v (Pbrt.Decoder.int64_as_bits64 d); end | Some (7, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span), field(7)" pk + Pbrt.Decoder.unexpected_payload_message "span" 7 pk | Some (8, Pbrt.Bits64) -> begin span_set_end_time_unix_nano v (Pbrt.Decoder.int64_as_bits64 d); end | Some (8, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span), field(8)" pk + Pbrt.Decoder.unexpected_payload_message "span" 8 pk | Some (9, Pbrt.Bytes) -> begin span_set_attributes v ((Common.decode_pb_key_value (Pbrt.Decoder.nested d)) :: v.attributes); end | Some (9, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span), field(9)" pk + Pbrt.Decoder.unexpected_payload_message "span" 9 pk | Some (10, Pbrt.Varint) -> begin span_set_dropped_attributes_count v (Pbrt.Decoder.int32_as_varint d); end | Some (10, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span), field(10)" pk + Pbrt.Decoder.unexpected_payload_message "span" 10 pk | Some (11, Pbrt.Bytes) -> begin span_set_events v ((decode_pb_span_event (Pbrt.Decoder.nested d)) :: v.events); end | Some (11, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span), field(11)" pk + Pbrt.Decoder.unexpected_payload_message "span" 11 pk | Some (12, Pbrt.Varint) -> begin span_set_dropped_events_count v (Pbrt.Decoder.int32_as_varint d); end | Some (12, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span), field(12)" pk + Pbrt.Decoder.unexpected_payload_message "span" 12 pk | Some (13, Pbrt.Bytes) -> begin span_set_links v ((decode_pb_span_link (Pbrt.Decoder.nested d)) :: v.links); end | Some (13, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span), field(13)" pk + Pbrt.Decoder.unexpected_payload_message "span" 13 pk | Some (14, Pbrt.Varint) -> begin span_set_dropped_links_count v (Pbrt.Decoder.int32_as_varint d); end | Some (14, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span), field(14)" pk + Pbrt.Decoder.unexpected_payload_message "span" 14 pk | Some (15, Pbrt.Bytes) -> begin span_set_status v (decode_pb_status (Pbrt.Decoder.nested d)); end | Some (15, pk) -> - Pbrt.Decoder.unexpected_payload "Message(span), field(15)" pk + Pbrt.Decoder.unexpected_payload_message "span" 15 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : span) @@ -989,17 +962,17 @@ let rec decode_pb_scope_spans d = scope_spans_set_scope v (Common.decode_pb_instrumentation_scope (Pbrt.Decoder.nested d)); end | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(scope_spans), field(1)" pk + Pbrt.Decoder.unexpected_payload_message "scope_spans" 1 pk | Some (2, Pbrt.Bytes) -> begin scope_spans_set_spans v ((decode_pb_span (Pbrt.Decoder.nested d)) :: v.spans); end | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(scope_spans), field(2)" pk + Pbrt.Decoder.unexpected_payload_message "scope_spans" 2 pk | Some (3, Pbrt.Bytes) -> begin scope_spans_set_schema_url v (Pbrt.Decoder.string d); end | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(scope_spans), field(3)" pk + Pbrt.Decoder.unexpected_payload_message "scope_spans" 3 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : scope_spans) @@ -1017,17 +990,17 @@ let rec decode_pb_resource_spans d = resource_spans_set_resource v (Resource.decode_pb_resource (Pbrt.Decoder.nested d)); end | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(resource_spans), field(1)" pk + Pbrt.Decoder.unexpected_payload_message "resource_spans" 1 pk | Some (2, Pbrt.Bytes) -> begin resource_spans_set_scope_spans v ((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 + Pbrt.Decoder.unexpected_payload_message "resource_spans" 2 pk | Some (3, Pbrt.Bytes) -> begin resource_spans_set_schema_url v (Pbrt.Decoder.string d); end | Some (3, pk) -> - Pbrt.Decoder.unexpected_payload "Message(resource_spans), field(3)" pk + Pbrt.Decoder.unexpected_payload_message "resource_spans" 3 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : resource_spans) @@ -1045,15 +1018,15 @@ let rec decode_pb_traces_data d = traces_data_set_resource_spans v ((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 + Pbrt.Decoder.unexpected_payload_message "traces_data" 1 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : traces_data) -let rec decode_pb_span_flags d = +let rec decode_pb_span_flags d : span_flags = match Pbrt.Decoder.int_as_varint d with - | 0 -> (Span_flags_do_not_use:span_flags) - | 255 -> (Span_flags_trace_flags_mask:span_flags) - | 256 -> (Span_flags_context_has_is_remote_mask:span_flags) - | 512 -> (Span_flags_context_is_remote_mask:span_flags) + | 0 -> Span_flags_do_not_use + | 255 -> Span_flags_trace_flags_mask + | 256 -> Span_flags_context_has_is_remote_mask + | 512 -> Span_flags_context_is_remote_mask | _ -> Pbrt.Decoder.malformed_variant "span_flags" diff --git a/src/proto/trace.mli b/src/proto/trace.mli index 24e47f53..ba4dcfd2 100644 --- a/src/proto/trace.mli +++ b/src/proto/trace.mli @@ -124,7 +124,6 @@ val default_span_flags : unit -> span_flags (** {2 Make functions} *) - val make_span_event : ?time_unix_nano:int64 -> ?name:string -> @@ -203,7 +202,6 @@ val span_link_has_flags : span_link -> bool val span_link_set_flags : span_link -> int32 -> unit (** set field flags in span_link *) - val make_status : ?message:string -> ?code:status_status_code -> @@ -388,7 +386,6 @@ val traces_data_set_resource_spans : traces_data -> resource_spans list -> unit (** set field resource_spans in traces_data *) - (** {2 Formatters} *) val pp_span_span_kind : Format.formatter -> span_span_kind -> unit diff --git a/src/proto/trace_service.ml b/src/proto/trace_service.ml index 2fe72338..4839ec04 100644 --- a/src/proto/trace_service.ml +++ b/src/proto/trace_service.ml @@ -100,10 +100,8 @@ let rec pp_export_trace_service_request fmt (v:export_trace_service_request) = 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; - if not (export_trace_partial_success_has_rejected_spans v) then Format.pp_print_string fmt "(* absent *)"; - Pbrt.Pp.pp_record_field ~first:false "error_message" Pbrt.Pp.pp_string fmt v.error_message; - if not (export_trace_partial_success_has_error_message v) then Format.pp_print_string fmt "(* absent *)"; + Pbrt.Pp.pp_record_field ~absent:(not (export_trace_partial_success_has_rejected_spans v)) ~first:true "rejected_spans" Pbrt.Pp.pp_int64 fmt v.rejected_spans; + Pbrt.Pp.pp_record_field ~absent:(not (export_trace_partial_success_has_error_message v)) ~first:false "error_message" Pbrt.Pp.pp_string fmt v.error_message; in Pbrt.Pp.pp_brk pp_i fmt () @@ -161,7 +159,7 @@ let rec decode_pb_export_trace_service_request d = export_trace_service_request_set_resource_spans v ((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 + Pbrt.Decoder.unexpected_payload_message "export_trace_service_request" 1 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : export_trace_service_request) @@ -177,12 +175,12 @@ let rec decode_pb_export_trace_partial_success d = export_trace_partial_success_set_rejected_spans v (Pbrt.Decoder.int64_as_varint d); end | Some (1, pk) -> - Pbrt.Decoder.unexpected_payload "Message(export_trace_partial_success), field(1)" pk + Pbrt.Decoder.unexpected_payload_message "export_trace_partial_success" 1 pk | Some (2, Pbrt.Bytes) -> begin export_trace_partial_success_set_error_message v (Pbrt.Decoder.string d); end | Some (2, pk) -> - Pbrt.Decoder.unexpected_payload "Message(export_trace_partial_success), field(2)" pk + Pbrt.Decoder.unexpected_payload_message "export_trace_partial_success" 2 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : export_trace_partial_success) @@ -198,7 +196,7 @@ let rec decode_pb_export_trace_service_response d = export_trace_service_response_set_partial_success v (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 + Pbrt.Decoder.unexpected_payload_message "export_trace_service_response" 1 pk | Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind done; (v : export_trace_service_response)