mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-10 04:35:46 -04:00
202 lines
7.8 KiB
OCaml
202 lines
7.8 KiB
OCaml
[@@@ocaml.warning "-23-27-30-39-44"]
|
|
|
|
type export_metrics_service_request = {
|
|
mutable resource_metrics : Metrics.resource_metrics list;
|
|
}
|
|
|
|
type export_metrics_partial_success = {
|
|
mutable _presence: Pbrt.Bitfield.t; (** presence for 2 fields *)
|
|
mutable rejected_data_points : int64;
|
|
mutable error_message : string;
|
|
}
|
|
|
|
type export_metrics_service_response = {
|
|
mutable partial_success : export_metrics_partial_success option;
|
|
}
|
|
|
|
let default_export_metrics_service_request (): export_metrics_service_request =
|
|
{
|
|
resource_metrics=[];
|
|
}
|
|
|
|
let default_export_metrics_partial_success (): export_metrics_partial_success =
|
|
{
|
|
_presence=Pbrt.Bitfield.empty;
|
|
rejected_data_points=0L;
|
|
error_message="";
|
|
}
|
|
|
|
let default_export_metrics_service_response (): export_metrics_service_response =
|
|
{
|
|
partial_success=None;
|
|
}
|
|
|
|
|
|
(** {2 Make functions} *)
|
|
|
|
|
|
let[@inline] export_metrics_service_request_set_resource_metrics (self:export_metrics_service_request) (x:Metrics.resource_metrics list) : unit =
|
|
self.resource_metrics <- x
|
|
|
|
let copy_export_metrics_service_request (self:export_metrics_service_request) : export_metrics_service_request =
|
|
{ self with resource_metrics = self.resource_metrics }
|
|
|
|
let make_export_metrics_service_request
|
|
?(resource_metrics=[])
|
|
() : export_metrics_service_request =
|
|
let _res = default_export_metrics_service_request () in
|
|
export_metrics_service_request_set_resource_metrics _res resource_metrics;
|
|
_res
|
|
|
|
let[@inline] export_metrics_partial_success_has_rejected_data_points (self:export_metrics_partial_success) : bool = (Pbrt.Bitfield.get self._presence 0)
|
|
let[@inline] export_metrics_partial_success_has_error_message (self:export_metrics_partial_success) : bool = (Pbrt.Bitfield.get self._presence 1)
|
|
|
|
let[@inline] export_metrics_partial_success_set_rejected_data_points (self:export_metrics_partial_success) (x:int64) : unit =
|
|
self._presence <- (Pbrt.Bitfield.set self._presence 0); self.rejected_data_points <- x
|
|
let[@inline] export_metrics_partial_success_set_error_message (self:export_metrics_partial_success) (x:string) : unit =
|
|
self._presence <- (Pbrt.Bitfield.set self._presence 1); self.error_message <- x
|
|
|
|
let copy_export_metrics_partial_success (self:export_metrics_partial_success) : export_metrics_partial_success =
|
|
{ self with rejected_data_points = self.rejected_data_points }
|
|
|
|
let make_export_metrics_partial_success
|
|
?(rejected_data_points:int64 option)
|
|
?(error_message:string option)
|
|
() : export_metrics_partial_success =
|
|
let _res = default_export_metrics_partial_success () in
|
|
(match rejected_data_points with
|
|
| None -> ()
|
|
| Some v -> export_metrics_partial_success_set_rejected_data_points _res v);
|
|
(match error_message with
|
|
| None -> ()
|
|
| Some v -> export_metrics_partial_success_set_error_message _res v);
|
|
_res
|
|
|
|
|
|
let[@inline] export_metrics_service_response_set_partial_success (self:export_metrics_service_response) (x:export_metrics_partial_success) : unit =
|
|
self.partial_success <- Some x
|
|
|
|
let copy_export_metrics_service_response (self:export_metrics_service_response) : export_metrics_service_response =
|
|
{ self with partial_success = self.partial_success }
|
|
|
|
let make_export_metrics_service_response
|
|
?(partial_success:export_metrics_partial_success option)
|
|
() : export_metrics_service_response =
|
|
let _res = default_export_metrics_service_response () in
|
|
(match partial_success with
|
|
| None -> ()
|
|
| Some v -> export_metrics_service_response_set_partial_success _res v);
|
|
_res
|
|
|
|
[@@@ocaml.warning "-23-27-30-39"]
|
|
|
|
(** {2 Formatters} *)
|
|
|
|
let rec pp_export_metrics_service_request fmt (v:export_metrics_service_request) =
|
|
let pp_i fmt () =
|
|
Pbrt.Pp.pp_record_field ~first:true "resource_metrics" (Pbrt.Pp.pp_list Metrics.pp_resource_metrics) fmt v.resource_metrics;
|
|
in
|
|
Pbrt.Pp.pp_brk pp_i fmt ()
|
|
|
|
let rec pp_export_metrics_partial_success fmt (v:export_metrics_partial_success) =
|
|
let pp_i fmt () =
|
|
Pbrt.Pp.pp_record_field ~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 ()
|
|
|
|
let rec pp_export_metrics_service_response fmt (v:export_metrics_service_response) =
|
|
let pp_i fmt () =
|
|
Pbrt.Pp.pp_record_field ~first:true "partial_success" (Pbrt.Pp.pp_option pp_export_metrics_partial_success) fmt v.partial_success;
|
|
in
|
|
Pbrt.Pp.pp_brk pp_i fmt ()
|
|
|
|
[@@@ocaml.warning "-23-27-30-39"]
|
|
|
|
(** {2 Protobuf Encoding} *)
|
|
|
|
let rec encode_pb_export_metrics_service_request (v:export_metrics_service_request) encoder =
|
|
Pbrt.List_util.rev_iter_with (fun x encoder ->
|
|
Pbrt.Encoder.nested Metrics.encode_pb_resource_metrics x encoder;
|
|
Pbrt.Encoder.key 1 Pbrt.Bytes encoder;
|
|
) v.resource_metrics encoder;
|
|
()
|
|
|
|
let rec encode_pb_export_metrics_partial_success (v:export_metrics_partial_success) encoder =
|
|
if export_metrics_partial_success_has_rejected_data_points v then (
|
|
Pbrt.Encoder.int64_as_varint v.rejected_data_points encoder;
|
|
Pbrt.Encoder.key 1 Pbrt.Varint encoder;
|
|
);
|
|
if export_metrics_partial_success_has_error_message v then (
|
|
Pbrt.Encoder.string v.error_message encoder;
|
|
Pbrt.Encoder.key 2 Pbrt.Bytes encoder;
|
|
);
|
|
()
|
|
|
|
let rec encode_pb_export_metrics_service_response (v:export_metrics_service_response) encoder =
|
|
begin match v.partial_success with
|
|
| Some x ->
|
|
Pbrt.Encoder.nested encode_pb_export_metrics_partial_success x encoder;
|
|
Pbrt.Encoder.key 1 Pbrt.Bytes encoder;
|
|
| None -> ();
|
|
end;
|
|
()
|
|
|
|
[@@@ocaml.warning "-23-27-30-39"]
|
|
|
|
(** {2 Protobuf Decoding} *)
|
|
|
|
let rec decode_pb_export_metrics_service_request d =
|
|
let v = default_export_metrics_service_request () in
|
|
let continue__= ref true in
|
|
while !continue__ do
|
|
match Pbrt.Decoder.key d with
|
|
| None -> (
|
|
(* put lists in the correct order *)
|
|
export_metrics_service_request_set_resource_metrics v (List.rev v.resource_metrics);
|
|
); continue__ := false
|
|
| Some (1, Pbrt.Bytes) -> begin
|
|
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" 1 pk
|
|
| Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind
|
|
done;
|
|
(v : export_metrics_service_request)
|
|
|
|
let rec decode_pb_export_metrics_partial_success d =
|
|
let v = default_export_metrics_partial_success () in
|
|
let continue__= ref true in
|
|
while !continue__ do
|
|
match Pbrt.Decoder.key d with
|
|
| None -> (
|
|
); continue__ := false
|
|
| Some (1, Pbrt.Varint) -> begin
|
|
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" 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" 2 pk
|
|
| Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind
|
|
done;
|
|
(v : export_metrics_partial_success)
|
|
|
|
let rec decode_pb_export_metrics_service_response d =
|
|
let v = default_export_metrics_service_response () in
|
|
let continue__= ref true in
|
|
while !continue__ do
|
|
match Pbrt.Decoder.key d with
|
|
| None -> (
|
|
); continue__ := false
|
|
| Some (1, Pbrt.Bytes) -> begin
|
|
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" 1 pk
|
|
| Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind
|
|
done;
|
|
(v : export_metrics_service_response)
|