mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-07 18:37:56 -05:00
Merge pull request #123 from ocaml-tracing/simon/http-retry
HTTP improvements: retry, json protocol, key renames
This commit is contained in:
commit
126e25b5a7
40 changed files with 2793 additions and 73 deletions
29
README.md
29
README.md
|
|
@ -78,12 +78,31 @@ let main () =
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
The library is configurable via `Opentelemetry.Config`, via the standard
|
### Environment Variables
|
||||||
opentelemetry env variables, or with some custom environment variables.
|
|
||||||
|
The library supports standard OpenTelemetry environment variables:
|
||||||
|
|
||||||
|
**General:**
|
||||||
|
- `OTEL_SDK_DISABLED` - disable the SDK (default: false)
|
||||||
|
- `OTEL_SERVICE_NAME` - service name
|
||||||
|
- `OTEL_RESOURCE_ATTRIBUTES` - comma-separated key=value resource attributes
|
||||||
|
- `OTEL_OCAML_DEBUG=1` - print debug messages from the opentelemetry library
|
||||||
|
|
||||||
|
**Exporter endpoints:**
|
||||||
|
- `OTEL_EXPORTER_OTLP_ENDPOINT` - base endpoint (default: http://localhost:4318)
|
||||||
|
- `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` - traces endpoint
|
||||||
|
- `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT` - metrics endpoint
|
||||||
|
- `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT` - logs endpoint
|
||||||
|
|
||||||
|
**Exporter configuration:**
|
||||||
|
- `OTEL_EXPORTER_OTLP_PROTOCOL` - protocol: http/protobuf or http/json (default: http/protobuf)
|
||||||
|
|
||||||
|
**Headers:**
|
||||||
|
- `OTEL_EXPORTER_OTLP_HEADERS` - headers as comma-separated key=value pairs
|
||||||
|
- `OTEL_EXPORTER_OTLP_TRACES_HEADERS` - traces-specific headers
|
||||||
|
- `OTEL_EXPORTER_OTLP_METRICS_HEADERS` - metrics-specific headers
|
||||||
|
- `OTEL_EXPORTER_OTLP_LOGS_HEADERS` - logs-specific headers
|
||||||
|
|
||||||
- `OTEL_EXPORTER_OTLP_ENDPOINT` sets the http endpoint to send signals to
|
|
||||||
- `OTEL_OCAML_DEBUG=1` to print some debug messages from the opentelemetry library ide
|
|
||||||
- `OTEL_RESOURCE_ATTRIBUTES` sets a comma separated list of custom resource attributes
|
|
||||||
|
|
||||||
## Collector opentelemetry-client-ocurl
|
## Collector opentelemetry-client-ocurl
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,10 @@
|
||||||
(and
|
(and
|
||||||
(>= 4.0)
|
(>= 4.0)
|
||||||
(< 5.0)))
|
(< 5.0)))
|
||||||
|
(pbrt_yojson
|
||||||
|
(and
|
||||||
|
(>= 4.0)
|
||||||
|
(< 5.0)))
|
||||||
(ambient-context
|
(ambient-context
|
||||||
(>= 0.2))
|
(>= 0.2))
|
||||||
(ocaml-lsp-server :with-dev-setup)
|
(ocaml-lsp-server :with-dev-setup)
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ depends: [
|
||||||
"odoc" {with-doc}
|
"odoc" {with-doc}
|
||||||
"alcotest" {with-test}
|
"alcotest" {with-test}
|
||||||
"pbrt" {>= "4.0" & < "5.0"}
|
"pbrt" {>= "4.0" & < "5.0"}
|
||||||
|
"pbrt_yojson" {>= "4.0" & < "5.0"}
|
||||||
"ambient-context" {>= "0.2"}
|
"ambient-context" {>= "0.2"}
|
||||||
"ocaml-lsp-server" {with-dev-setup}
|
"ocaml-lsp-server" {with-dev-setup}
|
||||||
"ocamlformat" {with-dev-setup & >= "0.27" & < "0.28"}
|
"ocamlformat" {with-dev-setup & >= "0.27" & < "0.28"}
|
||||||
|
|
|
||||||
|
|
@ -94,9 +94,6 @@ struct
|
||||||
|
|
||||||
let open Cohttp in
|
let open Cohttp in
|
||||||
let headers = Header.(add_list (init ()) user_headers) in
|
let headers = Header.(add_list (init ()) user_headers) in
|
||||||
let headers =
|
|
||||||
Header.(add headers "Content-Type" "application/x-protobuf")
|
|
||||||
in
|
|
||||||
|
|
||||||
let body = Cohttp_eio.Body.of_string body in
|
let body = Cohttp_eio.Body.of_string body in
|
||||||
let r =
|
let r =
|
||||||
|
|
|
||||||
|
|
@ -33,14 +33,6 @@ module Httpc : Generic_http_consumer.HTTPC with module IO = IO = struct
|
||||||
|
|
||||||
let open Cohttp in
|
let open Cohttp in
|
||||||
let headers = Header.(add_list (init ()) user_headers) in
|
let headers = Header.(add_list (init ()) user_headers) in
|
||||||
let headers =
|
|
||||||
Header.(
|
|
||||||
add_list headers
|
|
||||||
[
|
|
||||||
"Content-Type", "application/x-protobuf";
|
|
||||||
"Accept", "application/x-protobuf";
|
|
||||||
])
|
|
||||||
in
|
|
||||||
|
|
||||||
let body = Cohttp_lwt.Body.of_string bod in
|
let body = Cohttp_lwt.Body.of_string bod in
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,7 @@ module Httpc : Generic_http_consumer.HTTPC with module IO = IO = struct
|
||||||
let send (self : t) ~url ~headers:user_headers ~decode (bod : string) :
|
let send (self : t) ~url ~headers:user_headers ~decode (bod : string) :
|
||||||
('a, error) result Lwt.t =
|
('a, error) result Lwt.t =
|
||||||
let* r =
|
let* r =
|
||||||
let headers =
|
let headers = user_headers in
|
||||||
("Content-Type", "application/x-protobuf")
|
|
||||||
:: ("Accept", "application/x-protobuf")
|
|
||||||
:: user_headers
|
|
||||||
in
|
|
||||||
Ezcurl_lwt.post ~client:self ~headers ~params:[] ~url
|
Ezcurl_lwt.post ~client:self ~headers ~params:[] ~url
|
||||||
~content:(`String bod) ()
|
~content:(`String bod) ()
|
||||||
in
|
in
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,7 @@ module Httpc : OTELC.Generic_http_consumer.HTTPC with module IO = IO = struct
|
||||||
let send (self : t) ~url ~headers:user_headers ~decode (bod : string) :
|
let send (self : t) ~url ~headers:user_headers ~decode (bod : string) :
|
||||||
('a, error) result =
|
('a, error) result =
|
||||||
let r =
|
let r =
|
||||||
let headers =
|
let headers = user_headers in
|
||||||
("Content-Type", "application/x-protobuf")
|
|
||||||
:: ("Accept", "application/x-protobuf")
|
|
||||||
:: user_headers
|
|
||||||
in
|
|
||||||
Ezcurl.post ~client:self ~headers ~params:[] ~url ~content:(`String bod)
|
Ezcurl.post ~client:self ~headers ~params:[] ~url ~content:(`String bod)
|
||||||
()
|
()
|
||||||
in
|
in
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
mtime.clock.os
|
mtime.clock.os
|
||||||
unix
|
unix
|
||||||
pbrt
|
pbrt
|
||||||
|
yojson
|
||||||
threads.posix)
|
threads.posix)
|
||||||
(synopsis
|
(synopsis
|
||||||
"Basic exporters, as well as common types and logic shared between exporters"))
|
"Basic exporters, as well as common types and logic shared between exporters"))
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,10 @@ type t = {
|
||||||
batch_timeout_ms: int;
|
batch_timeout_ms: int;
|
||||||
self_trace: bool;
|
self_trace: bool;
|
||||||
http_concurrency_level: int option;
|
http_concurrency_level: int option;
|
||||||
|
retry_max_attempts: int;
|
||||||
|
retry_initial_delay_ms: float;
|
||||||
|
retry_max_delay_ms: float;
|
||||||
|
retry_backoff_multiplier: float;
|
||||||
_rest: rest;
|
_rest: rest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -82,6 +86,10 @@ let pp out (self : t) : unit =
|
||||||
batch_logs;
|
batch_logs;
|
||||||
batch_timeout_ms;
|
batch_timeout_ms;
|
||||||
http_concurrency_level;
|
http_concurrency_level;
|
||||||
|
retry_max_attempts;
|
||||||
|
retry_initial_delay_ms;
|
||||||
|
retry_max_delay_ms;
|
||||||
|
retry_backoff_multiplier;
|
||||||
_rest = _;
|
_rest = _;
|
||||||
} =
|
} =
|
||||||
self
|
self
|
||||||
|
|
@ -95,13 +103,16 @@ let pp out (self : t) : unit =
|
||||||
%a@];@ protocol=%a;@ timeout_ms=%d;@ timeout_traces_ms=%d;@ \
|
%a@];@ protocol=%a;@ timeout_ms=%d;@ timeout_traces_ms=%d;@ \
|
||||||
timeout_metrics_ms=%d;@ timeout_logs_ms=%d;@ batch_traces=%a;@ \
|
timeout_metrics_ms=%d;@ timeout_logs_ms=%d;@ batch_traces=%a;@ \
|
||||||
batch_metrics=%a;@ batch_logs=%a;@ batch_timeout_ms=%d;@ \
|
batch_metrics=%a;@ batch_logs=%a;@ batch_timeout_ms=%d;@ \
|
||||||
http_concurrency_level=%a @]}"
|
http_concurrency_level=%a;@ retry_max_attempts=%d;@ \
|
||||||
|
retry_initial_delay_ms=%.0f;@ retry_max_delay_ms=%.0f;@ \
|
||||||
|
retry_backoff_multiplier=%.1f @]}"
|
||||||
debug pp_log_level log_level sdk_disabled self_trace url_traces url_metrics
|
debug pp_log_level log_level sdk_disabled self_trace url_traces url_metrics
|
||||||
url_logs ppheaders headers ppheaders headers_traces ppheaders
|
url_logs ppheaders headers ppheaders headers_traces ppheaders
|
||||||
headers_metrics ppheaders headers_logs pp_protocol protocol timeout_ms
|
headers_metrics ppheaders headers_logs pp_protocol protocol timeout_ms
|
||||||
timeout_traces_ms timeout_metrics_ms timeout_logs_ms ppiopt batch_traces
|
timeout_traces_ms timeout_metrics_ms timeout_logs_ms ppiopt batch_traces
|
||||||
ppiopt batch_metrics ppiopt batch_logs batch_timeout_ms ppiopt
|
ppiopt batch_metrics ppiopt batch_logs batch_timeout_ms ppiopt
|
||||||
http_concurrency_level
|
http_concurrency_level retry_max_attempts retry_initial_delay_ms
|
||||||
|
retry_max_delay_ms retry_backoff_multiplier
|
||||||
|
|
||||||
let default_url = "http://localhost:4318"
|
let default_url = "http://localhost:4318"
|
||||||
|
|
||||||
|
|
@ -128,6 +139,10 @@ type 'k make =
|
||||||
?batch_timeout_ms:int ->
|
?batch_timeout_ms:int ->
|
||||||
?self_trace:bool ->
|
?self_trace:bool ->
|
||||||
?http_concurrency_level:int ->
|
?http_concurrency_level:int ->
|
||||||
|
?retry_max_attempts:int ->
|
||||||
|
?retry_initial_delay_ms:float ->
|
||||||
|
?retry_max_delay_ms:float ->
|
||||||
|
?retry_backoff_multiplier:float ->
|
||||||
'k
|
'k
|
||||||
|
|
||||||
module type ENV = sig
|
module type ENV = sig
|
||||||
|
|
@ -234,7 +249,8 @@ module Env () : ENV = struct
|
||||||
?(timeout_ms = get_timeout_from_env "OTEL_EXPORTER_OTLP_TIMEOUT" 10_000)
|
?(timeout_ms = get_timeout_from_env "OTEL_EXPORTER_OTLP_TIMEOUT" 10_000)
|
||||||
?timeout_traces_ms ?timeout_metrics_ms ?timeout_logs_ms
|
?timeout_traces_ms ?timeout_metrics_ms ?timeout_logs_ms
|
||||||
?(batch_timeout_ms = 2_000) ?(self_trace = false) ?http_concurrency_level
|
?(batch_timeout_ms = 2_000) ?(self_trace = false) ?http_concurrency_level
|
||||||
=
|
?(retry_max_attempts = 3) ?(retry_initial_delay_ms = 100.)
|
||||||
|
?(retry_max_delay_ms = 5000.) ?(retry_backoff_multiplier = 2.0) =
|
||||||
let url_traces, url_metrics, url_logs =
|
let url_traces, url_metrics, url_logs =
|
||||||
let base_url =
|
let base_url =
|
||||||
let base_url =
|
let base_url =
|
||||||
|
|
@ -333,6 +349,10 @@ module Env () : ENV = struct
|
||||||
batch_timeout_ms;
|
batch_timeout_ms;
|
||||||
self_trace;
|
self_trace;
|
||||||
http_concurrency_level;
|
http_concurrency_level;
|
||||||
|
retry_max_attempts;
|
||||||
|
retry_initial_delay_ms;
|
||||||
|
retry_max_delay_ms;
|
||||||
|
retry_backoff_multiplier;
|
||||||
_rest = ();
|
_rest = ();
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,15 @@ type t = {
|
||||||
be used to represent the size of a pool of workers where each worker
|
be used to represent the size of a pool of workers where each worker
|
||||||
gets a batch to send, send it, and repeats.
|
gets a batch to send, send it, and repeats.
|
||||||
@since NEXT_RELEASE *)
|
@since NEXT_RELEASE *)
|
||||||
|
retry_max_attempts: int;
|
||||||
|
(** Maximum number of retry attempts for failed exports. 0 means no retry,
|
||||||
|
1 means one retry after initial failure. Default 3. *)
|
||||||
|
retry_initial_delay_ms: float;
|
||||||
|
(** Initial delay in milliseconds before first retry. Default 100ms. *)
|
||||||
|
retry_max_delay_ms: float;
|
||||||
|
(** Maximum delay in milliseconds between retries. Default 5000ms. *)
|
||||||
|
retry_backoff_multiplier: float;
|
||||||
|
(** Multiplier for exponential backoff. Default 2.0. *)
|
||||||
_rest: rest;
|
_rest: rest;
|
||||||
}
|
}
|
||||||
(** Configuration.
|
(** Configuration.
|
||||||
|
|
@ -123,6 +132,10 @@ type 'k make =
|
||||||
?batch_timeout_ms:int ->
|
?batch_timeout_ms:int ->
|
||||||
?self_trace:bool ->
|
?self_trace:bool ->
|
||||||
?http_concurrency_level:int ->
|
?http_concurrency_level:int ->
|
||||||
|
?retry_max_attempts:int ->
|
||||||
|
?retry_initial_delay_ms:float ->
|
||||||
|
?retry_max_delay_ms:float ->
|
||||||
|
?retry_backoff_multiplier:float ->
|
||||||
'k
|
'k
|
||||||
(** A function that gathers all the values needed to construct a {!t}, and
|
(** A function that gathers all the values needed to construct a {!t}, and
|
||||||
produces a ['k]. ['k] is typically a continuation used to construct a
|
produces a ['k]. ['k] is typically a continuation used to construct a
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,31 @@ end = struct
|
||||||
|
|
||||||
let cleanup self = Httpc.cleanup self.http
|
let cleanup self = Httpc.cleanup self.http
|
||||||
|
|
||||||
|
(** Should we retry, based on the HTTP response code? *)
|
||||||
|
let should_retry = function
|
||||||
|
| `Failure _ -> true (* Network errors, connection issues *)
|
||||||
|
| `Status (code, _) ->
|
||||||
|
(* Retry on server errors, rate limits, timeouts *)
|
||||||
|
code >= 500 || code = 429 || code = 408
|
||||||
|
| `Sysbreak -> false (* User interrupt, don't retry *)
|
||||||
|
|
||||||
|
(** Retry loop over [f()] with exponential backoff *)
|
||||||
|
let rec retry_loop_ (self : t) attempt delay_ms ~f =
|
||||||
|
let open IO in
|
||||||
|
let* result = f () in
|
||||||
|
match result with
|
||||||
|
| Ok x -> return (Ok x)
|
||||||
|
| Error err
|
||||||
|
when should_retry err && attempt < self.config.retry_max_attempts ->
|
||||||
|
let delay_s = delay_ms /. 1000. in
|
||||||
|
let* () = sleep_s delay_s in
|
||||||
|
let next_delay =
|
||||||
|
min self.config.retry_max_delay_ms
|
||||||
|
(delay_ms *. self.config.retry_backoff_multiplier)
|
||||||
|
in
|
||||||
|
retry_loop_ self (attempt + 1) next_delay ~f
|
||||||
|
| Error _ as err -> return err
|
||||||
|
|
||||||
let send (self : t) (sigs : OTEL.Any_signal_l.t) : (unit, error) result IO.t
|
let send (self : t) (sigs : OTEL.Any_signal_l.t) : (unit, error) result IO.t
|
||||||
=
|
=
|
||||||
let res = Resource_signal.of_signal_l sigs in
|
let res = Resource_signal.of_signal_l sigs in
|
||||||
|
|
@ -76,9 +101,29 @@ end = struct
|
||||||
(fun (k, _) -> not (List.mem k signal_keys))
|
(fun (k, _) -> not (List.mem k signal_keys))
|
||||||
self.config.headers
|
self.config.headers
|
||||||
in
|
in
|
||||||
let headers = List.rev_append signal_headers filtered_general in
|
let content_type =
|
||||||
let data = Resource_signal.Encode.any ~encoder:self.encoder res in
|
match self.config.protocol with
|
||||||
Httpc.send self.http ~url ~headers ~decode:(`Ret ()) data
|
| Http_protobuf -> "application/x-protobuf"
|
||||||
|
| Http_json -> "application/json"
|
||||||
|
in
|
||||||
|
let headers =
|
||||||
|
("Content-Type", content_type)
|
||||||
|
:: ("Accept", content_type)
|
||||||
|
:: List.rev_append signal_headers filtered_general
|
||||||
|
in
|
||||||
|
let data =
|
||||||
|
Resource_signal.Encode.any ~encoder:self.encoder
|
||||||
|
~protocol:self.config.protocol res
|
||||||
|
in
|
||||||
|
|
||||||
|
let do_once () =
|
||||||
|
Httpc.send self.http ~url ~headers ~decode:(`Ret ()) data
|
||||||
|
in
|
||||||
|
|
||||||
|
if self.config.retry_max_attempts > 0 then
|
||||||
|
retry_loop_ self 0 self.config.retry_initial_delay_ms ~f:do_once
|
||||||
|
else
|
||||||
|
do_once ()
|
||||||
end
|
end
|
||||||
|
|
||||||
module C = Generic_consumer.Make (IO) (Notifier) (Sender)
|
module C = Generic_consumer.Make (IO) (Notifier) (Sender)
|
||||||
|
|
|
||||||
|
|
@ -65,8 +65,12 @@ let of_signal_l ?service_name ?attrs (s : OTEL.Any_signal_l.t) : t =
|
||||||
| Spans sp -> of_spans ?service_name ?attrs sp
|
| Spans sp -> of_spans ?service_name ?attrs sp
|
||||||
| Metrics ms -> of_metrics ?service_name ?attrs ms
|
| Metrics ms -> of_metrics ?service_name ?attrs ms
|
||||||
|
|
||||||
|
type protocol = Exporter_config.protocol =
|
||||||
|
| Http_protobuf
|
||||||
|
| Http_json
|
||||||
|
|
||||||
module Encode = struct
|
module Encode = struct
|
||||||
let resource_to_string ~encoder ~ctor ~enc resource : string =
|
let resource_to_pb_string ~encoder ~ctor ~enc resource : string =
|
||||||
let encoder =
|
let encoder =
|
||||||
match encoder with
|
match encoder with
|
||||||
| Some e ->
|
| Some e ->
|
||||||
|
|
@ -85,33 +89,77 @@ module Encode = struct
|
||||||
Pbrt.Encoder.reset encoder;
|
Pbrt.Encoder.reset encoder;
|
||||||
data
|
data
|
||||||
in
|
in
|
||||||
|
|
||||||
data
|
data
|
||||||
|
|
||||||
let logs ?encoder resource_logs =
|
let resource_to_json_string ~ctor ~enc resource : string =
|
||||||
resource_to_string ~encoder resource_logs
|
let x = ctor resource in
|
||||||
|
let data =
|
||||||
|
let@ _sc = Self_trace.with_ ~kind:Span.Span_kind_internal "encode-json" in
|
||||||
|
let json = enc x in
|
||||||
|
let data = Yojson.Basic.to_string json in
|
||||||
|
Span.add_attrs _sc [ "size", `Int (String.length data) ];
|
||||||
|
data
|
||||||
|
in
|
||||||
|
data
|
||||||
|
|
||||||
|
let logs_pb ?encoder resource_logs =
|
||||||
|
resource_to_pb_string ~encoder resource_logs
|
||||||
~ctor:(fun r ->
|
~ctor:(fun r ->
|
||||||
Logs_service.make_export_logs_service_request ~resource_logs:r ())
|
Logs_service.make_export_logs_service_request ~resource_logs:r ())
|
||||||
~enc:Logs_service.encode_pb_export_logs_service_request
|
~enc:Logs_service.encode_pb_export_logs_service_request
|
||||||
|
|
||||||
let metrics ?encoder resource_metrics =
|
let logs_json resource_logs =
|
||||||
resource_to_string ~encoder resource_metrics
|
resource_to_json_string resource_logs
|
||||||
|
~ctor:(fun r ->
|
||||||
|
Logs_service.make_export_logs_service_request ~resource_logs:r ())
|
||||||
|
~enc:Logs_service.encode_json_export_logs_service_request
|
||||||
|
|
||||||
|
let metrics_pb ?encoder resource_metrics =
|
||||||
|
resource_to_pb_string ~encoder resource_metrics
|
||||||
~ctor:(fun r ->
|
~ctor:(fun r ->
|
||||||
Metrics_service.make_export_metrics_service_request ~resource_metrics:r
|
Metrics_service.make_export_metrics_service_request ~resource_metrics:r
|
||||||
())
|
())
|
||||||
~enc:Metrics_service.encode_pb_export_metrics_service_request
|
~enc:Metrics_service.encode_pb_export_metrics_service_request
|
||||||
|
|
||||||
let traces ?encoder resource_spans =
|
let metrics_json resource_metrics =
|
||||||
resource_to_string ~encoder resource_spans
|
resource_to_json_string resource_metrics
|
||||||
|
~ctor:(fun r ->
|
||||||
|
Metrics_service.make_export_metrics_service_request ~resource_metrics:r
|
||||||
|
())
|
||||||
|
~enc:Metrics_service.encode_json_export_metrics_service_request
|
||||||
|
|
||||||
|
let traces_pb ?encoder resource_spans =
|
||||||
|
resource_to_pb_string ~encoder resource_spans
|
||||||
~ctor:(fun r ->
|
~ctor:(fun r ->
|
||||||
Trace_service.make_export_trace_service_request ~resource_spans:r ())
|
Trace_service.make_export_trace_service_request ~resource_spans:r ())
|
||||||
~enc:Trace_service.encode_pb_export_trace_service_request
|
~enc:Trace_service.encode_pb_export_trace_service_request
|
||||||
|
|
||||||
let any ?encoder (r : t) : string =
|
let traces_json resource_spans =
|
||||||
|
resource_to_json_string resource_spans
|
||||||
|
~ctor:(fun r ->
|
||||||
|
Trace_service.make_export_trace_service_request ~resource_spans:r ())
|
||||||
|
~enc:Trace_service.encode_json_export_trace_service_request
|
||||||
|
|
||||||
|
let logs ?encoder ?(protocol = Http_protobuf) resource_logs =
|
||||||
|
match protocol with
|
||||||
|
| Http_protobuf -> logs_pb ?encoder resource_logs
|
||||||
|
| Http_json -> logs_json resource_logs
|
||||||
|
|
||||||
|
let metrics ?encoder ?(protocol = Http_protobuf) resource_metrics =
|
||||||
|
match protocol with
|
||||||
|
| Http_protobuf -> metrics_pb ?encoder resource_metrics
|
||||||
|
| Http_json -> metrics_json resource_metrics
|
||||||
|
|
||||||
|
let traces ?encoder ?(protocol = Http_protobuf) resource_spans =
|
||||||
|
match protocol with
|
||||||
|
| Http_protobuf -> traces_pb ?encoder resource_spans
|
||||||
|
| Http_json -> traces_json resource_spans
|
||||||
|
|
||||||
|
let any ?encoder ?(protocol = Http_protobuf) (r : t) : string =
|
||||||
match r with
|
match r with
|
||||||
| Logs l -> logs ?encoder l
|
| Logs l -> logs ?encoder ~protocol l
|
||||||
| Traces sp -> traces ?encoder sp
|
| Traces sp -> traces ?encoder ~protocol sp
|
||||||
| Metrics ms -> metrics ?encoder ms
|
| Metrics ms -> metrics ?encoder ~protocol ms
|
||||||
end
|
end
|
||||||
|
|
||||||
module Decode = struct
|
module Decode = struct
|
||||||
|
|
|
||||||
|
|
@ -67,33 +67,44 @@ val is_metrics : t -> bool
|
||||||
|
|
||||||
val is_logs : t -> bool
|
val is_logs : t -> bool
|
||||||
|
|
||||||
(** Encode signals to protobuf encoded strings, ready to be sent over the wire
|
type protocol = Exporter_config.protocol =
|
||||||
*)
|
| Http_protobuf
|
||||||
|
| Http_json
|
||||||
|
|
||||||
|
(** Encode signals to protobuf or JSON encoded strings, ready to be sent over
|
||||||
|
the wire *)
|
||||||
module Encode : sig
|
module Encode : sig
|
||||||
val logs :
|
val logs :
|
||||||
?encoder:Pbrt.Encoder.t ->
|
?encoder:Pbrt.Encoder.t ->
|
||||||
|
?protocol:protocol ->
|
||||||
Opentelemetry_proto.Logs.resource_logs list ->
|
Opentelemetry_proto.Logs.resource_logs list ->
|
||||||
string
|
string
|
||||||
(** [logs ls] is a protobuf encoded string of the logs [ls]
|
(** [logs ls] is an encoded string of the logs [ls].
|
||||||
|
|
||||||
@param encoder provide an encoder state to reuse *)
|
@param encoder provide an encoder state to reuse (protobuf only)
|
||||||
|
@param protocol encoding protocol to use (default: Http_protobuf) *)
|
||||||
|
|
||||||
val metrics :
|
val metrics :
|
||||||
?encoder:Pbrt.Encoder.t ->
|
?encoder:Pbrt.Encoder.t ->
|
||||||
|
?protocol:protocol ->
|
||||||
Opentelemetry_proto.Metrics.resource_metrics list ->
|
Opentelemetry_proto.Metrics.resource_metrics list ->
|
||||||
string
|
string
|
||||||
(** [metrics ms] is a protobuf encoded string of the metrics [ms]
|
(** [metrics ms] is an encoded string of the metrics [ms].
|
||||||
@param encoder provide an encoder state to reuse *)
|
|
||||||
|
@param encoder provide an encoder state to reuse (protobuf only)
|
||||||
|
@param protocol encoding protocol to use (default: Http_protobuf) *)
|
||||||
|
|
||||||
val traces :
|
val traces :
|
||||||
?encoder:Pbrt.Encoder.t ->
|
?encoder:Pbrt.Encoder.t ->
|
||||||
|
?protocol:protocol ->
|
||||||
Opentelemetry_proto.Trace.resource_spans list ->
|
Opentelemetry_proto.Trace.resource_spans list ->
|
||||||
string
|
string
|
||||||
(** [traces ts] is a protobuf encoded string of the traces [ts]
|
(** [traces ts] is an encoded string of the traces [ts].
|
||||||
|
|
||||||
@param encoder provide an encoder state to reuse *)
|
@param encoder provide an encoder state to reuse (protobuf only)
|
||||||
|
@param protocol encoding protocol to use (default: Http_protobuf) *)
|
||||||
|
|
||||||
val any : ?encoder:Pbrt.Encoder.t -> t -> string
|
val any : ?encoder:Pbrt.Encoder.t -> ?protocol:protocol -> t -> string
|
||||||
end
|
end
|
||||||
|
|
||||||
(** Decode signals from protobuf encoded strings, received over the wire *)
|
(** Decode signals from protobuf encoded strings, received over the wire *)
|
||||||
|
|
|
||||||
|
|
@ -144,4 +144,4 @@ let set_status = span_set_status
|
||||||
|
|
||||||
let set_kind = span_set_kind
|
let set_kind = span_set_kind
|
||||||
|
|
||||||
let k_context : t Context.key = Context.new_key ()
|
let k_ambient : t Context.key = Context.new_key ()
|
||||||
|
|
|
||||||
|
|
@ -124,4 +124,6 @@ val default_kind : Span_kind.t ref
|
||||||
set to "internal", following directions from the [.proto] file. It can be
|
set to "internal", following directions from the [.proto] file. It can be
|
||||||
convenient to set "client" or "server" uniformly in here. *)
|
convenient to set "client" or "server" uniformly in here. *)
|
||||||
|
|
||||||
val k_context : t Context.key
|
val k_ambient : t Context.key
|
||||||
|
(** Context key to carry around a {!Span.t} in ambient context.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
|
||||||
|
|
@ -88,4 +88,4 @@ let of_w3c_trace_context_exn bs =
|
||||||
| Ok t -> t
|
| Ok t -> t
|
||||||
| Error msg -> invalid_arg @@ spf "invalid w3c trace context: %s" msg
|
| Error msg -> invalid_arg @@ spf "invalid w3c trace context: %s" msg
|
||||||
|
|
||||||
let k_span_ctx : t Hmap.key = Hmap.Key.create ()
|
let k_ambient : t Hmap.key = Hmap.Key.create ()
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ val of_w3c_trace_context : bytes -> (t, string) result
|
||||||
val of_w3c_trace_context_exn : bytes -> t
|
val of_w3c_trace_context_exn : bytes -> t
|
||||||
(** @raise Invalid_argument if parsing failed *)
|
(** @raise Invalid_argument if parsing failed *)
|
||||||
|
|
||||||
val k_span_ctx : t Hmap.key
|
val k_ambient : t Hmap.key
|
||||||
(** Hmap key to carry around a {!Span_ctx.t}, e.g. to remember what the current
|
(** Hmap key to carry around a {!Span_ctx.t}, e.g. to remember what the current
|
||||||
parent span is.
|
parent span is.
|
||||||
@since 0.8 *)
|
@since 0.8 *)
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
(** Find current span from ambient-context *)
|
(** Find current span from ambient-context *)
|
||||||
let[@inline] get () : Span.t option =
|
let[@inline] get () : Span.t option =
|
||||||
Opentelemetry_ambient_context.get Span.k_context
|
Opentelemetry_ambient_context.get Span.k_ambient
|
||||||
|
|
||||||
(** [with_ambient span f] runs [f()] with the current ambient span being set to
|
(** [with_ambient span f] runs [f()] with the current ambient span being set to
|
||||||
[span] *)
|
[span] *)
|
||||||
let[@inline] with_ambient (span : Span.t) (f : unit -> 'a) : 'a =
|
let[@inline] with_ambient (span : Span.t) (f : unit -> 'a) : 'a =
|
||||||
Opentelemetry_ambient_context.with_key_bound_to Span.k_context span (fun _ ->
|
Opentelemetry_ambient_context.with_key_bound_to Span.k_ambient span (fun _ ->
|
||||||
f ())
|
f ())
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ let k_trace_id = Trace_id.k_trace_id
|
||||||
module Span_id = Span_id
|
module Span_id = Span_id
|
||||||
module Span_ctx = Span_ctx
|
module Span_ctx = Span_ctx
|
||||||
|
|
||||||
let k_span_ctx = Span_ctx.k_span_ctx
|
let k_ambient = Span_ctx.k_ambient
|
||||||
|
|
||||||
(** {2 Attributes and conventions} *)
|
(** {2 Attributes and conventions} *)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -489,3 +489,228 @@ let rec decode_pb_entity_ref d =
|
||||||
| Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind
|
| Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind
|
||||||
done;
|
done;
|
||||||
(v : entity_ref)
|
(v : entity_ref)
|
||||||
|
|
||||||
|
[@@@ocaml.warning "-23-27-30-39"]
|
||||||
|
|
||||||
|
(** {2 Protobuf YoJson Encoding} *)
|
||||||
|
|
||||||
|
let rec encode_json_any_value (v:any_value) =
|
||||||
|
begin match v with
|
||||||
|
| String_value v -> `Assoc [("stringValue", Pbrt_yojson.make_string v)]
|
||||||
|
| Bool_value v -> `Assoc [("boolValue", Pbrt_yojson.make_bool v)]
|
||||||
|
| Int_value v -> `Assoc [("intValue", Pbrt_yojson.make_string (Int64.to_string v))]
|
||||||
|
| Double_value v -> `Assoc [("doubleValue", Pbrt_yojson.make_string (string_of_float v))]
|
||||||
|
| Array_value v -> `Assoc [("arrayValue", encode_json_array_value v)]
|
||||||
|
| Kvlist_value v -> `Assoc [("kvlistValue", encode_json_key_value_list v)]
|
||||||
|
| Bytes_value v -> `Assoc [("bytesValue", Pbrt_yojson.make_bytes v)]
|
||||||
|
end
|
||||||
|
|
||||||
|
and encode_json_array_value (v:array_value) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
assoc := (
|
||||||
|
let l = v.values |> List.map encode_json_any_value in
|
||||||
|
("values", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
and encode_json_key_value_list (v:key_value_list) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
assoc := (
|
||||||
|
let l = v.values |> List.map encode_json_key_value in
|
||||||
|
("values", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
and encode_json_key_value (v:key_value) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
if key_value_has_key v then (
|
||||||
|
assoc := ("key", Pbrt_yojson.make_string v.key) :: !assoc;
|
||||||
|
);
|
||||||
|
assoc := (match v.value with
|
||||||
|
| None -> !assoc
|
||||||
|
| Some v -> ("value", encode_json_any_value v) :: !assoc);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_instrumentation_scope (v:instrumentation_scope) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
if instrumentation_scope_has_name v then (
|
||||||
|
assoc := ("name", Pbrt_yojson.make_string v.name) :: !assoc;
|
||||||
|
);
|
||||||
|
if instrumentation_scope_has_version v then (
|
||||||
|
assoc := ("version", Pbrt_yojson.make_string v.version) :: !assoc;
|
||||||
|
);
|
||||||
|
assoc := (
|
||||||
|
let l = v.attributes |> List.map encode_json_key_value in
|
||||||
|
("attributes", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
if instrumentation_scope_has_dropped_attributes_count v then (
|
||||||
|
assoc := ("droppedAttributesCount", Pbrt_yojson.make_int (Int32.to_int v.dropped_attributes_count)) :: !assoc;
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_entity_ref (v:entity_ref) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
if entity_ref_has_schema_url v then (
|
||||||
|
assoc := ("schemaUrl", Pbrt_yojson.make_string v.schema_url) :: !assoc;
|
||||||
|
);
|
||||||
|
if entity_ref_has_type_ v then (
|
||||||
|
assoc := ("type", Pbrt_yojson.make_string v.type_) :: !assoc;
|
||||||
|
);
|
||||||
|
assoc := (
|
||||||
|
let l = v.id_keys |> List.map Pbrt_yojson.make_string in
|
||||||
|
("idKeys", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
assoc := (
|
||||||
|
let l = v.description_keys |> List.map Pbrt_yojson.make_string in
|
||||||
|
("descriptionKeys", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
[@@@ocaml.warning "-23-27-30-39"]
|
||||||
|
|
||||||
|
(** {2 JSON Decoding} *)
|
||||||
|
|
||||||
|
let rec decode_json_any_value json =
|
||||||
|
let assoc = match json with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
let rec loop = function
|
||||||
|
| [] -> Pbrt_yojson.E.malformed_variant "any_value"
|
||||||
|
| ("stringValue", json_value)::_ ->
|
||||||
|
(String_value (Pbrt_yojson.string json_value "any_value" "String_value") : any_value)
|
||||||
|
| ("boolValue", json_value)::_ ->
|
||||||
|
(Bool_value (Pbrt_yojson.bool json_value "any_value" "Bool_value") : any_value)
|
||||||
|
| ("intValue", json_value)::_ ->
|
||||||
|
(Int_value (Pbrt_yojson.int64 json_value "any_value" "Int_value") : any_value)
|
||||||
|
| ("doubleValue", json_value)::_ ->
|
||||||
|
(Double_value (Pbrt_yojson.float json_value "any_value" "Double_value") : any_value)
|
||||||
|
| ("arrayValue", json_value)::_ ->
|
||||||
|
(Array_value ((decode_json_array_value json_value)) : any_value)
|
||||||
|
| ("kvlistValue", json_value)::_ ->
|
||||||
|
(Kvlist_value ((decode_json_key_value_list json_value)) : any_value)
|
||||||
|
| ("bytesValue", json_value)::_ ->
|
||||||
|
(Bytes_value (Pbrt_yojson.bytes json_value "any_value" "Bytes_value") : any_value)
|
||||||
|
|
||||||
|
| _ :: tl -> loop tl
|
||||||
|
in
|
||||||
|
loop assoc
|
||||||
|
|
||||||
|
and decode_json_array_value d =
|
||||||
|
let v = default_array_value () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("values", `List l) -> begin
|
||||||
|
array_value_set_values v @@ List.map (function
|
||||||
|
| json_value -> (decode_json_any_value json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
values = v.values;
|
||||||
|
} : array_value)
|
||||||
|
|
||||||
|
and decode_json_key_value_list d =
|
||||||
|
let v = default_key_value_list () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("values", `List l) -> begin
|
||||||
|
key_value_list_set_values v @@ List.map (function
|
||||||
|
| json_value -> (decode_json_key_value json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
values = v.values;
|
||||||
|
} : key_value_list)
|
||||||
|
|
||||||
|
and decode_json_key_value d =
|
||||||
|
let v = default_key_value () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("key", json_value) ->
|
||||||
|
key_value_set_key v (Pbrt_yojson.string json_value "key_value" "key")
|
||||||
|
| ("value", json_value) ->
|
||||||
|
key_value_set_value v (decode_json_any_value json_value)
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
_presence = v._presence;
|
||||||
|
key = v.key;
|
||||||
|
value = v.value;
|
||||||
|
} : key_value)
|
||||||
|
|
||||||
|
let rec decode_json_instrumentation_scope d =
|
||||||
|
let v = default_instrumentation_scope () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("name", json_value) ->
|
||||||
|
instrumentation_scope_set_name v (Pbrt_yojson.string json_value "instrumentation_scope" "name")
|
||||||
|
| ("version", json_value) ->
|
||||||
|
instrumentation_scope_set_version v (Pbrt_yojson.string json_value "instrumentation_scope" "version")
|
||||||
|
| ("attributes", `List l) -> begin
|
||||||
|
instrumentation_scope_set_attributes v @@ List.map (function
|
||||||
|
| json_value -> (decode_json_key_value json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
| ("droppedAttributesCount", json_value) ->
|
||||||
|
instrumentation_scope_set_dropped_attributes_count v (Pbrt_yojson.int32 json_value "instrumentation_scope" "dropped_attributes_count")
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
_presence = v._presence;
|
||||||
|
name = v.name;
|
||||||
|
version = v.version;
|
||||||
|
attributes = v.attributes;
|
||||||
|
dropped_attributes_count = v.dropped_attributes_count;
|
||||||
|
} : instrumentation_scope)
|
||||||
|
|
||||||
|
let rec decode_json_entity_ref d =
|
||||||
|
let v = default_entity_ref () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("schemaUrl", json_value) ->
|
||||||
|
entity_ref_set_schema_url v (Pbrt_yojson.string json_value "entity_ref" "schema_url")
|
||||||
|
| ("type", json_value) ->
|
||||||
|
entity_ref_set_type_ v (Pbrt_yojson.string json_value "entity_ref" "type_")
|
||||||
|
| ("idKeys", `List l) -> begin
|
||||||
|
entity_ref_set_id_keys v @@ List.map (function
|
||||||
|
| json_value -> Pbrt_yojson.string json_value "entity_ref" "id_keys"
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
| ("descriptionKeys", `List l) -> begin
|
||||||
|
entity_ref_set_description_keys v @@ List.map (function
|
||||||
|
| json_value -> Pbrt_yojson.string json_value "entity_ref" "description_keys"
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
_presence = v._presence;
|
||||||
|
schema_url = v.schema_url;
|
||||||
|
type_ = v.type_;
|
||||||
|
id_keys = v.id_keys;
|
||||||
|
description_keys = v.description_keys;
|
||||||
|
} : entity_ref)
|
||||||
|
|
|
||||||
|
|
@ -233,3 +233,45 @@ val decode_pb_instrumentation_scope : Pbrt.Decoder.t -> instrumentation_scope
|
||||||
|
|
||||||
val decode_pb_entity_ref : Pbrt.Decoder.t -> entity_ref
|
val decode_pb_entity_ref : Pbrt.Decoder.t -> entity_ref
|
||||||
(** [decode_pb_entity_ref decoder] decodes a [entity_ref] binary value from [decoder] *)
|
(** [decode_pb_entity_ref decoder] decodes a [entity_ref] binary value from [decoder] *)
|
||||||
|
|
||||||
|
|
||||||
|
(** {2 Protobuf YoJson Encoding} *)
|
||||||
|
|
||||||
|
val encode_json_any_value : any_value -> Yojson.Basic.t
|
||||||
|
(** [encode_json_any_value v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_array_value : array_value -> Yojson.Basic.t
|
||||||
|
(** [encode_json_array_value v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_key_value_list : key_value_list -> Yojson.Basic.t
|
||||||
|
(** [encode_json_key_value_list v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_key_value : key_value -> Yojson.Basic.t
|
||||||
|
(** [encode_json_key_value v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_instrumentation_scope : instrumentation_scope -> Yojson.Basic.t
|
||||||
|
(** [encode_json_instrumentation_scope v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_entity_ref : entity_ref -> Yojson.Basic.t
|
||||||
|
(** [encode_json_entity_ref v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
|
||||||
|
(** {2 JSON Decoding} *)
|
||||||
|
|
||||||
|
val decode_json_any_value : Yojson.Basic.t -> any_value
|
||||||
|
(** [decode_json_any_value decoder] decodes a [any_value] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_array_value : Yojson.Basic.t -> array_value
|
||||||
|
(** [decode_json_array_value decoder] decodes a [array_value] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_key_value_list : Yojson.Basic.t -> key_value_list
|
||||||
|
(** [decode_json_key_value_list decoder] decodes a [key_value_list] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_key_value : Yojson.Basic.t -> key_value
|
||||||
|
(** [decode_json_key_value decoder] decodes a [key_value] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_instrumentation_scope : Yojson.Basic.t -> instrumentation_scope
|
||||||
|
(** [decode_json_instrumentation_scope decoder] decodes a [instrumentation_scope] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_entity_ref : Yojson.Basic.t -> entity_ref
|
||||||
|
(** [decode_json_entity_ref decoder] decodes a [entity_ref] value from [decoder] *)
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
(public_name opentelemetry.proto)
|
(public_name opentelemetry.proto)
|
||||||
(synopsis "Protobuf generated code for opentelemetry")
|
(synopsis "Protobuf generated code for opentelemetry")
|
||||||
(flags :standard -warn-error -a+8)
|
(flags :standard -warn-error -a+8)
|
||||||
(libraries pbrt))
|
(libraries pbrt pbrt_yojson))
|
||||||
|
|
||||||
; ### protobuf rules ###
|
; ### protobuf rules ###
|
||||||
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
(:file status.proto)
|
(:file status.proto)
|
||||||
(source_tree %{project_root}/vendor/opentelemetry-proto/))
|
(source_tree %{project_root}/vendor/opentelemetry-proto/))
|
||||||
(action
|
(action
|
||||||
(run ocaml-protoc %{file} --ml_out . --pp --make --binary)))
|
(run ocaml-protoc %{file} --ml_out . --pp --make --binary --yojson)))
|
||||||
|
|
||||||
(rule
|
(rule
|
||||||
(alias lint)
|
(alias lint)
|
||||||
|
|
@ -37,7 +37,8 @@
|
||||||
.
|
.
|
||||||
--pp
|
--pp
|
||||||
--make
|
--make
|
||||||
--binary)))
|
--binary
|
||||||
|
--yojson)))
|
||||||
|
|
||||||
(rule
|
(rule
|
||||||
(alias lint)
|
(alias lint)
|
||||||
|
|
@ -58,7 +59,8 @@
|
||||||
.
|
.
|
||||||
--pp
|
--pp
|
||||||
--make
|
--make
|
||||||
--binary)))
|
--binary
|
||||||
|
--yojson)))
|
||||||
|
|
||||||
(rule
|
(rule
|
||||||
(alias lint)
|
(alias lint)
|
||||||
|
|
@ -79,7 +81,8 @@
|
||||||
.
|
.
|
||||||
--pp
|
--pp
|
||||||
--make
|
--make
|
||||||
--binary)))
|
--binary
|
||||||
|
--yojson)))
|
||||||
|
|
||||||
(rule
|
(rule
|
||||||
(alias lint)
|
(alias lint)
|
||||||
|
|
@ -100,7 +103,8 @@
|
||||||
.
|
.
|
||||||
--pp
|
--pp
|
||||||
--make
|
--make
|
||||||
--binary)))
|
--binary
|
||||||
|
--yojson)))
|
||||||
|
|
||||||
(rule
|
(rule
|
||||||
(alias lint)
|
(alias lint)
|
||||||
|
|
@ -121,7 +125,8 @@
|
||||||
.
|
.
|
||||||
--pp
|
--pp
|
||||||
--make
|
--make
|
||||||
--binary)))
|
--binary
|
||||||
|
--yojson)))
|
||||||
|
|
||||||
(rule
|
(rule
|
||||||
(alias lint)
|
(alias lint)
|
||||||
|
|
@ -142,7 +147,8 @@
|
||||||
.
|
.
|
||||||
--pp
|
--pp
|
||||||
--make
|
--make
|
||||||
--binary)))
|
--binary
|
||||||
|
--yojson)))
|
||||||
|
|
||||||
(rule
|
(rule
|
||||||
(alias lint)
|
(alias lint)
|
||||||
|
|
@ -163,7 +169,8 @@
|
||||||
.
|
.
|
||||||
--pp
|
--pp
|
||||||
--make
|
--make
|
||||||
--binary)))
|
--binary
|
||||||
|
--yojson)))
|
||||||
|
|
||||||
(rule
|
(rule
|
||||||
(alias lint)
|
(alias lint)
|
||||||
|
|
@ -184,4 +191,5 @@
|
||||||
.
|
.
|
||||||
--pp
|
--pp
|
||||||
--make
|
--make
|
||||||
--binary)))
|
--binary
|
||||||
|
--yojson)))
|
||||||
|
|
|
||||||
|
|
@ -641,3 +641,274 @@ let rec decode_pb_log_record_flags d : log_record_flags =
|
||||||
| 0 -> Log_record_flags_do_not_use
|
| 0 -> Log_record_flags_do_not_use
|
||||||
| 255 -> Log_record_flags_trace_flags_mask
|
| 255 -> Log_record_flags_trace_flags_mask
|
||||||
| _ -> Pbrt.Decoder.malformed_variant "log_record_flags"
|
| _ -> Pbrt.Decoder.malformed_variant "log_record_flags"
|
||||||
|
|
||||||
|
[@@@ocaml.warning "-23-27-30-39"]
|
||||||
|
|
||||||
|
(** {2 Protobuf YoJson Encoding} *)
|
||||||
|
|
||||||
|
let rec encode_json_severity_number (v:severity_number) =
|
||||||
|
match v with
|
||||||
|
| Severity_number_unspecified -> `String "SEVERITY_NUMBER_UNSPECIFIED"
|
||||||
|
| Severity_number_trace -> `String "SEVERITY_NUMBER_TRACE"
|
||||||
|
| Severity_number_trace2 -> `String "SEVERITY_NUMBER_TRACE2"
|
||||||
|
| Severity_number_trace3 -> `String "SEVERITY_NUMBER_TRACE3"
|
||||||
|
| Severity_number_trace4 -> `String "SEVERITY_NUMBER_TRACE4"
|
||||||
|
| Severity_number_debug -> `String "SEVERITY_NUMBER_DEBUG"
|
||||||
|
| Severity_number_debug2 -> `String "SEVERITY_NUMBER_DEBUG2"
|
||||||
|
| Severity_number_debug3 -> `String "SEVERITY_NUMBER_DEBUG3"
|
||||||
|
| Severity_number_debug4 -> `String "SEVERITY_NUMBER_DEBUG4"
|
||||||
|
| Severity_number_info -> `String "SEVERITY_NUMBER_INFO"
|
||||||
|
| Severity_number_info2 -> `String "SEVERITY_NUMBER_INFO2"
|
||||||
|
| Severity_number_info3 -> `String "SEVERITY_NUMBER_INFO3"
|
||||||
|
| Severity_number_info4 -> `String "SEVERITY_NUMBER_INFO4"
|
||||||
|
| Severity_number_warn -> `String "SEVERITY_NUMBER_WARN"
|
||||||
|
| Severity_number_warn2 -> `String "SEVERITY_NUMBER_WARN2"
|
||||||
|
| Severity_number_warn3 -> `String "SEVERITY_NUMBER_WARN3"
|
||||||
|
| Severity_number_warn4 -> `String "SEVERITY_NUMBER_WARN4"
|
||||||
|
| Severity_number_error -> `String "SEVERITY_NUMBER_ERROR"
|
||||||
|
| Severity_number_error2 -> `String "SEVERITY_NUMBER_ERROR2"
|
||||||
|
| Severity_number_error3 -> `String "SEVERITY_NUMBER_ERROR3"
|
||||||
|
| Severity_number_error4 -> `String "SEVERITY_NUMBER_ERROR4"
|
||||||
|
| Severity_number_fatal -> `String "SEVERITY_NUMBER_FATAL"
|
||||||
|
| Severity_number_fatal2 -> `String "SEVERITY_NUMBER_FATAL2"
|
||||||
|
| Severity_number_fatal3 -> `String "SEVERITY_NUMBER_FATAL3"
|
||||||
|
| Severity_number_fatal4 -> `String "SEVERITY_NUMBER_FATAL4"
|
||||||
|
|
||||||
|
let rec encode_json_log_record (v:log_record) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
if log_record_has_time_unix_nano v then (
|
||||||
|
assoc := ("timeUnixNano", Pbrt_yojson.make_string (Int64.to_string v.time_unix_nano)) :: !assoc;
|
||||||
|
);
|
||||||
|
if log_record_has_observed_time_unix_nano v then (
|
||||||
|
assoc := ("observedTimeUnixNano", Pbrt_yojson.make_string (Int64.to_string v.observed_time_unix_nano)) :: !assoc;
|
||||||
|
);
|
||||||
|
if log_record_has_severity_number v then (
|
||||||
|
assoc := ("severityNumber", encode_json_severity_number v.severity_number) :: !assoc;
|
||||||
|
);
|
||||||
|
if log_record_has_severity_text v then (
|
||||||
|
assoc := ("severityText", Pbrt_yojson.make_string v.severity_text) :: !assoc;
|
||||||
|
);
|
||||||
|
assoc := (match v.body with
|
||||||
|
| None -> !assoc
|
||||||
|
| Some v -> ("body", Common.encode_json_any_value v) :: !assoc);
|
||||||
|
assoc := (
|
||||||
|
let l = v.attributes |> List.map Common.encode_json_key_value in
|
||||||
|
("attributes", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
if log_record_has_dropped_attributes_count v then (
|
||||||
|
assoc := ("droppedAttributesCount", Pbrt_yojson.make_int (Int32.to_int v.dropped_attributes_count)) :: !assoc;
|
||||||
|
);
|
||||||
|
if log_record_has_flags v then (
|
||||||
|
assoc := ("flags", Pbrt_yojson.make_int (Int32.to_int v.flags)) :: !assoc;
|
||||||
|
);
|
||||||
|
if log_record_has_trace_id v then (
|
||||||
|
assoc := ("traceId", Pbrt_yojson.make_bytes v.trace_id) :: !assoc;
|
||||||
|
);
|
||||||
|
if log_record_has_span_id v then (
|
||||||
|
assoc := ("spanId", Pbrt_yojson.make_bytes v.span_id) :: !assoc;
|
||||||
|
);
|
||||||
|
if log_record_has_event_name v then (
|
||||||
|
assoc := ("eventName", Pbrt_yojson.make_string v.event_name) :: !assoc;
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_scope_logs (v:scope_logs) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
assoc := (match v.scope with
|
||||||
|
| None -> !assoc
|
||||||
|
| Some v -> ("scope", Common.encode_json_instrumentation_scope v) :: !assoc);
|
||||||
|
assoc := (
|
||||||
|
let l = v.log_records |> List.map encode_json_log_record in
|
||||||
|
("logRecords", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
if scope_logs_has_schema_url v then (
|
||||||
|
assoc := ("schemaUrl", Pbrt_yojson.make_string v.schema_url) :: !assoc;
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_resource_logs (v:resource_logs) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
assoc := (match v.resource with
|
||||||
|
| None -> !assoc
|
||||||
|
| Some v -> ("resource", Resource.encode_json_resource v) :: !assoc);
|
||||||
|
assoc := (
|
||||||
|
let l = v.scope_logs |> List.map encode_json_scope_logs in
|
||||||
|
("scopeLogs", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
if resource_logs_has_schema_url v then (
|
||||||
|
assoc := ("schemaUrl", Pbrt_yojson.make_string v.schema_url) :: !assoc;
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_logs_data (v:logs_data) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
assoc := (
|
||||||
|
let l = v.resource_logs |> List.map encode_json_resource_logs in
|
||||||
|
("resourceLogs", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_log_record_flags (v:log_record_flags) =
|
||||||
|
match v with
|
||||||
|
| Log_record_flags_do_not_use -> `String "LOG_RECORD_FLAGS_DO_NOT_USE"
|
||||||
|
| Log_record_flags_trace_flags_mask -> `String "LOG_RECORD_FLAGS_TRACE_FLAGS_MASK"
|
||||||
|
|
||||||
|
[@@@ocaml.warning "-23-27-30-39"]
|
||||||
|
|
||||||
|
(** {2 JSON Decoding} *)
|
||||||
|
|
||||||
|
let rec decode_json_severity_number json =
|
||||||
|
match json with
|
||||||
|
| `String "SEVERITY_NUMBER_UNSPECIFIED" -> (Severity_number_unspecified : severity_number)
|
||||||
|
| `String "SEVERITY_NUMBER_TRACE" -> (Severity_number_trace : severity_number)
|
||||||
|
| `String "SEVERITY_NUMBER_TRACE2" -> (Severity_number_trace2 : severity_number)
|
||||||
|
| `String "SEVERITY_NUMBER_TRACE3" -> (Severity_number_trace3 : severity_number)
|
||||||
|
| `String "SEVERITY_NUMBER_TRACE4" -> (Severity_number_trace4 : severity_number)
|
||||||
|
| `String "SEVERITY_NUMBER_DEBUG" -> (Severity_number_debug : severity_number)
|
||||||
|
| `String "SEVERITY_NUMBER_DEBUG2" -> (Severity_number_debug2 : severity_number)
|
||||||
|
| `String "SEVERITY_NUMBER_DEBUG3" -> (Severity_number_debug3 : severity_number)
|
||||||
|
| `String "SEVERITY_NUMBER_DEBUG4" -> (Severity_number_debug4 : severity_number)
|
||||||
|
| `String "SEVERITY_NUMBER_INFO" -> (Severity_number_info : severity_number)
|
||||||
|
| `String "SEVERITY_NUMBER_INFO2" -> (Severity_number_info2 : severity_number)
|
||||||
|
| `String "SEVERITY_NUMBER_INFO3" -> (Severity_number_info3 : severity_number)
|
||||||
|
| `String "SEVERITY_NUMBER_INFO4" -> (Severity_number_info4 : severity_number)
|
||||||
|
| `String "SEVERITY_NUMBER_WARN" -> (Severity_number_warn : severity_number)
|
||||||
|
| `String "SEVERITY_NUMBER_WARN2" -> (Severity_number_warn2 : severity_number)
|
||||||
|
| `String "SEVERITY_NUMBER_WARN3" -> (Severity_number_warn3 : severity_number)
|
||||||
|
| `String "SEVERITY_NUMBER_WARN4" -> (Severity_number_warn4 : severity_number)
|
||||||
|
| `String "SEVERITY_NUMBER_ERROR" -> (Severity_number_error : severity_number)
|
||||||
|
| `String "SEVERITY_NUMBER_ERROR2" -> (Severity_number_error2 : severity_number)
|
||||||
|
| `String "SEVERITY_NUMBER_ERROR3" -> (Severity_number_error3 : severity_number)
|
||||||
|
| `String "SEVERITY_NUMBER_ERROR4" -> (Severity_number_error4 : severity_number)
|
||||||
|
| `String "SEVERITY_NUMBER_FATAL" -> (Severity_number_fatal : severity_number)
|
||||||
|
| `String "SEVERITY_NUMBER_FATAL2" -> (Severity_number_fatal2 : severity_number)
|
||||||
|
| `String "SEVERITY_NUMBER_FATAL3" -> (Severity_number_fatal3 : severity_number)
|
||||||
|
| `String "SEVERITY_NUMBER_FATAL4" -> (Severity_number_fatal4 : severity_number)
|
||||||
|
| _ -> Pbrt_yojson.E.malformed_variant "severity_number"
|
||||||
|
|
||||||
|
let rec decode_json_log_record d =
|
||||||
|
let v = default_log_record () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("timeUnixNano", json_value) ->
|
||||||
|
log_record_set_time_unix_nano v (Pbrt_yojson.int64 json_value "log_record" "time_unix_nano")
|
||||||
|
| ("observedTimeUnixNano", json_value) ->
|
||||||
|
log_record_set_observed_time_unix_nano v (Pbrt_yojson.int64 json_value "log_record" "observed_time_unix_nano")
|
||||||
|
| ("severityNumber", json_value) ->
|
||||||
|
log_record_set_severity_number v ((decode_json_severity_number json_value))
|
||||||
|
| ("severityText", json_value) ->
|
||||||
|
log_record_set_severity_text v (Pbrt_yojson.string json_value "log_record" "severity_text")
|
||||||
|
| ("body", json_value) ->
|
||||||
|
log_record_set_body v (Common.decode_json_any_value json_value)
|
||||||
|
| ("attributes", `List l) -> begin
|
||||||
|
log_record_set_attributes v @@ List.map (function
|
||||||
|
| json_value -> (Common.decode_json_key_value json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
| ("droppedAttributesCount", json_value) ->
|
||||||
|
log_record_set_dropped_attributes_count v (Pbrt_yojson.int32 json_value "log_record" "dropped_attributes_count")
|
||||||
|
| ("flags", json_value) ->
|
||||||
|
log_record_set_flags v (Pbrt_yojson.int32 json_value "log_record" "flags")
|
||||||
|
| ("traceId", json_value) ->
|
||||||
|
log_record_set_trace_id v (Pbrt_yojson.bytes json_value "log_record" "trace_id")
|
||||||
|
| ("spanId", json_value) ->
|
||||||
|
log_record_set_span_id v (Pbrt_yojson.bytes json_value "log_record" "span_id")
|
||||||
|
| ("eventName", json_value) ->
|
||||||
|
log_record_set_event_name v (Pbrt_yojson.string json_value "log_record" "event_name")
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
_presence = v._presence;
|
||||||
|
time_unix_nano = v.time_unix_nano;
|
||||||
|
observed_time_unix_nano = v.observed_time_unix_nano;
|
||||||
|
severity_number = v.severity_number;
|
||||||
|
severity_text = v.severity_text;
|
||||||
|
body = v.body;
|
||||||
|
attributes = v.attributes;
|
||||||
|
dropped_attributes_count = v.dropped_attributes_count;
|
||||||
|
flags = v.flags;
|
||||||
|
trace_id = v.trace_id;
|
||||||
|
span_id = v.span_id;
|
||||||
|
event_name = v.event_name;
|
||||||
|
} : log_record)
|
||||||
|
|
||||||
|
let rec decode_json_scope_logs d =
|
||||||
|
let v = default_scope_logs () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("scope", json_value) ->
|
||||||
|
scope_logs_set_scope v (Common.decode_json_instrumentation_scope json_value)
|
||||||
|
| ("logRecords", `List l) -> begin
|
||||||
|
scope_logs_set_log_records v @@ List.map (function
|
||||||
|
| json_value -> (decode_json_log_record json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
| ("schemaUrl", json_value) ->
|
||||||
|
scope_logs_set_schema_url v (Pbrt_yojson.string json_value "scope_logs" "schema_url")
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
_presence = v._presence;
|
||||||
|
scope = v.scope;
|
||||||
|
log_records = v.log_records;
|
||||||
|
schema_url = v.schema_url;
|
||||||
|
} : scope_logs)
|
||||||
|
|
||||||
|
let rec decode_json_resource_logs d =
|
||||||
|
let v = default_resource_logs () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("resource", json_value) ->
|
||||||
|
resource_logs_set_resource v (Resource.decode_json_resource json_value)
|
||||||
|
| ("scopeLogs", `List l) -> begin
|
||||||
|
resource_logs_set_scope_logs v @@ List.map (function
|
||||||
|
| json_value -> (decode_json_scope_logs json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
| ("schemaUrl", json_value) ->
|
||||||
|
resource_logs_set_schema_url v (Pbrt_yojson.string json_value "resource_logs" "schema_url")
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
_presence = v._presence;
|
||||||
|
resource = v.resource;
|
||||||
|
scope_logs = v.scope_logs;
|
||||||
|
schema_url = v.schema_url;
|
||||||
|
} : resource_logs)
|
||||||
|
|
||||||
|
let rec decode_json_logs_data d =
|
||||||
|
let v = default_logs_data () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("resourceLogs", `List l) -> begin
|
||||||
|
logs_data_set_resource_logs v @@ List.map (function
|
||||||
|
| json_value -> (decode_json_resource_logs json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
resource_logs = v.resource_logs;
|
||||||
|
} : logs_data)
|
||||||
|
|
||||||
|
let rec decode_json_log_record_flags json =
|
||||||
|
match json with
|
||||||
|
| `String "LOG_RECORD_FLAGS_DO_NOT_USE" -> (Log_record_flags_do_not_use : log_record_flags)
|
||||||
|
| `String "LOG_RECORD_FLAGS_TRACE_FLAGS_MASK" -> (Log_record_flags_trace_flags_mask : log_record_flags)
|
||||||
|
| _ -> Pbrt_yojson.E.malformed_variant "log_record_flags"
|
||||||
|
|
|
||||||
|
|
@ -290,3 +290,45 @@ val decode_pb_logs_data : Pbrt.Decoder.t -> logs_data
|
||||||
|
|
||||||
val decode_pb_log_record_flags : Pbrt.Decoder.t -> log_record_flags
|
val decode_pb_log_record_flags : Pbrt.Decoder.t -> log_record_flags
|
||||||
(** [decode_pb_log_record_flags decoder] decodes a [log_record_flags] binary value from [decoder] *)
|
(** [decode_pb_log_record_flags decoder] decodes a [log_record_flags] binary value from [decoder] *)
|
||||||
|
|
||||||
|
|
||||||
|
(** {2 Protobuf YoJson Encoding} *)
|
||||||
|
|
||||||
|
val encode_json_severity_number : severity_number -> Yojson.Basic.t
|
||||||
|
(** [encode_json_severity_number v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_log_record : log_record -> Yojson.Basic.t
|
||||||
|
(** [encode_json_log_record v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_scope_logs : scope_logs -> Yojson.Basic.t
|
||||||
|
(** [encode_json_scope_logs v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_resource_logs : resource_logs -> Yojson.Basic.t
|
||||||
|
(** [encode_json_resource_logs v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_logs_data : logs_data -> Yojson.Basic.t
|
||||||
|
(** [encode_json_logs_data v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_log_record_flags : log_record_flags -> Yojson.Basic.t
|
||||||
|
(** [encode_json_log_record_flags v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
|
||||||
|
(** {2 JSON Decoding} *)
|
||||||
|
|
||||||
|
val decode_json_severity_number : Yojson.Basic.t -> severity_number
|
||||||
|
(** [decode_json_severity_number decoder] decodes a [severity_number] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_log_record : Yojson.Basic.t -> log_record
|
||||||
|
(** [decode_json_log_record decoder] decodes a [log_record] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_scope_logs : Yojson.Basic.t -> scope_logs
|
||||||
|
(** [decode_json_scope_logs decoder] decodes a [scope_logs] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_resource_logs : Yojson.Basic.t -> resource_logs
|
||||||
|
(** [decode_json_resource_logs decoder] decodes a [resource_logs] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_logs_data : Yojson.Basic.t -> logs_data
|
||||||
|
(** [decode_json_logs_data decoder] decodes a [logs_data] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_log_record_flags : Yojson.Basic.t -> log_record_flags
|
||||||
|
(** [decode_json_log_record_flags decoder] decodes a [log_record_flags] value from [decoder] *)
|
||||||
|
|
|
||||||
|
|
@ -200,3 +200,91 @@ let rec decode_pb_export_logs_service_response d =
|
||||||
| Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind
|
| Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind
|
||||||
done;
|
done;
|
||||||
(v : export_logs_service_response)
|
(v : export_logs_service_response)
|
||||||
|
|
||||||
|
[@@@ocaml.warning "-23-27-30-39"]
|
||||||
|
|
||||||
|
(** {2 Protobuf YoJson Encoding} *)
|
||||||
|
|
||||||
|
let rec encode_json_export_logs_service_request (v:export_logs_service_request) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
assoc := (
|
||||||
|
let l = v.resource_logs |> List.map Logs.encode_json_resource_logs in
|
||||||
|
("resourceLogs", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_export_logs_partial_success (v:export_logs_partial_success) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
if export_logs_partial_success_has_rejected_log_records v then (
|
||||||
|
assoc := ("rejectedLogRecords", Pbrt_yojson.make_string (Int64.to_string v.rejected_log_records)) :: !assoc;
|
||||||
|
);
|
||||||
|
if export_logs_partial_success_has_error_message v then (
|
||||||
|
assoc := ("errorMessage", Pbrt_yojson.make_string v.error_message) :: !assoc;
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_export_logs_service_response (v:export_logs_service_response) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
assoc := (match v.partial_success with
|
||||||
|
| None -> !assoc
|
||||||
|
| Some v -> ("partialSuccess", encode_json_export_logs_partial_success v) :: !assoc);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
[@@@ocaml.warning "-23-27-30-39"]
|
||||||
|
|
||||||
|
(** {2 JSON Decoding} *)
|
||||||
|
|
||||||
|
let rec decode_json_export_logs_service_request d =
|
||||||
|
let v = default_export_logs_service_request () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("resourceLogs", `List l) -> begin
|
||||||
|
export_logs_service_request_set_resource_logs v @@ List.map (function
|
||||||
|
| json_value -> (Logs.decode_json_resource_logs json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
resource_logs = v.resource_logs;
|
||||||
|
} : export_logs_service_request)
|
||||||
|
|
||||||
|
let rec decode_json_export_logs_partial_success d =
|
||||||
|
let v = default_export_logs_partial_success () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("rejectedLogRecords", json_value) ->
|
||||||
|
export_logs_partial_success_set_rejected_log_records v (Pbrt_yojson.int64 json_value "export_logs_partial_success" "rejected_log_records")
|
||||||
|
| ("errorMessage", json_value) ->
|
||||||
|
export_logs_partial_success_set_error_message v (Pbrt_yojson.string json_value "export_logs_partial_success" "error_message")
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
_presence = v._presence;
|
||||||
|
rejected_log_records = v.rejected_log_records;
|
||||||
|
error_message = v.error_message;
|
||||||
|
} : export_logs_partial_success)
|
||||||
|
|
||||||
|
let rec decode_json_export_logs_service_response d =
|
||||||
|
let v = default_export_logs_service_response () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("partialSuccess", json_value) ->
|
||||||
|
export_logs_service_response_set_partial_success v (decode_json_export_logs_partial_success json_value)
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
partial_success = v.partial_success;
|
||||||
|
} : export_logs_service_response)
|
||||||
|
|
|
||||||
|
|
@ -114,3 +114,27 @@ val decode_pb_export_logs_partial_success : Pbrt.Decoder.t -> export_logs_partia
|
||||||
|
|
||||||
val decode_pb_export_logs_service_response : Pbrt.Decoder.t -> export_logs_service_response
|
val decode_pb_export_logs_service_response : Pbrt.Decoder.t -> export_logs_service_response
|
||||||
(** [decode_pb_export_logs_service_response decoder] decodes a [export_logs_service_response] binary value from [decoder] *)
|
(** [decode_pb_export_logs_service_response decoder] decodes a [export_logs_service_response] binary value from [decoder] *)
|
||||||
|
|
||||||
|
|
||||||
|
(** {2 Protobuf YoJson Encoding} *)
|
||||||
|
|
||||||
|
val encode_json_export_logs_service_request : export_logs_service_request -> Yojson.Basic.t
|
||||||
|
(** [encode_json_export_logs_service_request v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_export_logs_partial_success : export_logs_partial_success -> Yojson.Basic.t
|
||||||
|
(** [encode_json_export_logs_partial_success v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_export_logs_service_response : export_logs_service_response -> Yojson.Basic.t
|
||||||
|
(** [encode_json_export_logs_service_response v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
|
||||||
|
(** {2 JSON Decoding} *)
|
||||||
|
|
||||||
|
val decode_json_export_logs_service_request : Yojson.Basic.t -> export_logs_service_request
|
||||||
|
(** [decode_json_export_logs_service_request decoder] decodes a [export_logs_service_request] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_export_logs_partial_success : Yojson.Basic.t -> export_logs_partial_success
|
||||||
|
(** [decode_json_export_logs_partial_success decoder] decodes a [export_logs_partial_success] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_export_logs_service_response : Yojson.Basic.t -> export_logs_service_response
|
||||||
|
(** [decode_json_export_logs_service_response decoder] decodes a [export_logs_service_response] value from [decoder] *)
|
||||||
|
|
|
||||||
|
|
@ -2116,3 +2116,908 @@ let rec decode_pb_data_point_flags d : data_point_flags =
|
||||||
| 0 -> Data_point_flags_do_not_use
|
| 0 -> Data_point_flags_do_not_use
|
||||||
| 1 -> Data_point_flags_no_recorded_value_mask
|
| 1 -> Data_point_flags_no_recorded_value_mask
|
||||||
| _ -> Pbrt.Decoder.malformed_variant "data_point_flags"
|
| _ -> Pbrt.Decoder.malformed_variant "data_point_flags"
|
||||||
|
|
||||||
|
[@@@ocaml.warning "-23-27-30-39"]
|
||||||
|
|
||||||
|
(** {2 Protobuf YoJson Encoding} *)
|
||||||
|
|
||||||
|
let rec encode_json_exemplar_value (v:exemplar_value) =
|
||||||
|
begin match v with
|
||||||
|
| As_double v -> `Assoc [("asDouble", Pbrt_yojson.make_string (string_of_float v))]
|
||||||
|
| As_int v -> `Assoc [("asInt", Pbrt_yojson.make_string (Int64.to_string v))]
|
||||||
|
end
|
||||||
|
|
||||||
|
and encode_json_exemplar (v:exemplar) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
assoc := (
|
||||||
|
let l = v.filtered_attributes |> List.map Common.encode_json_key_value in
|
||||||
|
("filteredAttributes", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
if exemplar_has_time_unix_nano v then (
|
||||||
|
assoc := ("timeUnixNano", Pbrt_yojson.make_string (Int64.to_string v.time_unix_nano)) :: !assoc;
|
||||||
|
);
|
||||||
|
assoc := (match v.value with
|
||||||
|
| None -> !assoc
|
||||||
|
| Some (As_double v) -> ("asDouble", Pbrt_yojson.make_string (string_of_float v)) :: !assoc
|
||||||
|
| Some (As_int v) -> ("asInt", Pbrt_yojson.make_string (Int64.to_string v)) :: !assoc
|
||||||
|
); (* match v.value *)
|
||||||
|
if exemplar_has_span_id v then (
|
||||||
|
assoc := ("spanId", Pbrt_yojson.make_bytes v.span_id) :: !assoc;
|
||||||
|
);
|
||||||
|
if exemplar_has_trace_id v then (
|
||||||
|
assoc := ("traceId", Pbrt_yojson.make_bytes v.trace_id) :: !assoc;
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_number_data_point_value (v:number_data_point_value) =
|
||||||
|
begin match v with
|
||||||
|
| As_double v -> `Assoc [("asDouble", Pbrt_yojson.make_string (string_of_float v))]
|
||||||
|
| As_int v -> `Assoc [("asInt", Pbrt_yojson.make_string (Int64.to_string v))]
|
||||||
|
end
|
||||||
|
|
||||||
|
and encode_json_number_data_point (v:number_data_point) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
assoc := (
|
||||||
|
let l = v.attributes |> List.map Common.encode_json_key_value in
|
||||||
|
("attributes", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
if number_data_point_has_start_time_unix_nano v then (
|
||||||
|
assoc := ("startTimeUnixNano", Pbrt_yojson.make_string (Int64.to_string v.start_time_unix_nano)) :: !assoc;
|
||||||
|
);
|
||||||
|
if number_data_point_has_time_unix_nano v then (
|
||||||
|
assoc := ("timeUnixNano", Pbrt_yojson.make_string (Int64.to_string v.time_unix_nano)) :: !assoc;
|
||||||
|
);
|
||||||
|
assoc := (match v.value with
|
||||||
|
| None -> !assoc
|
||||||
|
| Some (As_double v) -> ("asDouble", Pbrt_yojson.make_string (string_of_float v)) :: !assoc
|
||||||
|
| Some (As_int v) -> ("asInt", Pbrt_yojson.make_string (Int64.to_string v)) :: !assoc
|
||||||
|
); (* match v.value *)
|
||||||
|
assoc := (
|
||||||
|
let l = v.exemplars |> List.map encode_json_exemplar in
|
||||||
|
("exemplars", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
if number_data_point_has_flags v then (
|
||||||
|
assoc := ("flags", Pbrt_yojson.make_int (Int32.to_int v.flags)) :: !assoc;
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_gauge (v:gauge) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
assoc := (
|
||||||
|
let l = v.data_points |> List.map encode_json_number_data_point in
|
||||||
|
("dataPoints", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_aggregation_temporality (v:aggregation_temporality) =
|
||||||
|
match v with
|
||||||
|
| Aggregation_temporality_unspecified -> `String "AGGREGATION_TEMPORALITY_UNSPECIFIED"
|
||||||
|
| Aggregation_temporality_delta -> `String "AGGREGATION_TEMPORALITY_DELTA"
|
||||||
|
| Aggregation_temporality_cumulative -> `String "AGGREGATION_TEMPORALITY_CUMULATIVE"
|
||||||
|
|
||||||
|
let rec encode_json_sum (v:sum) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
assoc := (
|
||||||
|
let l = v.data_points |> List.map encode_json_number_data_point in
|
||||||
|
("dataPoints", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
if sum_has_aggregation_temporality v then (
|
||||||
|
assoc := ("aggregationTemporality", encode_json_aggregation_temporality v.aggregation_temporality) :: !assoc;
|
||||||
|
);
|
||||||
|
if sum_has_is_monotonic v then (
|
||||||
|
assoc := ("isMonotonic", Pbrt_yojson.make_bool v.is_monotonic) :: !assoc;
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_histogram_data_point (v:histogram_data_point) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
assoc := (
|
||||||
|
let l = v.attributes |> List.map Common.encode_json_key_value in
|
||||||
|
("attributes", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
if histogram_data_point_has_start_time_unix_nano v then (
|
||||||
|
assoc := ("startTimeUnixNano", Pbrt_yojson.make_string (Int64.to_string v.start_time_unix_nano)) :: !assoc;
|
||||||
|
);
|
||||||
|
if histogram_data_point_has_time_unix_nano v then (
|
||||||
|
assoc := ("timeUnixNano", Pbrt_yojson.make_string (Int64.to_string v.time_unix_nano)) :: !assoc;
|
||||||
|
);
|
||||||
|
if histogram_data_point_has_count v then (
|
||||||
|
assoc := ("count", Pbrt_yojson.make_string (Int64.to_string v.count)) :: !assoc;
|
||||||
|
);
|
||||||
|
if histogram_data_point_has_sum v then (
|
||||||
|
assoc := ("sum", Pbrt_yojson.make_string (string_of_float v.sum)) :: !assoc;
|
||||||
|
);
|
||||||
|
assoc := (
|
||||||
|
let l = v.bucket_counts |> List.map Int64.to_string |> List.map Pbrt_yojson.make_string in
|
||||||
|
("bucketCounts", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
assoc := (
|
||||||
|
let l = v.explicit_bounds |> List.map string_of_float |> List.map Pbrt_yojson.make_string in
|
||||||
|
("explicitBounds", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
assoc := (
|
||||||
|
let l = v.exemplars |> List.map encode_json_exemplar in
|
||||||
|
("exemplars", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
if histogram_data_point_has_flags v then (
|
||||||
|
assoc := ("flags", Pbrt_yojson.make_int (Int32.to_int v.flags)) :: !assoc;
|
||||||
|
);
|
||||||
|
if histogram_data_point_has_min v then (
|
||||||
|
assoc := ("min", Pbrt_yojson.make_string (string_of_float v.min)) :: !assoc;
|
||||||
|
);
|
||||||
|
if histogram_data_point_has_max v then (
|
||||||
|
assoc := ("max", Pbrt_yojson.make_string (string_of_float v.max)) :: !assoc;
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_histogram (v:histogram) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
assoc := (
|
||||||
|
let l = v.data_points |> List.map encode_json_histogram_data_point in
|
||||||
|
("dataPoints", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
if histogram_has_aggregation_temporality v then (
|
||||||
|
assoc := ("aggregationTemporality", encode_json_aggregation_temporality v.aggregation_temporality) :: !assoc;
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_exponential_histogram_data_point_buckets (v:exponential_histogram_data_point_buckets) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
if exponential_histogram_data_point_buckets_has_offset v then (
|
||||||
|
assoc := ("offset", Pbrt_yojson.make_int (Int32.to_int v.offset)) :: !assoc;
|
||||||
|
);
|
||||||
|
assoc := (
|
||||||
|
let l = v.bucket_counts |> List.map Int64.to_string |> List.map Pbrt_yojson.make_string in
|
||||||
|
("bucketCounts", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_exponential_histogram_data_point (v:exponential_histogram_data_point) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
assoc := (
|
||||||
|
let l = v.attributes |> List.map Common.encode_json_key_value in
|
||||||
|
("attributes", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
if exponential_histogram_data_point_has_start_time_unix_nano v then (
|
||||||
|
assoc := ("startTimeUnixNano", Pbrt_yojson.make_string (Int64.to_string v.start_time_unix_nano)) :: !assoc;
|
||||||
|
);
|
||||||
|
if exponential_histogram_data_point_has_time_unix_nano v then (
|
||||||
|
assoc := ("timeUnixNano", Pbrt_yojson.make_string (Int64.to_string v.time_unix_nano)) :: !assoc;
|
||||||
|
);
|
||||||
|
if exponential_histogram_data_point_has_count v then (
|
||||||
|
assoc := ("count", Pbrt_yojson.make_string (Int64.to_string v.count)) :: !assoc;
|
||||||
|
);
|
||||||
|
if exponential_histogram_data_point_has_sum v then (
|
||||||
|
assoc := ("sum", Pbrt_yojson.make_string (string_of_float v.sum)) :: !assoc;
|
||||||
|
);
|
||||||
|
if exponential_histogram_data_point_has_scale v then (
|
||||||
|
assoc := ("scale", Pbrt_yojson.make_int (Int32.to_int v.scale)) :: !assoc;
|
||||||
|
);
|
||||||
|
if exponential_histogram_data_point_has_zero_count v then (
|
||||||
|
assoc := ("zeroCount", Pbrt_yojson.make_string (Int64.to_string v.zero_count)) :: !assoc;
|
||||||
|
);
|
||||||
|
assoc := (match v.positive with
|
||||||
|
| None -> !assoc
|
||||||
|
| Some v -> ("positive", encode_json_exponential_histogram_data_point_buckets v) :: !assoc);
|
||||||
|
assoc := (match v.negative with
|
||||||
|
| None -> !assoc
|
||||||
|
| Some v -> ("negative", encode_json_exponential_histogram_data_point_buckets v) :: !assoc);
|
||||||
|
if exponential_histogram_data_point_has_flags v then (
|
||||||
|
assoc := ("flags", Pbrt_yojson.make_int (Int32.to_int v.flags)) :: !assoc;
|
||||||
|
);
|
||||||
|
assoc := (
|
||||||
|
let l = v.exemplars |> List.map encode_json_exemplar in
|
||||||
|
("exemplars", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
if exponential_histogram_data_point_has_min v then (
|
||||||
|
assoc := ("min", Pbrt_yojson.make_string (string_of_float v.min)) :: !assoc;
|
||||||
|
);
|
||||||
|
if exponential_histogram_data_point_has_max v then (
|
||||||
|
assoc := ("max", Pbrt_yojson.make_string (string_of_float v.max)) :: !assoc;
|
||||||
|
);
|
||||||
|
if exponential_histogram_data_point_has_zero_threshold v then (
|
||||||
|
assoc := ("zeroThreshold", Pbrt_yojson.make_string (string_of_float v.zero_threshold)) :: !assoc;
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_exponential_histogram (v:exponential_histogram) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
assoc := (
|
||||||
|
let l = v.data_points |> List.map encode_json_exponential_histogram_data_point in
|
||||||
|
("dataPoints", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
if exponential_histogram_has_aggregation_temporality v then (
|
||||||
|
assoc := ("aggregationTemporality", encode_json_aggregation_temporality v.aggregation_temporality) :: !assoc;
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_summary_data_point_value_at_quantile (v:summary_data_point_value_at_quantile) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
if summary_data_point_value_at_quantile_has_quantile v then (
|
||||||
|
assoc := ("quantile", Pbrt_yojson.make_string (string_of_float v.quantile)) :: !assoc;
|
||||||
|
);
|
||||||
|
if summary_data_point_value_at_quantile_has_value v then (
|
||||||
|
assoc := ("value", Pbrt_yojson.make_string (string_of_float v.value)) :: !assoc;
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_summary_data_point (v:summary_data_point) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
assoc := (
|
||||||
|
let l = v.attributes |> List.map Common.encode_json_key_value in
|
||||||
|
("attributes", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
if summary_data_point_has_start_time_unix_nano v then (
|
||||||
|
assoc := ("startTimeUnixNano", Pbrt_yojson.make_string (Int64.to_string v.start_time_unix_nano)) :: !assoc;
|
||||||
|
);
|
||||||
|
if summary_data_point_has_time_unix_nano v then (
|
||||||
|
assoc := ("timeUnixNano", Pbrt_yojson.make_string (Int64.to_string v.time_unix_nano)) :: !assoc;
|
||||||
|
);
|
||||||
|
if summary_data_point_has_count v then (
|
||||||
|
assoc := ("count", Pbrt_yojson.make_string (Int64.to_string v.count)) :: !assoc;
|
||||||
|
);
|
||||||
|
if summary_data_point_has_sum v then (
|
||||||
|
assoc := ("sum", Pbrt_yojson.make_string (string_of_float v.sum)) :: !assoc;
|
||||||
|
);
|
||||||
|
assoc := (
|
||||||
|
let l = v.quantile_values |> List.map encode_json_summary_data_point_value_at_quantile in
|
||||||
|
("quantileValues", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
if summary_data_point_has_flags v then (
|
||||||
|
assoc := ("flags", Pbrt_yojson.make_int (Int32.to_int v.flags)) :: !assoc;
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_summary (v:summary) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
assoc := (
|
||||||
|
let l = v.data_points |> List.map encode_json_summary_data_point in
|
||||||
|
("dataPoints", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_metric_data (v:metric_data) =
|
||||||
|
begin match v with
|
||||||
|
| Gauge v -> `Assoc [("gauge", encode_json_gauge v)]
|
||||||
|
| Sum v -> `Assoc [("sum", encode_json_sum v)]
|
||||||
|
| Histogram v -> `Assoc [("histogram", encode_json_histogram v)]
|
||||||
|
| Exponential_histogram v -> `Assoc [("exponentialHistogram", encode_json_exponential_histogram v)]
|
||||||
|
| Summary v -> `Assoc [("summary", encode_json_summary v)]
|
||||||
|
end
|
||||||
|
|
||||||
|
and encode_json_metric (v:metric) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
if metric_has_name v then (
|
||||||
|
assoc := ("name", Pbrt_yojson.make_string v.name) :: !assoc;
|
||||||
|
);
|
||||||
|
if metric_has_description v then (
|
||||||
|
assoc := ("description", Pbrt_yojson.make_string v.description) :: !assoc;
|
||||||
|
);
|
||||||
|
if metric_has_unit_ v then (
|
||||||
|
assoc := ("unit", Pbrt_yojson.make_string v.unit_) :: !assoc;
|
||||||
|
);
|
||||||
|
assoc := (match v.data with
|
||||||
|
| None -> !assoc
|
||||||
|
| Some (Gauge v) -> ("gauge", encode_json_gauge v) :: !assoc
|
||||||
|
| Some (Sum v) -> ("sum", encode_json_sum v) :: !assoc
|
||||||
|
| Some (Histogram v) -> ("histogram", encode_json_histogram v) :: !assoc
|
||||||
|
| Some (Exponential_histogram v) -> ("exponentialHistogram", encode_json_exponential_histogram v) :: !assoc
|
||||||
|
| Some (Summary v) -> ("summary", encode_json_summary v) :: !assoc
|
||||||
|
); (* match v.data *)
|
||||||
|
assoc := (
|
||||||
|
let l = v.metadata |> List.map Common.encode_json_key_value in
|
||||||
|
("metadata", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_scope_metrics (v:scope_metrics) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
assoc := (match v.scope with
|
||||||
|
| None -> !assoc
|
||||||
|
| Some v -> ("scope", Common.encode_json_instrumentation_scope v) :: !assoc);
|
||||||
|
assoc := (
|
||||||
|
let l = v.metrics |> List.map encode_json_metric in
|
||||||
|
("metrics", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
if scope_metrics_has_schema_url v then (
|
||||||
|
assoc := ("schemaUrl", Pbrt_yojson.make_string v.schema_url) :: !assoc;
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_resource_metrics (v:resource_metrics) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
assoc := (match v.resource with
|
||||||
|
| None -> !assoc
|
||||||
|
| Some v -> ("resource", Resource.encode_json_resource v) :: !assoc);
|
||||||
|
assoc := (
|
||||||
|
let l = v.scope_metrics |> List.map encode_json_scope_metrics in
|
||||||
|
("scopeMetrics", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
if resource_metrics_has_schema_url v then (
|
||||||
|
assoc := ("schemaUrl", Pbrt_yojson.make_string v.schema_url) :: !assoc;
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_metrics_data (v:metrics_data) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
assoc := (
|
||||||
|
let l = v.resource_metrics |> List.map encode_json_resource_metrics in
|
||||||
|
("resourceMetrics", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_data_point_flags (v:data_point_flags) =
|
||||||
|
match v with
|
||||||
|
| Data_point_flags_do_not_use -> `String "DATA_POINT_FLAGS_DO_NOT_USE"
|
||||||
|
| Data_point_flags_no_recorded_value_mask -> `String "DATA_POINT_FLAGS_NO_RECORDED_VALUE_MASK"
|
||||||
|
|
||||||
|
[@@@ocaml.warning "-23-27-30-39"]
|
||||||
|
|
||||||
|
(** {2 JSON Decoding} *)
|
||||||
|
|
||||||
|
let rec decode_json_exemplar_value json =
|
||||||
|
let assoc = match json with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
let rec loop = function
|
||||||
|
| [] -> Pbrt_yojson.E.malformed_variant "exemplar_value"
|
||||||
|
| ("asDouble", json_value)::_ ->
|
||||||
|
(As_double (Pbrt_yojson.float json_value "exemplar_value" "As_double") : exemplar_value)
|
||||||
|
| ("asInt", json_value)::_ ->
|
||||||
|
(As_int (Pbrt_yojson.int64 json_value "exemplar_value" "As_int") : exemplar_value)
|
||||||
|
|
||||||
|
| _ :: tl -> loop tl
|
||||||
|
in
|
||||||
|
loop assoc
|
||||||
|
|
||||||
|
and decode_json_exemplar d =
|
||||||
|
let v = default_exemplar () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("filteredAttributes", `List l) -> begin
|
||||||
|
exemplar_set_filtered_attributes v @@ List.map (function
|
||||||
|
| json_value -> (Common.decode_json_key_value json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
| ("timeUnixNano", json_value) ->
|
||||||
|
exemplar_set_time_unix_nano v (Pbrt_yojson.int64 json_value "exemplar" "time_unix_nano")
|
||||||
|
| ("asDouble", json_value) ->
|
||||||
|
exemplar_set_value v (As_double (Pbrt_yojson.float json_value "exemplar" "value"))
|
||||||
|
| ("asInt", json_value) ->
|
||||||
|
exemplar_set_value v (As_int (Pbrt_yojson.int64 json_value "exemplar" "value"))
|
||||||
|
| ("spanId", json_value) ->
|
||||||
|
exemplar_set_span_id v (Pbrt_yojson.bytes json_value "exemplar" "span_id")
|
||||||
|
| ("traceId", json_value) ->
|
||||||
|
exemplar_set_trace_id v (Pbrt_yojson.bytes json_value "exemplar" "trace_id")
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
_presence = v._presence;
|
||||||
|
filtered_attributes = v.filtered_attributes;
|
||||||
|
time_unix_nano = v.time_unix_nano;
|
||||||
|
value = v.value;
|
||||||
|
span_id = v.span_id;
|
||||||
|
trace_id = v.trace_id;
|
||||||
|
} : exemplar)
|
||||||
|
|
||||||
|
let rec decode_json_number_data_point_value json =
|
||||||
|
let assoc = match json with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
let rec loop = function
|
||||||
|
| [] -> Pbrt_yojson.E.malformed_variant "number_data_point_value"
|
||||||
|
| ("asDouble", json_value)::_ ->
|
||||||
|
(As_double (Pbrt_yojson.float json_value "number_data_point_value" "As_double") : number_data_point_value)
|
||||||
|
| ("asInt", json_value)::_ ->
|
||||||
|
(As_int (Pbrt_yojson.int64 json_value "number_data_point_value" "As_int") : number_data_point_value)
|
||||||
|
|
||||||
|
| _ :: tl -> loop tl
|
||||||
|
in
|
||||||
|
loop assoc
|
||||||
|
|
||||||
|
and decode_json_number_data_point d =
|
||||||
|
let v = default_number_data_point () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("attributes", `List l) -> begin
|
||||||
|
number_data_point_set_attributes v @@ List.map (function
|
||||||
|
| json_value -> (Common.decode_json_key_value json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
| ("startTimeUnixNano", json_value) ->
|
||||||
|
number_data_point_set_start_time_unix_nano v (Pbrt_yojson.int64 json_value "number_data_point" "start_time_unix_nano")
|
||||||
|
| ("timeUnixNano", json_value) ->
|
||||||
|
number_data_point_set_time_unix_nano v (Pbrt_yojson.int64 json_value "number_data_point" "time_unix_nano")
|
||||||
|
| ("asDouble", json_value) ->
|
||||||
|
number_data_point_set_value v (As_double (Pbrt_yojson.float json_value "number_data_point" "value"))
|
||||||
|
| ("asInt", json_value) ->
|
||||||
|
number_data_point_set_value v (As_int (Pbrt_yojson.int64 json_value "number_data_point" "value"))
|
||||||
|
| ("exemplars", `List l) -> begin
|
||||||
|
number_data_point_set_exemplars v @@ List.map (function
|
||||||
|
| json_value -> (decode_json_exemplar json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
| ("flags", json_value) ->
|
||||||
|
number_data_point_set_flags v (Pbrt_yojson.int32 json_value "number_data_point" "flags")
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
_presence = v._presence;
|
||||||
|
attributes = v.attributes;
|
||||||
|
start_time_unix_nano = v.start_time_unix_nano;
|
||||||
|
time_unix_nano = v.time_unix_nano;
|
||||||
|
value = v.value;
|
||||||
|
exemplars = v.exemplars;
|
||||||
|
flags = v.flags;
|
||||||
|
} : number_data_point)
|
||||||
|
|
||||||
|
let rec decode_json_gauge d =
|
||||||
|
let v = default_gauge () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("dataPoints", `List l) -> begin
|
||||||
|
gauge_set_data_points v @@ List.map (function
|
||||||
|
| json_value -> (decode_json_number_data_point json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
data_points = v.data_points;
|
||||||
|
} : gauge)
|
||||||
|
|
||||||
|
let rec decode_json_aggregation_temporality json =
|
||||||
|
match json with
|
||||||
|
| `String "AGGREGATION_TEMPORALITY_UNSPECIFIED" -> (Aggregation_temporality_unspecified : aggregation_temporality)
|
||||||
|
| `String "AGGREGATION_TEMPORALITY_DELTA" -> (Aggregation_temporality_delta : aggregation_temporality)
|
||||||
|
| `String "AGGREGATION_TEMPORALITY_CUMULATIVE" -> (Aggregation_temporality_cumulative : aggregation_temporality)
|
||||||
|
| _ -> Pbrt_yojson.E.malformed_variant "aggregation_temporality"
|
||||||
|
|
||||||
|
let rec decode_json_sum d =
|
||||||
|
let v = default_sum () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("dataPoints", `List l) -> begin
|
||||||
|
sum_set_data_points v @@ List.map (function
|
||||||
|
| json_value -> (decode_json_number_data_point json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
| ("aggregationTemporality", json_value) ->
|
||||||
|
sum_set_aggregation_temporality v ((decode_json_aggregation_temporality json_value))
|
||||||
|
| ("isMonotonic", json_value) ->
|
||||||
|
sum_set_is_monotonic v (Pbrt_yojson.bool json_value "sum" "is_monotonic")
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
_presence = v._presence;
|
||||||
|
data_points = v.data_points;
|
||||||
|
aggregation_temporality = v.aggregation_temporality;
|
||||||
|
is_monotonic = v.is_monotonic;
|
||||||
|
} : sum)
|
||||||
|
|
||||||
|
let rec decode_json_histogram_data_point d =
|
||||||
|
let v = default_histogram_data_point () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("attributes", `List l) -> begin
|
||||||
|
histogram_data_point_set_attributes v @@ List.map (function
|
||||||
|
| json_value -> (Common.decode_json_key_value json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
| ("startTimeUnixNano", json_value) ->
|
||||||
|
histogram_data_point_set_start_time_unix_nano v (Pbrt_yojson.int64 json_value "histogram_data_point" "start_time_unix_nano")
|
||||||
|
| ("timeUnixNano", json_value) ->
|
||||||
|
histogram_data_point_set_time_unix_nano v (Pbrt_yojson.int64 json_value "histogram_data_point" "time_unix_nano")
|
||||||
|
| ("count", json_value) ->
|
||||||
|
histogram_data_point_set_count v (Pbrt_yojson.int64 json_value "histogram_data_point" "count")
|
||||||
|
| ("sum", json_value) ->
|
||||||
|
histogram_data_point_set_sum v (Pbrt_yojson.float json_value "histogram_data_point" "sum")
|
||||||
|
| ("bucketCounts", `List l) -> begin
|
||||||
|
histogram_data_point_set_bucket_counts v @@ List.map (function
|
||||||
|
| json_value -> Pbrt_yojson.int64 json_value "histogram_data_point" "bucket_counts"
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
| ("explicitBounds", `List l) -> begin
|
||||||
|
histogram_data_point_set_explicit_bounds v @@ List.map (function
|
||||||
|
| json_value -> Pbrt_yojson.float json_value "histogram_data_point" "explicit_bounds"
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
| ("exemplars", `List l) -> begin
|
||||||
|
histogram_data_point_set_exemplars v @@ List.map (function
|
||||||
|
| json_value -> (decode_json_exemplar json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
| ("flags", json_value) ->
|
||||||
|
histogram_data_point_set_flags v (Pbrt_yojson.int32 json_value "histogram_data_point" "flags")
|
||||||
|
| ("min", json_value) ->
|
||||||
|
histogram_data_point_set_min v (Pbrt_yojson.float json_value "histogram_data_point" "min")
|
||||||
|
| ("max", json_value) ->
|
||||||
|
histogram_data_point_set_max v (Pbrt_yojson.float json_value "histogram_data_point" "max")
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
_presence = v._presence;
|
||||||
|
attributes = v.attributes;
|
||||||
|
start_time_unix_nano = v.start_time_unix_nano;
|
||||||
|
time_unix_nano = v.time_unix_nano;
|
||||||
|
count = v.count;
|
||||||
|
sum = v.sum;
|
||||||
|
bucket_counts = v.bucket_counts;
|
||||||
|
explicit_bounds = v.explicit_bounds;
|
||||||
|
exemplars = v.exemplars;
|
||||||
|
flags = v.flags;
|
||||||
|
min = v.min;
|
||||||
|
max = v.max;
|
||||||
|
} : histogram_data_point)
|
||||||
|
|
||||||
|
let rec decode_json_histogram d =
|
||||||
|
let v = default_histogram () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("dataPoints", `List l) -> begin
|
||||||
|
histogram_set_data_points v @@ List.map (function
|
||||||
|
| json_value -> (decode_json_histogram_data_point json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
| ("aggregationTemporality", json_value) ->
|
||||||
|
histogram_set_aggregation_temporality v ((decode_json_aggregation_temporality json_value))
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
_presence = v._presence;
|
||||||
|
data_points = v.data_points;
|
||||||
|
aggregation_temporality = v.aggregation_temporality;
|
||||||
|
} : histogram)
|
||||||
|
|
||||||
|
let rec decode_json_exponential_histogram_data_point_buckets d =
|
||||||
|
let v = default_exponential_histogram_data_point_buckets () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("offset", json_value) ->
|
||||||
|
exponential_histogram_data_point_buckets_set_offset v (Pbrt_yojson.int32 json_value "exponential_histogram_data_point_buckets" "offset")
|
||||||
|
| ("bucketCounts", `List l) -> begin
|
||||||
|
exponential_histogram_data_point_buckets_set_bucket_counts v @@ List.map (function
|
||||||
|
| json_value -> Pbrt_yojson.int64 json_value "exponential_histogram_data_point_buckets" "bucket_counts"
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
_presence = v._presence;
|
||||||
|
offset = v.offset;
|
||||||
|
bucket_counts = v.bucket_counts;
|
||||||
|
} : exponential_histogram_data_point_buckets)
|
||||||
|
|
||||||
|
let rec decode_json_exponential_histogram_data_point d =
|
||||||
|
let v = default_exponential_histogram_data_point () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("attributes", `List l) -> begin
|
||||||
|
exponential_histogram_data_point_set_attributes v @@ List.map (function
|
||||||
|
| json_value -> (Common.decode_json_key_value json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
| ("startTimeUnixNano", json_value) ->
|
||||||
|
exponential_histogram_data_point_set_start_time_unix_nano v (Pbrt_yojson.int64 json_value "exponential_histogram_data_point" "start_time_unix_nano")
|
||||||
|
| ("timeUnixNano", json_value) ->
|
||||||
|
exponential_histogram_data_point_set_time_unix_nano v (Pbrt_yojson.int64 json_value "exponential_histogram_data_point" "time_unix_nano")
|
||||||
|
| ("count", json_value) ->
|
||||||
|
exponential_histogram_data_point_set_count v (Pbrt_yojson.int64 json_value "exponential_histogram_data_point" "count")
|
||||||
|
| ("sum", json_value) ->
|
||||||
|
exponential_histogram_data_point_set_sum v (Pbrt_yojson.float json_value "exponential_histogram_data_point" "sum")
|
||||||
|
| ("scale", json_value) ->
|
||||||
|
exponential_histogram_data_point_set_scale v (Pbrt_yojson.int32 json_value "exponential_histogram_data_point" "scale")
|
||||||
|
| ("zeroCount", json_value) ->
|
||||||
|
exponential_histogram_data_point_set_zero_count v (Pbrt_yojson.int64 json_value "exponential_histogram_data_point" "zero_count")
|
||||||
|
| ("positive", json_value) ->
|
||||||
|
exponential_histogram_data_point_set_positive v (decode_json_exponential_histogram_data_point_buckets json_value)
|
||||||
|
| ("negative", json_value) ->
|
||||||
|
exponential_histogram_data_point_set_negative v (decode_json_exponential_histogram_data_point_buckets json_value)
|
||||||
|
| ("flags", json_value) ->
|
||||||
|
exponential_histogram_data_point_set_flags v (Pbrt_yojson.int32 json_value "exponential_histogram_data_point" "flags")
|
||||||
|
| ("exemplars", `List l) -> begin
|
||||||
|
exponential_histogram_data_point_set_exemplars v @@ List.map (function
|
||||||
|
| json_value -> (decode_json_exemplar json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
| ("min", json_value) ->
|
||||||
|
exponential_histogram_data_point_set_min v (Pbrt_yojson.float json_value "exponential_histogram_data_point" "min")
|
||||||
|
| ("max", json_value) ->
|
||||||
|
exponential_histogram_data_point_set_max v (Pbrt_yojson.float json_value "exponential_histogram_data_point" "max")
|
||||||
|
| ("zeroThreshold", json_value) ->
|
||||||
|
exponential_histogram_data_point_set_zero_threshold v (Pbrt_yojson.float json_value "exponential_histogram_data_point" "zero_threshold")
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
_presence = v._presence;
|
||||||
|
attributes = v.attributes;
|
||||||
|
start_time_unix_nano = v.start_time_unix_nano;
|
||||||
|
time_unix_nano = v.time_unix_nano;
|
||||||
|
count = v.count;
|
||||||
|
sum = v.sum;
|
||||||
|
scale = v.scale;
|
||||||
|
zero_count = v.zero_count;
|
||||||
|
positive = v.positive;
|
||||||
|
negative = v.negative;
|
||||||
|
flags = v.flags;
|
||||||
|
exemplars = v.exemplars;
|
||||||
|
min = v.min;
|
||||||
|
max = v.max;
|
||||||
|
zero_threshold = v.zero_threshold;
|
||||||
|
} : exponential_histogram_data_point)
|
||||||
|
|
||||||
|
let rec decode_json_exponential_histogram d =
|
||||||
|
let v = default_exponential_histogram () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("dataPoints", `List l) -> begin
|
||||||
|
exponential_histogram_set_data_points v @@ List.map (function
|
||||||
|
| json_value -> (decode_json_exponential_histogram_data_point json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
| ("aggregationTemporality", json_value) ->
|
||||||
|
exponential_histogram_set_aggregation_temporality v ((decode_json_aggregation_temporality json_value))
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
_presence = v._presence;
|
||||||
|
data_points = v.data_points;
|
||||||
|
aggregation_temporality = v.aggregation_temporality;
|
||||||
|
} : exponential_histogram)
|
||||||
|
|
||||||
|
let rec decode_json_summary_data_point_value_at_quantile d =
|
||||||
|
let v = default_summary_data_point_value_at_quantile () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("quantile", json_value) ->
|
||||||
|
summary_data_point_value_at_quantile_set_quantile v (Pbrt_yojson.float json_value "summary_data_point_value_at_quantile" "quantile")
|
||||||
|
| ("value", json_value) ->
|
||||||
|
summary_data_point_value_at_quantile_set_value v (Pbrt_yojson.float json_value "summary_data_point_value_at_quantile" "value")
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
_presence = v._presence;
|
||||||
|
quantile = v.quantile;
|
||||||
|
value = v.value;
|
||||||
|
} : summary_data_point_value_at_quantile)
|
||||||
|
|
||||||
|
let rec decode_json_summary_data_point d =
|
||||||
|
let v = default_summary_data_point () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("attributes", `List l) -> begin
|
||||||
|
summary_data_point_set_attributes v @@ List.map (function
|
||||||
|
| json_value -> (Common.decode_json_key_value json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
| ("startTimeUnixNano", json_value) ->
|
||||||
|
summary_data_point_set_start_time_unix_nano v (Pbrt_yojson.int64 json_value "summary_data_point" "start_time_unix_nano")
|
||||||
|
| ("timeUnixNano", json_value) ->
|
||||||
|
summary_data_point_set_time_unix_nano v (Pbrt_yojson.int64 json_value "summary_data_point" "time_unix_nano")
|
||||||
|
| ("count", json_value) ->
|
||||||
|
summary_data_point_set_count v (Pbrt_yojson.int64 json_value "summary_data_point" "count")
|
||||||
|
| ("sum", json_value) ->
|
||||||
|
summary_data_point_set_sum v (Pbrt_yojson.float json_value "summary_data_point" "sum")
|
||||||
|
| ("quantileValues", `List l) -> begin
|
||||||
|
summary_data_point_set_quantile_values v @@ List.map (function
|
||||||
|
| json_value -> (decode_json_summary_data_point_value_at_quantile json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
| ("flags", json_value) ->
|
||||||
|
summary_data_point_set_flags v (Pbrt_yojson.int32 json_value "summary_data_point" "flags")
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
_presence = v._presence;
|
||||||
|
attributes = v.attributes;
|
||||||
|
start_time_unix_nano = v.start_time_unix_nano;
|
||||||
|
time_unix_nano = v.time_unix_nano;
|
||||||
|
count = v.count;
|
||||||
|
sum = v.sum;
|
||||||
|
quantile_values = v.quantile_values;
|
||||||
|
flags = v.flags;
|
||||||
|
} : summary_data_point)
|
||||||
|
|
||||||
|
let rec decode_json_summary d =
|
||||||
|
let v = default_summary () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("dataPoints", `List l) -> begin
|
||||||
|
summary_set_data_points v @@ List.map (function
|
||||||
|
| json_value -> (decode_json_summary_data_point json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
data_points = v.data_points;
|
||||||
|
} : summary)
|
||||||
|
|
||||||
|
let rec decode_json_metric_data json =
|
||||||
|
let assoc = match json with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
let rec loop = function
|
||||||
|
| [] -> Pbrt_yojson.E.malformed_variant "metric_data"
|
||||||
|
| ("gauge", json_value)::_ ->
|
||||||
|
(Gauge ((decode_json_gauge json_value)) : metric_data)
|
||||||
|
| ("sum", json_value)::_ ->
|
||||||
|
(Sum ((decode_json_sum json_value)) : metric_data)
|
||||||
|
| ("histogram", json_value)::_ ->
|
||||||
|
(Histogram ((decode_json_histogram json_value)) : metric_data)
|
||||||
|
| ("exponentialHistogram", json_value)::_ ->
|
||||||
|
(Exponential_histogram ((decode_json_exponential_histogram json_value)) : metric_data)
|
||||||
|
| ("summary", json_value)::_ ->
|
||||||
|
(Summary ((decode_json_summary json_value)) : metric_data)
|
||||||
|
|
||||||
|
| _ :: tl -> loop tl
|
||||||
|
in
|
||||||
|
loop assoc
|
||||||
|
|
||||||
|
and decode_json_metric d =
|
||||||
|
let v = default_metric () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("name", json_value) ->
|
||||||
|
metric_set_name v (Pbrt_yojson.string json_value "metric" "name")
|
||||||
|
| ("description", json_value) ->
|
||||||
|
metric_set_description v (Pbrt_yojson.string json_value "metric" "description")
|
||||||
|
| ("unit", json_value) ->
|
||||||
|
metric_set_unit_ v (Pbrt_yojson.string json_value "metric" "unit_")
|
||||||
|
| ("gauge", json_value) ->
|
||||||
|
metric_set_data v (Gauge ((decode_json_gauge json_value)))
|
||||||
|
| ("sum", json_value) ->
|
||||||
|
metric_set_data v (Sum ((decode_json_sum json_value)))
|
||||||
|
| ("histogram", json_value) ->
|
||||||
|
metric_set_data v (Histogram ((decode_json_histogram json_value)))
|
||||||
|
| ("exponentialHistogram", json_value) ->
|
||||||
|
metric_set_data v (Exponential_histogram ((decode_json_exponential_histogram json_value)))
|
||||||
|
| ("summary", json_value) ->
|
||||||
|
metric_set_data v (Summary ((decode_json_summary json_value)))
|
||||||
|
| ("metadata", `List l) -> begin
|
||||||
|
metric_set_metadata v @@ List.map (function
|
||||||
|
| json_value -> (Common.decode_json_key_value json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
_presence = v._presence;
|
||||||
|
name = v.name;
|
||||||
|
description = v.description;
|
||||||
|
unit_ = v.unit_;
|
||||||
|
data = v.data;
|
||||||
|
metadata = v.metadata;
|
||||||
|
} : metric)
|
||||||
|
|
||||||
|
let rec decode_json_scope_metrics d =
|
||||||
|
let v = default_scope_metrics () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("scope", json_value) ->
|
||||||
|
scope_metrics_set_scope v (Common.decode_json_instrumentation_scope json_value)
|
||||||
|
| ("metrics", `List l) -> begin
|
||||||
|
scope_metrics_set_metrics v @@ List.map (function
|
||||||
|
| json_value -> (decode_json_metric json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
| ("schemaUrl", json_value) ->
|
||||||
|
scope_metrics_set_schema_url v (Pbrt_yojson.string json_value "scope_metrics" "schema_url")
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
_presence = v._presence;
|
||||||
|
scope = v.scope;
|
||||||
|
metrics = v.metrics;
|
||||||
|
schema_url = v.schema_url;
|
||||||
|
} : scope_metrics)
|
||||||
|
|
||||||
|
let rec decode_json_resource_metrics d =
|
||||||
|
let v = default_resource_metrics () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("resource", json_value) ->
|
||||||
|
resource_metrics_set_resource v (Resource.decode_json_resource json_value)
|
||||||
|
| ("scopeMetrics", `List l) -> begin
|
||||||
|
resource_metrics_set_scope_metrics v @@ List.map (function
|
||||||
|
| json_value -> (decode_json_scope_metrics json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
| ("schemaUrl", json_value) ->
|
||||||
|
resource_metrics_set_schema_url v (Pbrt_yojson.string json_value "resource_metrics" "schema_url")
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
_presence = v._presence;
|
||||||
|
resource = v.resource;
|
||||||
|
scope_metrics = v.scope_metrics;
|
||||||
|
schema_url = v.schema_url;
|
||||||
|
} : resource_metrics)
|
||||||
|
|
||||||
|
let rec decode_json_metrics_data d =
|
||||||
|
let v = default_metrics_data () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("resourceMetrics", `List l) -> begin
|
||||||
|
metrics_data_set_resource_metrics v @@ List.map (function
|
||||||
|
| json_value -> (decode_json_resource_metrics json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
resource_metrics = v.resource_metrics;
|
||||||
|
} : metrics_data)
|
||||||
|
|
||||||
|
let rec decode_json_data_point_flags json =
|
||||||
|
match json with
|
||||||
|
| `String "DATA_POINT_FLAGS_DO_NOT_USE" -> (Data_point_flags_do_not_use : data_point_flags)
|
||||||
|
| `String "DATA_POINT_FLAGS_NO_RECORDED_VALUE_MASK" -> (Data_point_flags_no_recorded_value_mask : data_point_flags)
|
||||||
|
| _ -> Pbrt_yojson.E.malformed_variant "data_point_flags"
|
||||||
|
|
|
||||||
|
|
@ -930,3 +930,135 @@ val decode_pb_metrics_data : Pbrt.Decoder.t -> metrics_data
|
||||||
|
|
||||||
val decode_pb_data_point_flags : Pbrt.Decoder.t -> data_point_flags
|
val decode_pb_data_point_flags : Pbrt.Decoder.t -> data_point_flags
|
||||||
(** [decode_pb_data_point_flags decoder] decodes a [data_point_flags] binary value from [decoder] *)
|
(** [decode_pb_data_point_flags decoder] decodes a [data_point_flags] binary value from [decoder] *)
|
||||||
|
|
||||||
|
|
||||||
|
(** {2 Protobuf YoJson Encoding} *)
|
||||||
|
|
||||||
|
val encode_json_exemplar_value : exemplar_value -> Yojson.Basic.t
|
||||||
|
(** [encode_json_exemplar_value v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_exemplar : exemplar -> Yojson.Basic.t
|
||||||
|
(** [encode_json_exemplar v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_number_data_point_value : number_data_point_value -> Yojson.Basic.t
|
||||||
|
(** [encode_json_number_data_point_value v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_number_data_point : number_data_point -> Yojson.Basic.t
|
||||||
|
(** [encode_json_number_data_point v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_gauge : gauge -> Yojson.Basic.t
|
||||||
|
(** [encode_json_gauge v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_aggregation_temporality : aggregation_temporality -> Yojson.Basic.t
|
||||||
|
(** [encode_json_aggregation_temporality v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_sum : sum -> Yojson.Basic.t
|
||||||
|
(** [encode_json_sum v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_histogram_data_point : histogram_data_point -> Yojson.Basic.t
|
||||||
|
(** [encode_json_histogram_data_point v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_histogram : histogram -> Yojson.Basic.t
|
||||||
|
(** [encode_json_histogram v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_exponential_histogram_data_point_buckets : exponential_histogram_data_point_buckets -> Yojson.Basic.t
|
||||||
|
(** [encode_json_exponential_histogram_data_point_buckets v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_exponential_histogram_data_point : exponential_histogram_data_point -> Yojson.Basic.t
|
||||||
|
(** [encode_json_exponential_histogram_data_point v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_exponential_histogram : exponential_histogram -> Yojson.Basic.t
|
||||||
|
(** [encode_json_exponential_histogram v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_summary_data_point_value_at_quantile : summary_data_point_value_at_quantile -> Yojson.Basic.t
|
||||||
|
(** [encode_json_summary_data_point_value_at_quantile v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_summary_data_point : summary_data_point -> Yojson.Basic.t
|
||||||
|
(** [encode_json_summary_data_point v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_summary : summary -> Yojson.Basic.t
|
||||||
|
(** [encode_json_summary v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_metric_data : metric_data -> Yojson.Basic.t
|
||||||
|
(** [encode_json_metric_data v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_metric : metric -> Yojson.Basic.t
|
||||||
|
(** [encode_json_metric v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_scope_metrics : scope_metrics -> Yojson.Basic.t
|
||||||
|
(** [encode_json_scope_metrics v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_resource_metrics : resource_metrics -> Yojson.Basic.t
|
||||||
|
(** [encode_json_resource_metrics v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_metrics_data : metrics_data -> Yojson.Basic.t
|
||||||
|
(** [encode_json_metrics_data v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_data_point_flags : data_point_flags -> Yojson.Basic.t
|
||||||
|
(** [encode_json_data_point_flags v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
|
||||||
|
(** {2 JSON Decoding} *)
|
||||||
|
|
||||||
|
val decode_json_exemplar_value : Yojson.Basic.t -> exemplar_value
|
||||||
|
(** [decode_json_exemplar_value decoder] decodes a [exemplar_value] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_exemplar : Yojson.Basic.t -> exemplar
|
||||||
|
(** [decode_json_exemplar decoder] decodes a [exemplar] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_number_data_point_value : Yojson.Basic.t -> number_data_point_value
|
||||||
|
(** [decode_json_number_data_point_value decoder] decodes a [number_data_point_value] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_number_data_point : Yojson.Basic.t -> number_data_point
|
||||||
|
(** [decode_json_number_data_point decoder] decodes a [number_data_point] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_gauge : Yojson.Basic.t -> gauge
|
||||||
|
(** [decode_json_gauge decoder] decodes a [gauge] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_aggregation_temporality : Yojson.Basic.t -> aggregation_temporality
|
||||||
|
(** [decode_json_aggregation_temporality decoder] decodes a [aggregation_temporality] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_sum : Yojson.Basic.t -> sum
|
||||||
|
(** [decode_json_sum decoder] decodes a [sum] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_histogram_data_point : Yojson.Basic.t -> histogram_data_point
|
||||||
|
(** [decode_json_histogram_data_point decoder] decodes a [histogram_data_point] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_histogram : Yojson.Basic.t -> histogram
|
||||||
|
(** [decode_json_histogram decoder] decodes a [histogram] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_exponential_histogram_data_point_buckets : Yojson.Basic.t -> exponential_histogram_data_point_buckets
|
||||||
|
(** [decode_json_exponential_histogram_data_point_buckets decoder] decodes a [exponential_histogram_data_point_buckets] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_exponential_histogram_data_point : Yojson.Basic.t -> exponential_histogram_data_point
|
||||||
|
(** [decode_json_exponential_histogram_data_point decoder] decodes a [exponential_histogram_data_point] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_exponential_histogram : Yojson.Basic.t -> exponential_histogram
|
||||||
|
(** [decode_json_exponential_histogram decoder] decodes a [exponential_histogram] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_summary_data_point_value_at_quantile : Yojson.Basic.t -> summary_data_point_value_at_quantile
|
||||||
|
(** [decode_json_summary_data_point_value_at_quantile decoder] decodes a [summary_data_point_value_at_quantile] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_summary_data_point : Yojson.Basic.t -> summary_data_point
|
||||||
|
(** [decode_json_summary_data_point decoder] decodes a [summary_data_point] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_summary : Yojson.Basic.t -> summary
|
||||||
|
(** [decode_json_summary decoder] decodes a [summary] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_metric_data : Yojson.Basic.t -> metric_data
|
||||||
|
(** [decode_json_metric_data decoder] decodes a [metric_data] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_metric : Yojson.Basic.t -> metric
|
||||||
|
(** [decode_json_metric decoder] decodes a [metric] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_scope_metrics : Yojson.Basic.t -> scope_metrics
|
||||||
|
(** [decode_json_scope_metrics decoder] decodes a [scope_metrics] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_resource_metrics : Yojson.Basic.t -> resource_metrics
|
||||||
|
(** [decode_json_resource_metrics decoder] decodes a [resource_metrics] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_metrics_data : Yojson.Basic.t -> metrics_data
|
||||||
|
(** [decode_json_metrics_data decoder] decodes a [metrics_data] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_data_point_flags : Yojson.Basic.t -> data_point_flags
|
||||||
|
(** [decode_json_data_point_flags decoder] decodes a [data_point_flags] value from [decoder] *)
|
||||||
|
|
|
||||||
|
|
@ -200,3 +200,91 @@ let rec decode_pb_export_metrics_service_response d =
|
||||||
| Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind
|
| Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind
|
||||||
done;
|
done;
|
||||||
(v : export_metrics_service_response)
|
(v : export_metrics_service_response)
|
||||||
|
|
||||||
|
[@@@ocaml.warning "-23-27-30-39"]
|
||||||
|
|
||||||
|
(** {2 Protobuf YoJson Encoding} *)
|
||||||
|
|
||||||
|
let rec encode_json_export_metrics_service_request (v:export_metrics_service_request) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
assoc := (
|
||||||
|
let l = v.resource_metrics |> List.map Metrics.encode_json_resource_metrics in
|
||||||
|
("resourceMetrics", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_export_metrics_partial_success (v:export_metrics_partial_success) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
if export_metrics_partial_success_has_rejected_data_points v then (
|
||||||
|
assoc := ("rejectedDataPoints", Pbrt_yojson.make_string (Int64.to_string v.rejected_data_points)) :: !assoc;
|
||||||
|
);
|
||||||
|
if export_metrics_partial_success_has_error_message v then (
|
||||||
|
assoc := ("errorMessage", Pbrt_yojson.make_string v.error_message) :: !assoc;
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_export_metrics_service_response (v:export_metrics_service_response) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
assoc := (match v.partial_success with
|
||||||
|
| None -> !assoc
|
||||||
|
| Some v -> ("partialSuccess", encode_json_export_metrics_partial_success v) :: !assoc);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
[@@@ocaml.warning "-23-27-30-39"]
|
||||||
|
|
||||||
|
(** {2 JSON Decoding} *)
|
||||||
|
|
||||||
|
let rec decode_json_export_metrics_service_request d =
|
||||||
|
let v = default_export_metrics_service_request () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("resourceMetrics", `List l) -> begin
|
||||||
|
export_metrics_service_request_set_resource_metrics v @@ List.map (function
|
||||||
|
| json_value -> (Metrics.decode_json_resource_metrics json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
resource_metrics = v.resource_metrics;
|
||||||
|
} : export_metrics_service_request)
|
||||||
|
|
||||||
|
let rec decode_json_export_metrics_partial_success d =
|
||||||
|
let v = default_export_metrics_partial_success () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("rejectedDataPoints", json_value) ->
|
||||||
|
export_metrics_partial_success_set_rejected_data_points v (Pbrt_yojson.int64 json_value "export_metrics_partial_success" "rejected_data_points")
|
||||||
|
| ("errorMessage", json_value) ->
|
||||||
|
export_metrics_partial_success_set_error_message v (Pbrt_yojson.string json_value "export_metrics_partial_success" "error_message")
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
_presence = v._presence;
|
||||||
|
rejected_data_points = v.rejected_data_points;
|
||||||
|
error_message = v.error_message;
|
||||||
|
} : export_metrics_partial_success)
|
||||||
|
|
||||||
|
let rec decode_json_export_metrics_service_response d =
|
||||||
|
let v = default_export_metrics_service_response () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("partialSuccess", json_value) ->
|
||||||
|
export_metrics_service_response_set_partial_success v (decode_json_export_metrics_partial_success json_value)
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
partial_success = v.partial_success;
|
||||||
|
} : export_metrics_service_response)
|
||||||
|
|
|
||||||
|
|
@ -114,3 +114,27 @@ val decode_pb_export_metrics_partial_success : Pbrt.Decoder.t -> export_metrics_
|
||||||
|
|
||||||
val decode_pb_export_metrics_service_response : Pbrt.Decoder.t -> export_metrics_service_response
|
val decode_pb_export_metrics_service_response : Pbrt.Decoder.t -> export_metrics_service_response
|
||||||
(** [decode_pb_export_metrics_service_response decoder] decodes a [export_metrics_service_response] binary value from [decoder] *)
|
(** [decode_pb_export_metrics_service_response decoder] decodes a [export_metrics_service_response] binary value from [decoder] *)
|
||||||
|
|
||||||
|
|
||||||
|
(** {2 Protobuf YoJson Encoding} *)
|
||||||
|
|
||||||
|
val encode_json_export_metrics_service_request : export_metrics_service_request -> Yojson.Basic.t
|
||||||
|
(** [encode_json_export_metrics_service_request v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_export_metrics_partial_success : export_metrics_partial_success -> Yojson.Basic.t
|
||||||
|
(** [encode_json_export_metrics_partial_success v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_export_metrics_service_response : export_metrics_service_response -> Yojson.Basic.t
|
||||||
|
(** [encode_json_export_metrics_service_response v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
|
||||||
|
(** {2 JSON Decoding} *)
|
||||||
|
|
||||||
|
val decode_json_export_metrics_service_request : Yojson.Basic.t -> export_metrics_service_request
|
||||||
|
(** [decode_json_export_metrics_service_request decoder] decodes a [export_metrics_service_request] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_export_metrics_partial_success : Yojson.Basic.t -> export_metrics_partial_success
|
||||||
|
(** [decode_json_export_metrics_partial_success decoder] decodes a [export_metrics_partial_success] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_export_metrics_service_response : Yojson.Basic.t -> export_metrics_service_response
|
||||||
|
(** [decode_json_export_metrics_service_response decoder] decodes a [export_metrics_service_response] value from [decoder] *)
|
||||||
|
|
|
||||||
|
|
@ -106,3 +106,55 @@ let rec decode_pb_resource d =
|
||||||
| Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind
|
| Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind
|
||||||
done;
|
done;
|
||||||
(v : resource)
|
(v : resource)
|
||||||
|
|
||||||
|
[@@@ocaml.warning "-23-27-30-39"]
|
||||||
|
|
||||||
|
(** {2 Protobuf YoJson Encoding} *)
|
||||||
|
|
||||||
|
let rec encode_json_resource (v:resource) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
assoc := (
|
||||||
|
let l = v.attributes |> List.map Common.encode_json_key_value in
|
||||||
|
("attributes", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
if resource_has_dropped_attributes_count v then (
|
||||||
|
assoc := ("droppedAttributesCount", Pbrt_yojson.make_int (Int32.to_int v.dropped_attributes_count)) :: !assoc;
|
||||||
|
);
|
||||||
|
assoc := (
|
||||||
|
let l = v.entity_refs |> List.map Common.encode_json_entity_ref in
|
||||||
|
("entityRefs", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
[@@@ocaml.warning "-23-27-30-39"]
|
||||||
|
|
||||||
|
(** {2 JSON Decoding} *)
|
||||||
|
|
||||||
|
let rec decode_json_resource d =
|
||||||
|
let v = default_resource () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("attributes", `List l) -> begin
|
||||||
|
resource_set_attributes v @@ List.map (function
|
||||||
|
| json_value -> (Common.decode_json_key_value json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
| ("droppedAttributesCount", json_value) ->
|
||||||
|
resource_set_dropped_attributes_count v (Pbrt_yojson.int32 json_value "resource" "dropped_attributes_count")
|
||||||
|
| ("entityRefs", `List l) -> begin
|
||||||
|
resource_set_entity_refs v @@ List.map (function
|
||||||
|
| json_value -> (Common.decode_json_entity_ref json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
_presence = v._presence;
|
||||||
|
attributes = v.attributes;
|
||||||
|
dropped_attributes_count = v.dropped_attributes_count;
|
||||||
|
entity_refs = v.entity_refs;
|
||||||
|
} : resource)
|
||||||
|
|
|
||||||
|
|
@ -62,3 +62,15 @@ val encode_pb_resource : resource -> Pbrt.Encoder.t -> unit
|
||||||
|
|
||||||
val decode_pb_resource : Pbrt.Decoder.t -> resource
|
val decode_pb_resource : Pbrt.Decoder.t -> resource
|
||||||
(** [decode_pb_resource decoder] decodes a [resource] binary value from [decoder] *)
|
(** [decode_pb_resource decoder] decodes a [resource] binary value from [decoder] *)
|
||||||
|
|
||||||
|
|
||||||
|
(** {2 Protobuf YoJson Encoding} *)
|
||||||
|
|
||||||
|
val encode_json_resource : resource -> Yojson.Basic.t
|
||||||
|
(** [encode_json_resource v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
|
||||||
|
(** {2 JSON Decoding} *)
|
||||||
|
|
||||||
|
val decode_json_resource : Yojson.Basic.t -> resource
|
||||||
|
(** [decode_json_resource decoder] decodes a [resource] value from [decoder] *)
|
||||||
|
|
|
||||||
|
|
@ -108,3 +108,51 @@ let rec decode_pb_status d =
|
||||||
| Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind
|
| Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind
|
||||||
done;
|
done;
|
||||||
(v : status)
|
(v : status)
|
||||||
|
|
||||||
|
[@@@ocaml.warning "-23-27-30-39"]
|
||||||
|
|
||||||
|
(** {2 Protobuf YoJson Encoding} *)
|
||||||
|
|
||||||
|
let rec encode_json_status (v:status) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
if status_has_code v then (
|
||||||
|
assoc := ("code", Pbrt_yojson.make_int (Int32.to_int v.code)) :: !assoc;
|
||||||
|
);
|
||||||
|
if status_has_message v then (
|
||||||
|
assoc := ("message", Pbrt_yojson.make_bytes v.message) :: !assoc;
|
||||||
|
);
|
||||||
|
assoc := (
|
||||||
|
let l = v.details |> List.map Pbrt_yojson.make_bytes in
|
||||||
|
("details", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
[@@@ocaml.warning "-23-27-30-39"]
|
||||||
|
|
||||||
|
(** {2 JSON Decoding} *)
|
||||||
|
|
||||||
|
let rec decode_json_status d =
|
||||||
|
let v = default_status () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("code", json_value) ->
|
||||||
|
status_set_code v (Pbrt_yojson.int32 json_value "status" "code")
|
||||||
|
| ("message", json_value) ->
|
||||||
|
status_set_message v (Pbrt_yojson.bytes json_value "status" "message")
|
||||||
|
| ("details", `List l) -> begin
|
||||||
|
status_set_details v @@ List.map (function
|
||||||
|
| json_value -> Pbrt_yojson.bytes json_value "status" "details"
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
_presence = v._presence;
|
||||||
|
code = v.code;
|
||||||
|
message = v.message;
|
||||||
|
details = v.details;
|
||||||
|
} : status)
|
||||||
|
|
|
||||||
|
|
@ -65,3 +65,15 @@ val encode_pb_status : status -> Pbrt.Encoder.t -> unit
|
||||||
|
|
||||||
val decode_pb_status : Pbrt.Decoder.t -> status
|
val decode_pb_status : Pbrt.Decoder.t -> status
|
||||||
(** [decode_pb_status decoder] decodes a [status] binary value from [decoder] *)
|
(** [decode_pb_status decoder] decodes a [status] binary value from [decoder] *)
|
||||||
|
|
||||||
|
|
||||||
|
(** {2 Protobuf YoJson Encoding} *)
|
||||||
|
|
||||||
|
val encode_json_status : status -> Yojson.Basic.t
|
||||||
|
(** [encode_json_status v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
|
||||||
|
(** {2 JSON Decoding} *)
|
||||||
|
|
||||||
|
val decode_json_status : Yojson.Basic.t -> status
|
||||||
|
(** [decode_json_status decoder] decodes a [status] value from [decoder] *)
|
||||||
|
|
|
||||||
|
|
@ -1030,3 +1030,425 @@ let rec decode_pb_span_flags d : span_flags =
|
||||||
| 256 -> Span_flags_context_has_is_remote_mask
|
| 256 -> Span_flags_context_has_is_remote_mask
|
||||||
| 512 -> Span_flags_context_is_remote_mask
|
| 512 -> Span_flags_context_is_remote_mask
|
||||||
| _ -> Pbrt.Decoder.malformed_variant "span_flags"
|
| _ -> Pbrt.Decoder.malformed_variant "span_flags"
|
||||||
|
|
||||||
|
[@@@ocaml.warning "-23-27-30-39"]
|
||||||
|
|
||||||
|
(** {2 Protobuf YoJson Encoding} *)
|
||||||
|
|
||||||
|
let rec encode_json_span_span_kind (v:span_span_kind) =
|
||||||
|
match v with
|
||||||
|
| Span_kind_unspecified -> `String "SPAN_KIND_UNSPECIFIED"
|
||||||
|
| Span_kind_internal -> `String "SPAN_KIND_INTERNAL"
|
||||||
|
| Span_kind_server -> `String "SPAN_KIND_SERVER"
|
||||||
|
| Span_kind_client -> `String "SPAN_KIND_CLIENT"
|
||||||
|
| Span_kind_producer -> `String "SPAN_KIND_PRODUCER"
|
||||||
|
| Span_kind_consumer -> `String "SPAN_KIND_CONSUMER"
|
||||||
|
|
||||||
|
let rec encode_json_span_event (v:span_event) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
if span_event_has_time_unix_nano v then (
|
||||||
|
assoc := ("timeUnixNano", Pbrt_yojson.make_string (Int64.to_string v.time_unix_nano)) :: !assoc;
|
||||||
|
);
|
||||||
|
if span_event_has_name v then (
|
||||||
|
assoc := ("name", Pbrt_yojson.make_string v.name) :: !assoc;
|
||||||
|
);
|
||||||
|
assoc := (
|
||||||
|
let l = v.attributes |> List.map Common.encode_json_key_value in
|
||||||
|
("attributes", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
if span_event_has_dropped_attributes_count v then (
|
||||||
|
assoc := ("droppedAttributesCount", Pbrt_yojson.make_int (Int32.to_int v.dropped_attributes_count)) :: !assoc;
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_span_link (v:span_link) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
if span_link_has_trace_id v then (
|
||||||
|
assoc := ("traceId", Pbrt_yojson.make_bytes v.trace_id) :: !assoc;
|
||||||
|
);
|
||||||
|
if span_link_has_span_id v then (
|
||||||
|
assoc := ("spanId", Pbrt_yojson.make_bytes v.span_id) :: !assoc;
|
||||||
|
);
|
||||||
|
if span_link_has_trace_state v then (
|
||||||
|
assoc := ("traceState", Pbrt_yojson.make_string v.trace_state) :: !assoc;
|
||||||
|
);
|
||||||
|
assoc := (
|
||||||
|
let l = v.attributes |> List.map Common.encode_json_key_value in
|
||||||
|
("attributes", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
if span_link_has_dropped_attributes_count v then (
|
||||||
|
assoc := ("droppedAttributesCount", Pbrt_yojson.make_int (Int32.to_int v.dropped_attributes_count)) :: !assoc;
|
||||||
|
);
|
||||||
|
if span_link_has_flags v then (
|
||||||
|
assoc := ("flags", Pbrt_yojson.make_int (Int32.to_int v.flags)) :: !assoc;
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_status_status_code (v:status_status_code) =
|
||||||
|
match v with
|
||||||
|
| Status_code_unset -> `String "STATUS_CODE_UNSET"
|
||||||
|
| Status_code_ok -> `String "STATUS_CODE_OK"
|
||||||
|
| Status_code_error -> `String "STATUS_CODE_ERROR"
|
||||||
|
|
||||||
|
let rec encode_json_status (v:status) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
if status_has_message v then (
|
||||||
|
assoc := ("message", Pbrt_yojson.make_string v.message) :: !assoc;
|
||||||
|
);
|
||||||
|
if status_has_code v then (
|
||||||
|
assoc := ("code", encode_json_status_status_code v.code) :: !assoc;
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_span (v:span) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
if span_has_trace_id v then (
|
||||||
|
assoc := ("traceId", Pbrt_yojson.make_bytes v.trace_id) :: !assoc;
|
||||||
|
);
|
||||||
|
if span_has_span_id v then (
|
||||||
|
assoc := ("spanId", Pbrt_yojson.make_bytes v.span_id) :: !assoc;
|
||||||
|
);
|
||||||
|
if span_has_trace_state v then (
|
||||||
|
assoc := ("traceState", Pbrt_yojson.make_string v.trace_state) :: !assoc;
|
||||||
|
);
|
||||||
|
if span_has_parent_span_id v then (
|
||||||
|
assoc := ("parentSpanId", Pbrt_yojson.make_bytes v.parent_span_id) :: !assoc;
|
||||||
|
);
|
||||||
|
if span_has_flags v then (
|
||||||
|
assoc := ("flags", Pbrt_yojson.make_int (Int32.to_int v.flags)) :: !assoc;
|
||||||
|
);
|
||||||
|
if span_has_name v then (
|
||||||
|
assoc := ("name", Pbrt_yojson.make_string v.name) :: !assoc;
|
||||||
|
);
|
||||||
|
if span_has_kind v then (
|
||||||
|
assoc := ("kind", encode_json_span_span_kind v.kind) :: !assoc;
|
||||||
|
);
|
||||||
|
if span_has_start_time_unix_nano v then (
|
||||||
|
assoc := ("startTimeUnixNano", Pbrt_yojson.make_string (Int64.to_string v.start_time_unix_nano)) :: !assoc;
|
||||||
|
);
|
||||||
|
if span_has_end_time_unix_nano v then (
|
||||||
|
assoc := ("endTimeUnixNano", Pbrt_yojson.make_string (Int64.to_string v.end_time_unix_nano)) :: !assoc;
|
||||||
|
);
|
||||||
|
assoc := (
|
||||||
|
let l = v.attributes |> List.map Common.encode_json_key_value in
|
||||||
|
("attributes", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
if span_has_dropped_attributes_count v then (
|
||||||
|
assoc := ("droppedAttributesCount", Pbrt_yojson.make_int (Int32.to_int v.dropped_attributes_count)) :: !assoc;
|
||||||
|
);
|
||||||
|
assoc := (
|
||||||
|
let l = v.events |> List.map encode_json_span_event in
|
||||||
|
("events", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
if span_has_dropped_events_count v then (
|
||||||
|
assoc := ("droppedEventsCount", Pbrt_yojson.make_int (Int32.to_int v.dropped_events_count)) :: !assoc;
|
||||||
|
);
|
||||||
|
assoc := (
|
||||||
|
let l = v.links |> List.map encode_json_span_link in
|
||||||
|
("links", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
if span_has_dropped_links_count v then (
|
||||||
|
assoc := ("droppedLinksCount", Pbrt_yojson.make_int (Int32.to_int v.dropped_links_count)) :: !assoc;
|
||||||
|
);
|
||||||
|
assoc := (match v.status with
|
||||||
|
| None -> !assoc
|
||||||
|
| Some v -> ("status", encode_json_status v) :: !assoc);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_scope_spans (v:scope_spans) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
assoc := (match v.scope with
|
||||||
|
| None -> !assoc
|
||||||
|
| Some v -> ("scope", Common.encode_json_instrumentation_scope v) :: !assoc);
|
||||||
|
assoc := (
|
||||||
|
let l = v.spans |> List.map encode_json_span in
|
||||||
|
("spans", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
if scope_spans_has_schema_url v then (
|
||||||
|
assoc := ("schemaUrl", Pbrt_yojson.make_string v.schema_url) :: !assoc;
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_resource_spans (v:resource_spans) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
assoc := (match v.resource with
|
||||||
|
| None -> !assoc
|
||||||
|
| Some v -> ("resource", Resource.encode_json_resource v) :: !assoc);
|
||||||
|
assoc := (
|
||||||
|
let l = v.scope_spans |> List.map encode_json_scope_spans in
|
||||||
|
("scopeSpans", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
if resource_spans_has_schema_url v then (
|
||||||
|
assoc := ("schemaUrl", Pbrt_yojson.make_string v.schema_url) :: !assoc;
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_traces_data (v:traces_data) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
assoc := (
|
||||||
|
let l = v.resource_spans |> List.map encode_json_resource_spans in
|
||||||
|
("resourceSpans", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_span_flags (v:span_flags) =
|
||||||
|
match v with
|
||||||
|
| Span_flags_do_not_use -> `String "SPAN_FLAGS_DO_NOT_USE"
|
||||||
|
| Span_flags_trace_flags_mask -> `String "SPAN_FLAGS_TRACE_FLAGS_MASK"
|
||||||
|
| Span_flags_context_has_is_remote_mask -> `String "SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK"
|
||||||
|
| Span_flags_context_is_remote_mask -> `String "SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK"
|
||||||
|
|
||||||
|
[@@@ocaml.warning "-23-27-30-39"]
|
||||||
|
|
||||||
|
(** {2 JSON Decoding} *)
|
||||||
|
|
||||||
|
let rec decode_json_span_span_kind json =
|
||||||
|
match json with
|
||||||
|
| `String "SPAN_KIND_UNSPECIFIED" -> (Span_kind_unspecified : span_span_kind)
|
||||||
|
| `String "SPAN_KIND_INTERNAL" -> (Span_kind_internal : span_span_kind)
|
||||||
|
| `String "SPAN_KIND_SERVER" -> (Span_kind_server : span_span_kind)
|
||||||
|
| `String "SPAN_KIND_CLIENT" -> (Span_kind_client : span_span_kind)
|
||||||
|
| `String "SPAN_KIND_PRODUCER" -> (Span_kind_producer : span_span_kind)
|
||||||
|
| `String "SPAN_KIND_CONSUMER" -> (Span_kind_consumer : span_span_kind)
|
||||||
|
| _ -> Pbrt_yojson.E.malformed_variant "span_span_kind"
|
||||||
|
|
||||||
|
let rec decode_json_span_event d =
|
||||||
|
let v = default_span_event () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("timeUnixNano", json_value) ->
|
||||||
|
span_event_set_time_unix_nano v (Pbrt_yojson.int64 json_value "span_event" "time_unix_nano")
|
||||||
|
| ("name", json_value) ->
|
||||||
|
span_event_set_name v (Pbrt_yojson.string json_value "span_event" "name")
|
||||||
|
| ("attributes", `List l) -> begin
|
||||||
|
span_event_set_attributes v @@ List.map (function
|
||||||
|
| json_value -> (Common.decode_json_key_value json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
| ("droppedAttributesCount", json_value) ->
|
||||||
|
span_event_set_dropped_attributes_count v (Pbrt_yojson.int32 json_value "span_event" "dropped_attributes_count")
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
_presence = v._presence;
|
||||||
|
time_unix_nano = v.time_unix_nano;
|
||||||
|
name = v.name;
|
||||||
|
attributes = v.attributes;
|
||||||
|
dropped_attributes_count = v.dropped_attributes_count;
|
||||||
|
} : span_event)
|
||||||
|
|
||||||
|
let rec decode_json_span_link d =
|
||||||
|
let v = default_span_link () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("traceId", json_value) ->
|
||||||
|
span_link_set_trace_id v (Pbrt_yojson.bytes json_value "span_link" "trace_id")
|
||||||
|
| ("spanId", json_value) ->
|
||||||
|
span_link_set_span_id v (Pbrt_yojson.bytes json_value "span_link" "span_id")
|
||||||
|
| ("traceState", json_value) ->
|
||||||
|
span_link_set_trace_state v (Pbrt_yojson.string json_value "span_link" "trace_state")
|
||||||
|
| ("attributes", `List l) -> begin
|
||||||
|
span_link_set_attributes v @@ List.map (function
|
||||||
|
| json_value -> (Common.decode_json_key_value json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
| ("droppedAttributesCount", json_value) ->
|
||||||
|
span_link_set_dropped_attributes_count v (Pbrt_yojson.int32 json_value "span_link" "dropped_attributes_count")
|
||||||
|
| ("flags", json_value) ->
|
||||||
|
span_link_set_flags v (Pbrt_yojson.int32 json_value "span_link" "flags")
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
_presence = v._presence;
|
||||||
|
trace_id = v.trace_id;
|
||||||
|
span_id = v.span_id;
|
||||||
|
trace_state = v.trace_state;
|
||||||
|
attributes = v.attributes;
|
||||||
|
dropped_attributes_count = v.dropped_attributes_count;
|
||||||
|
flags = v.flags;
|
||||||
|
} : span_link)
|
||||||
|
|
||||||
|
let rec decode_json_status_status_code json =
|
||||||
|
match json with
|
||||||
|
| `String "STATUS_CODE_UNSET" -> (Status_code_unset : status_status_code)
|
||||||
|
| `String "STATUS_CODE_OK" -> (Status_code_ok : status_status_code)
|
||||||
|
| `String "STATUS_CODE_ERROR" -> (Status_code_error : status_status_code)
|
||||||
|
| _ -> Pbrt_yojson.E.malformed_variant "status_status_code"
|
||||||
|
|
||||||
|
let rec decode_json_status d =
|
||||||
|
let v = default_status () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("message", json_value) ->
|
||||||
|
status_set_message v (Pbrt_yojson.string json_value "status" "message")
|
||||||
|
| ("code", json_value) ->
|
||||||
|
status_set_code v ((decode_json_status_status_code json_value))
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
_presence = v._presence;
|
||||||
|
message = v.message;
|
||||||
|
code = v.code;
|
||||||
|
} : status)
|
||||||
|
|
||||||
|
let rec decode_json_span d =
|
||||||
|
let v = default_span () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("traceId", json_value) ->
|
||||||
|
span_set_trace_id v (Pbrt_yojson.bytes json_value "span" "trace_id")
|
||||||
|
| ("spanId", json_value) ->
|
||||||
|
span_set_span_id v (Pbrt_yojson.bytes json_value "span" "span_id")
|
||||||
|
| ("traceState", json_value) ->
|
||||||
|
span_set_trace_state v (Pbrt_yojson.string json_value "span" "trace_state")
|
||||||
|
| ("parentSpanId", json_value) ->
|
||||||
|
span_set_parent_span_id v (Pbrt_yojson.bytes json_value "span" "parent_span_id")
|
||||||
|
| ("flags", json_value) ->
|
||||||
|
span_set_flags v (Pbrt_yojson.int32 json_value "span" "flags")
|
||||||
|
| ("name", json_value) ->
|
||||||
|
span_set_name v (Pbrt_yojson.string json_value "span" "name")
|
||||||
|
| ("kind", json_value) ->
|
||||||
|
span_set_kind v ((decode_json_span_span_kind json_value))
|
||||||
|
| ("startTimeUnixNano", json_value) ->
|
||||||
|
span_set_start_time_unix_nano v (Pbrt_yojson.int64 json_value "span" "start_time_unix_nano")
|
||||||
|
| ("endTimeUnixNano", json_value) ->
|
||||||
|
span_set_end_time_unix_nano v (Pbrt_yojson.int64 json_value "span" "end_time_unix_nano")
|
||||||
|
| ("attributes", `List l) -> begin
|
||||||
|
span_set_attributes v @@ List.map (function
|
||||||
|
| json_value -> (Common.decode_json_key_value json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
| ("droppedAttributesCount", json_value) ->
|
||||||
|
span_set_dropped_attributes_count v (Pbrt_yojson.int32 json_value "span" "dropped_attributes_count")
|
||||||
|
| ("events", `List l) -> begin
|
||||||
|
span_set_events v @@ List.map (function
|
||||||
|
| json_value -> (decode_json_span_event json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
| ("droppedEventsCount", json_value) ->
|
||||||
|
span_set_dropped_events_count v (Pbrt_yojson.int32 json_value "span" "dropped_events_count")
|
||||||
|
| ("links", `List l) -> begin
|
||||||
|
span_set_links v @@ List.map (function
|
||||||
|
| json_value -> (decode_json_span_link json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
| ("droppedLinksCount", json_value) ->
|
||||||
|
span_set_dropped_links_count v (Pbrt_yojson.int32 json_value "span" "dropped_links_count")
|
||||||
|
| ("status", json_value) ->
|
||||||
|
span_set_status v (decode_json_status json_value)
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
_presence = v._presence;
|
||||||
|
trace_id = v.trace_id;
|
||||||
|
span_id = v.span_id;
|
||||||
|
trace_state = v.trace_state;
|
||||||
|
parent_span_id = v.parent_span_id;
|
||||||
|
flags = v.flags;
|
||||||
|
name = v.name;
|
||||||
|
kind = v.kind;
|
||||||
|
start_time_unix_nano = v.start_time_unix_nano;
|
||||||
|
end_time_unix_nano = v.end_time_unix_nano;
|
||||||
|
attributes = v.attributes;
|
||||||
|
dropped_attributes_count = v.dropped_attributes_count;
|
||||||
|
events = v.events;
|
||||||
|
dropped_events_count = v.dropped_events_count;
|
||||||
|
links = v.links;
|
||||||
|
dropped_links_count = v.dropped_links_count;
|
||||||
|
status = v.status;
|
||||||
|
} : span)
|
||||||
|
|
||||||
|
let rec decode_json_scope_spans d =
|
||||||
|
let v = default_scope_spans () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("scope", json_value) ->
|
||||||
|
scope_spans_set_scope v (Common.decode_json_instrumentation_scope json_value)
|
||||||
|
| ("spans", `List l) -> begin
|
||||||
|
scope_spans_set_spans v @@ List.map (function
|
||||||
|
| json_value -> (decode_json_span json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
| ("schemaUrl", json_value) ->
|
||||||
|
scope_spans_set_schema_url v (Pbrt_yojson.string json_value "scope_spans" "schema_url")
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
_presence = v._presence;
|
||||||
|
scope = v.scope;
|
||||||
|
spans = v.spans;
|
||||||
|
schema_url = v.schema_url;
|
||||||
|
} : scope_spans)
|
||||||
|
|
||||||
|
let rec decode_json_resource_spans d =
|
||||||
|
let v = default_resource_spans () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("resource", json_value) ->
|
||||||
|
resource_spans_set_resource v (Resource.decode_json_resource json_value)
|
||||||
|
| ("scopeSpans", `List l) -> begin
|
||||||
|
resource_spans_set_scope_spans v @@ List.map (function
|
||||||
|
| json_value -> (decode_json_scope_spans json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
| ("schemaUrl", json_value) ->
|
||||||
|
resource_spans_set_schema_url v (Pbrt_yojson.string json_value "resource_spans" "schema_url")
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
_presence = v._presence;
|
||||||
|
resource = v.resource;
|
||||||
|
scope_spans = v.scope_spans;
|
||||||
|
schema_url = v.schema_url;
|
||||||
|
} : resource_spans)
|
||||||
|
|
||||||
|
let rec decode_json_traces_data d =
|
||||||
|
let v = default_traces_data () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("resourceSpans", `List l) -> begin
|
||||||
|
traces_data_set_resource_spans v @@ List.map (function
|
||||||
|
| json_value -> (decode_json_resource_spans json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
resource_spans = v.resource_spans;
|
||||||
|
} : traces_data)
|
||||||
|
|
||||||
|
let rec decode_json_span_flags json =
|
||||||
|
match json with
|
||||||
|
| `String "SPAN_FLAGS_DO_NOT_USE" -> (Span_flags_do_not_use : span_flags)
|
||||||
|
| `String "SPAN_FLAGS_TRACE_FLAGS_MASK" -> (Span_flags_trace_flags_mask : span_flags)
|
||||||
|
| `String "SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK" -> (Span_flags_context_has_is_remote_mask : span_flags)
|
||||||
|
| `String "SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK" -> (Span_flags_context_is_remote_mask : span_flags)
|
||||||
|
| _ -> Pbrt_yojson.E.malformed_variant "span_flags"
|
||||||
|
|
|
||||||
|
|
@ -483,3 +483,69 @@ val decode_pb_traces_data : Pbrt.Decoder.t -> traces_data
|
||||||
|
|
||||||
val decode_pb_span_flags : Pbrt.Decoder.t -> span_flags
|
val decode_pb_span_flags : Pbrt.Decoder.t -> span_flags
|
||||||
(** [decode_pb_span_flags decoder] decodes a [span_flags] binary value from [decoder] *)
|
(** [decode_pb_span_flags decoder] decodes a [span_flags] binary value from [decoder] *)
|
||||||
|
|
||||||
|
|
||||||
|
(** {2 Protobuf YoJson Encoding} *)
|
||||||
|
|
||||||
|
val encode_json_span_span_kind : span_span_kind -> Yojson.Basic.t
|
||||||
|
(** [encode_json_span_span_kind v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_span_event : span_event -> Yojson.Basic.t
|
||||||
|
(** [encode_json_span_event v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_span_link : span_link -> Yojson.Basic.t
|
||||||
|
(** [encode_json_span_link v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_status_status_code : status_status_code -> Yojson.Basic.t
|
||||||
|
(** [encode_json_status_status_code v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_status : status -> Yojson.Basic.t
|
||||||
|
(** [encode_json_status v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_span : span -> Yojson.Basic.t
|
||||||
|
(** [encode_json_span v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_scope_spans : scope_spans -> Yojson.Basic.t
|
||||||
|
(** [encode_json_scope_spans v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_resource_spans : resource_spans -> Yojson.Basic.t
|
||||||
|
(** [encode_json_resource_spans v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_traces_data : traces_data -> Yojson.Basic.t
|
||||||
|
(** [encode_json_traces_data v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_span_flags : span_flags -> Yojson.Basic.t
|
||||||
|
(** [encode_json_span_flags v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
|
||||||
|
(** {2 JSON Decoding} *)
|
||||||
|
|
||||||
|
val decode_json_span_span_kind : Yojson.Basic.t -> span_span_kind
|
||||||
|
(** [decode_json_span_span_kind decoder] decodes a [span_span_kind] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_span_event : Yojson.Basic.t -> span_event
|
||||||
|
(** [decode_json_span_event decoder] decodes a [span_event] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_span_link : Yojson.Basic.t -> span_link
|
||||||
|
(** [decode_json_span_link decoder] decodes a [span_link] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_status_status_code : Yojson.Basic.t -> status_status_code
|
||||||
|
(** [decode_json_status_status_code decoder] decodes a [status_status_code] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_status : Yojson.Basic.t -> status
|
||||||
|
(** [decode_json_status decoder] decodes a [status] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_span : Yojson.Basic.t -> span
|
||||||
|
(** [decode_json_span decoder] decodes a [span] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_scope_spans : Yojson.Basic.t -> scope_spans
|
||||||
|
(** [decode_json_scope_spans decoder] decodes a [scope_spans] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_resource_spans : Yojson.Basic.t -> resource_spans
|
||||||
|
(** [decode_json_resource_spans decoder] decodes a [resource_spans] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_traces_data : Yojson.Basic.t -> traces_data
|
||||||
|
(** [decode_json_traces_data decoder] decodes a [traces_data] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_span_flags : Yojson.Basic.t -> span_flags
|
||||||
|
(** [decode_json_span_flags decoder] decodes a [span_flags] value from [decoder] *)
|
||||||
|
|
|
||||||
|
|
@ -200,3 +200,91 @@ let rec decode_pb_export_trace_service_response d =
|
||||||
| Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind
|
| Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind
|
||||||
done;
|
done;
|
||||||
(v : export_trace_service_response)
|
(v : export_trace_service_response)
|
||||||
|
|
||||||
|
[@@@ocaml.warning "-23-27-30-39"]
|
||||||
|
|
||||||
|
(** {2 Protobuf YoJson Encoding} *)
|
||||||
|
|
||||||
|
let rec encode_json_export_trace_service_request (v:export_trace_service_request) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
assoc := (
|
||||||
|
let l = v.resource_spans |> List.map Trace.encode_json_resource_spans in
|
||||||
|
("resourceSpans", `List l) :: !assoc
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_export_trace_partial_success (v:export_trace_partial_success) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
if export_trace_partial_success_has_rejected_spans v then (
|
||||||
|
assoc := ("rejectedSpans", Pbrt_yojson.make_string (Int64.to_string v.rejected_spans)) :: !assoc;
|
||||||
|
);
|
||||||
|
if export_trace_partial_success_has_error_message v then (
|
||||||
|
assoc := ("errorMessage", Pbrt_yojson.make_string v.error_message) :: !assoc;
|
||||||
|
);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
let rec encode_json_export_trace_service_response (v:export_trace_service_response) =
|
||||||
|
let assoc = ref [] in
|
||||||
|
assoc := (match v.partial_success with
|
||||||
|
| None -> !assoc
|
||||||
|
| Some v -> ("partialSuccess", encode_json_export_trace_partial_success v) :: !assoc);
|
||||||
|
`Assoc !assoc
|
||||||
|
|
||||||
|
[@@@ocaml.warning "-23-27-30-39"]
|
||||||
|
|
||||||
|
(** {2 JSON Decoding} *)
|
||||||
|
|
||||||
|
let rec decode_json_export_trace_service_request d =
|
||||||
|
let v = default_export_trace_service_request () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("resourceSpans", `List l) -> begin
|
||||||
|
export_trace_service_request_set_resource_spans v @@ List.map (function
|
||||||
|
| json_value -> (Trace.decode_json_resource_spans json_value)
|
||||||
|
) l;
|
||||||
|
end
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
resource_spans = v.resource_spans;
|
||||||
|
} : export_trace_service_request)
|
||||||
|
|
||||||
|
let rec decode_json_export_trace_partial_success d =
|
||||||
|
let v = default_export_trace_partial_success () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("rejectedSpans", json_value) ->
|
||||||
|
export_trace_partial_success_set_rejected_spans v (Pbrt_yojson.int64 json_value "export_trace_partial_success" "rejected_spans")
|
||||||
|
| ("errorMessage", json_value) ->
|
||||||
|
export_trace_partial_success_set_error_message v (Pbrt_yojson.string json_value "export_trace_partial_success" "error_message")
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
_presence = v._presence;
|
||||||
|
rejected_spans = v.rejected_spans;
|
||||||
|
error_message = v.error_message;
|
||||||
|
} : export_trace_partial_success)
|
||||||
|
|
||||||
|
let rec decode_json_export_trace_service_response d =
|
||||||
|
let v = default_export_trace_service_response () in
|
||||||
|
let assoc = match d with
|
||||||
|
| `Assoc assoc -> assoc
|
||||||
|
| _ -> assert(false)
|
||||||
|
in
|
||||||
|
List.iter (function
|
||||||
|
| ("partialSuccess", json_value) ->
|
||||||
|
export_trace_service_response_set_partial_success v (decode_json_export_trace_partial_success json_value)
|
||||||
|
|
||||||
|
| (_, _) -> () (*Unknown fields are ignored*)
|
||||||
|
) assoc;
|
||||||
|
({
|
||||||
|
partial_success = v.partial_success;
|
||||||
|
} : export_trace_service_response)
|
||||||
|
|
|
||||||
|
|
@ -114,3 +114,27 @@ val decode_pb_export_trace_partial_success : Pbrt.Decoder.t -> export_trace_part
|
||||||
|
|
||||||
val decode_pb_export_trace_service_response : Pbrt.Decoder.t -> export_trace_service_response
|
val decode_pb_export_trace_service_response : Pbrt.Decoder.t -> export_trace_service_response
|
||||||
(** [decode_pb_export_trace_service_response decoder] decodes a [export_trace_service_response] binary value from [decoder] *)
|
(** [decode_pb_export_trace_service_response decoder] decodes a [export_trace_service_response] binary value from [decoder] *)
|
||||||
|
|
||||||
|
|
||||||
|
(** {2 Protobuf YoJson Encoding} *)
|
||||||
|
|
||||||
|
val encode_json_export_trace_service_request : export_trace_service_request -> Yojson.Basic.t
|
||||||
|
(** [encode_json_export_trace_service_request v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_export_trace_partial_success : export_trace_partial_success -> Yojson.Basic.t
|
||||||
|
(** [encode_json_export_trace_partial_success v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
val encode_json_export_trace_service_response : export_trace_service_response -> Yojson.Basic.t
|
||||||
|
(** [encode_json_export_trace_service_response v encoder] encodes [v] to to json *)
|
||||||
|
|
||||||
|
|
||||||
|
(** {2 JSON Decoding} *)
|
||||||
|
|
||||||
|
val decode_json_export_trace_service_request : Yojson.Basic.t -> export_trace_service_request
|
||||||
|
(** [decode_json_export_trace_service_request decoder] decodes a [export_trace_service_request] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_export_trace_partial_success : Yojson.Basic.t -> export_trace_partial_success
|
||||||
|
(** [decode_json_export_trace_partial_success decoder] decodes a [export_trace_partial_success] value from [decoder] *)
|
||||||
|
|
||||||
|
val decode_json_export_trace_service_response : Yojson.Basic.t -> export_trace_service_response
|
||||||
|
(** [decode_json_export_trace_service_response decoder] decodes a [export_trace_service_response] value from [decoder] *)
|
||||||
|
|
|
||||||
|
|
@ -36,9 +36,9 @@ open struct
|
||||||
(* sanity check: otrace meta-map must be the same as hmap *)
|
(* sanity check: otrace meta-map must be the same as hmap *)
|
||||||
let () = ignore (fun (k : _ Hmap.key) : _ Ambient_context.Context.key -> k)
|
let () = ignore (fun (k : _ Hmap.key) : _ Ambient_context.Context.key -> k)
|
||||||
|
|
||||||
(** Key to access the current span context. *)
|
(** Key to access the current span context. Uses the shared key from core. *)
|
||||||
let k_span_ctx : OTEL.Span_ctx.t Ambient_context.Context.key =
|
let k_span_ctx : OTEL.Span_ctx.t Ambient_context.Context.key =
|
||||||
Ambient_context.Context.new_key ()
|
OTEL.Span_ctx.k_ambient
|
||||||
|
|
||||||
let enter_span (self : state) ~__FUNCTION__ ~__FILE__ ~__LINE__ ~level:_
|
let enter_span (self : state) ~__FUNCTION__ ~__FILE__ ~__LINE__ ~level:_
|
||||||
~params:_ ~(data : (_ * Otrace.user_data) list) ~parent name : Otrace.span
|
~params:_ ~(data : (_ * Otrace.user_data) list) ~parent name : Otrace.span
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,9 @@ let test_config_printing () =
|
||||||
\ timeout_ms=10000; timeout_traces_ms=10000; timeout_metrics_ms=10000;\n\
|
\ timeout_ms=10000; timeout_traces_ms=10000; timeout_metrics_ms=10000;\n\
|
||||||
\ timeout_logs_ms=10000; batch_traces=400; batch_metrics=200; \
|
\ timeout_logs_ms=10000; batch_traces=400; batch_metrics=200; \
|
||||||
batch_logs=400;\n\
|
batch_logs=400;\n\
|
||||||
\ batch_timeout_ms=2000; http_concurrency_level=None }"
|
\ batch_timeout_ms=2000; http_concurrency_level=None; retry_max_attempts=3;\n\
|
||||||
|
\ retry_initial_delay_ms=100; retry_max_delay_ms=5000;\n\
|
||||||
|
\ retry_backoff_multiplier=2.0 }"
|
||||||
in
|
in
|
||||||
check' string ~msg:"is rendered correctly" ~actual ~expected
|
check' string ~msg:"is rendered correctly" ~actual ~expected
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue