From f63df22c2e21d95d88271604418027d2f12a7ebe Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Mon, 11 Dec 2023 16:51:49 -0500 Subject: [PATCH] use ocaml-protoc 3.0.1 for codegen --- .../opentelemetry_client_cohttp_lwt.ml | 8 +- .../opentelemetry_client_ocurl.ml | 8 +- src/core/opentelemetry.ml | 78 +++---------------- src/proto/common.mli | 3 - src/proto/logs.mli | 3 - src/proto/logs_service.ml | 45 ----------- src/proto/logs_service.mli | 21 ----- src/proto/metrics.mli | 3 - src/proto/metrics_service.ml | 45 ----------- src/proto/metrics_service.mli | 21 ----- src/proto/resource.mli | 3 - src/proto/status.mli | 3 - src/proto/trace.mli | 3 - src/proto/trace_service.ml | 45 ----------- src/proto/trace_service.mli | 21 ----- 15 files changed, 19 insertions(+), 291 deletions(-) diff --git a/src/client-cohttp-lwt/opentelemetry_client_cohttp_lwt.ml b/src/client-cohttp-lwt/opentelemetry_client_cohttp_lwt.ml index d86e5279..5b4f0453 100644 --- a/src/client-cohttp-lwt/opentelemetry_client_cohttp_lwt.ml +++ b/src/client-cohttp-lwt/opentelemetry_client_cohttp_lwt.ml @@ -147,7 +147,7 @@ end = struct let r = try - let status = Status.decode_status dec in + let status = Status.decode_pb_status dec in Error (`Status (code, status)) with e -> let bt = Printexc.get_backtrace () in @@ -318,7 +318,7 @@ let mk_emitter ~stop ~(config : Config.t) () : (module EMITTER) = ~resource_metrics:l () in send_http_ curl encoder ~path:"/v1/metrics" - ~encode:Metrics_service.encode_export_metrics_service_request x + ~encode:Metrics_service.encode_pb_export_metrics_service_request x let send_traces_http curl encoder (l : Trace.resource_spans list list) = let l = List.fold_left (fun acc l -> List.rev_append l acc) [] l in @@ -326,7 +326,7 @@ let mk_emitter ~stop ~(config : Config.t) () : (module EMITTER) = Trace_service.default_export_trace_service_request ~resource_spans:l () in send_http_ curl encoder ~path:"/v1/traces" - ~encode:Trace_service.encode_export_trace_service_request x + ~encode:Trace_service.encode_pb_export_trace_service_request x let send_logs_http curl encoder (l : Logs.resource_logs list list) = let l = List.fold_left (fun acc l -> List.rev_append l acc) [] l in @@ -334,7 +334,7 @@ let mk_emitter ~stop ~(config : Config.t) () : (module EMITTER) = Logs_service.default_export_logs_service_request ~resource_logs:l () in send_http_ curl encoder ~path:"/v1/logs" - ~encode:Logs_service.encode_export_logs_service_request x + ~encode:Logs_service.encode_pb_export_logs_service_request x (* emit metrics, if the batch is full or timeout lapsed *) let emit_metrics_maybe ~now ?force httpc encoder : bool Lwt.t = diff --git a/src/client-ocurl/opentelemetry_client_ocurl.ml b/src/client-ocurl/opentelemetry_client_ocurl.ml index c8396d06..29e11fa4 100644 --- a/src/client-ocurl/opentelemetry_client_ocurl.ml +++ b/src/client-ocurl/opentelemetry_client_ocurl.ml @@ -147,7 +147,7 @@ end = struct let dec = Pbrt.Decoder.of_string body in let body = try - let status = Status.decode_status dec in + let status = Status.decode_pb_status dec in Format.asprintf "%a" Status.pp_status status with _ -> spf "(could not decode status)\nraw bytes: %s" (str_to_hex body) @@ -175,7 +175,7 @@ end = struct Logs_service.default_export_logs_service_request ~resource_logs:l () in send_http_ ~stop ~config client encoder ~path:"/v1/logs" - ~encode:Logs_service.encode_export_logs_service_request x + ~encode:Logs_service.encode_pb_export_logs_service_request x let send_metrics_http ~stop ~config curl encoder (l : Metrics.resource_metrics list list) : unit = @@ -185,7 +185,7 @@ end = struct () in send_http_ ~stop ~config curl encoder ~path:"/v1/metrics" - ~encode:Metrics_service.encode_export_metrics_service_request x + ~encode:Metrics_service.encode_pb_export_metrics_service_request x let send_traces_http ~stop ~config curl encoder (l : Trace.resource_spans list list) : unit = @@ -194,7 +194,7 @@ end = struct Trace_service.default_export_trace_service_request ~resource_spans:l () in send_http_ ~stop ~config curl encoder ~path:"/v1/traces" - ~encode:Trace_service.encode_export_trace_service_request x + ~encode:Trace_service.encode_pb_export_trace_service_request x let[@inline] send_event (self : t) ev : unit = B_queue.push self.q ev diff --git a/src/core/opentelemetry.ml b/src/core/opentelemetry.ml index 983ca128..cc5186e2 100644 --- a/src/core/opentelemetry.ml +++ b/src/core/opentelemetry.ml @@ -15,66 +15,10 @@ end (** {2 Wire format} *) +module Proto = Opentelemetry_proto (** Protobuf types. This is mostly useful internally. Users should not need to touch it. *) -module Proto = struct - open Opentelemetry_proto - - module Common = struct - include Common_types - include Common_pp - include Common_pb - end - - module Resource = struct - include Resource_types - include Resource_pp - include Resource_pb - end - - module Trace = struct - include Trace_types - include Trace_pp - include Trace_pb - end - - module Metrics = struct - include Metrics_types - include Metrics_pp - include Metrics_pb - end - - module Trace_service = struct - include Trace_service_types - include Trace_service_pb - include Trace_service_pp - end - - module Metrics_service = struct - include Metrics_service_types - include Metrics_service_pp - include Metrics_service_pb - end - - module Status = struct - include Status_types - include Status_pp - include Status_pb - end - - module Logs = struct - include Logs_types - include Logs_pb - include Logs_pp - end - - module Logs_service = struct - include Logs_service_types - include Logs_service_pb - include Logs_service_pp - end -end (** {2 Timestamps} *) @@ -105,7 +49,7 @@ end Note: most users will not need to touch this module *) module Collector = struct - open Proto + open Opentelemetry_proto type 'msg sender = { send: 'a. 'msg -> ret:(unit -> 'a) -> 'a } (** Sender interface for a message of type [msg]. @@ -889,10 +833,10 @@ end See {{: https://opentelemetry.io/docs/reference/specification/overview/#metric-signal} the spec} *) module Metrics = struct - open Opentelemetry_proto - open Metrics_types + open Proto + open Proto.Metrics - type t = Metrics_types.metric + type t = Metrics.metric (** A single metric, measuring some time-varying quantity or statistical distribution. It is composed of one or more data points that have precise values and time stamps. Each distinct metric should have a @@ -925,7 +869,7 @@ module Metrics = struct let data = Gauge (default_gauge ~data_points:l ()) in default_metric ~name ?description ?unit_ ~data () - type aggregation_temporality = Metrics_types.aggregation_temporality = + type aggregation_temporality = Metrics.aggregation_temporality = | Aggregation_temporality_unspecified | Aggregation_temporality_delta | Aggregation_temporality_cumulative @@ -993,12 +937,12 @@ end See {{: https://opentelemetry.io/docs/reference/specification/overview/#log-signal} the spec} *) module Logs = struct open Opentelemetry_proto - open Logs_types + open Logs type t = log_record (** Severity level of a log event *) - type severity = Logs_types.severity_number = + type severity = Logs.severity_number = | Severity_number_unspecified | Severity_number_trace | Severity_number_trace2 @@ -1025,13 +969,13 @@ module Logs = struct | Severity_number_fatal3 | Severity_number_fatal4 - let pp_severity = Logs_pp.pp_severity_number + let pp_severity = Logs.pp_severity_number - type flags = Logs_types.log_record_flags = + type flags = Logs.log_record_flags = | Log_record_flags_do_not_use | Log_record_flags_trace_flags_mask - let pp_flags = Logs_pp.pp_log_record_flags + let pp_flags = Logs.pp_log_record_flags (** Make a single log entry *) let make ?time ?(observed_time_unix_nano = Timestamp_ns.now_unix_ns ()) diff --git a/src/proto/common.mli b/src/proto/common.mli index fcbc7999..eb1114cd 100644 --- a/src/proto/common.mli +++ b/src/proto/common.mli @@ -155,6 +155,3 @@ val decode_pb_key_value : Pbrt.Decoder.t -> key_value val decode_pb_instrumentation_scope : Pbrt.Decoder.t -> instrumentation_scope (** [decode_pb_instrumentation_scope decoder] decodes a [instrumentation_scope] binary value from [decoder] *) - - -(** {2 Services} *) diff --git a/src/proto/logs.mli b/src/proto/logs.mli index f1a17d69..84dd9c0c 100644 --- a/src/proto/logs.mli +++ b/src/proto/logs.mli @@ -217,6 +217,3 @@ val decode_pb_logs_data : Pbrt.Decoder.t -> logs_data val decode_pb_log_record_flags : Pbrt.Decoder.t -> log_record_flags (** [decode_pb_log_record_flags decoder] decodes a [log_record_flags] binary value from [decoder] *) - - -(** {2 Services} *) diff --git a/src/proto/logs_service.ml b/src/proto/logs_service.ml index 7958071b..8e271c59 100644 --- a/src/proto/logs_service.ml +++ b/src/proto/logs_service.ml @@ -196,48 +196,3 @@ let rec decode_pb_export_logs_service_response d = ({ partial_success = v.partial_success; } : export_logs_service_response) - -module LogsService = struct - open Pbrt_services.Value_mode - module Client = struct - open Pbrt_services - - let export : (export_logs_service_request, unary, export_logs_service_response, unary) Client.rpc = - (Client.mk_rpc - ~package:["opentelemetry";"proto";"collector";"logs";"v1"] - ~service_name:"LogsService" ~rpc_name:"Export" - ~req_mode:Client.Unary - ~res_mode:Client.Unary - ~encode_json_req:encode_json_export_logs_service_request - ~encode_pb_req:encode_pb_export_logs_service_request - ~decode_json_res:decode_json_export_logs_service_response - ~decode_pb_res:decode_pb_export_logs_service_response - () : (export_logs_service_request, unary, export_logs_service_response, unary) Client.rpc) - end - - module Server = struct - open Pbrt_services - - let _rpc_export : (export_logs_service_request,unary,export_logs_service_response,unary) Server.rpc = - (Server.mk_rpc ~name:"Export" - ~req_mode:Server.Unary - ~res_mode:Server.Unary - ~encode_json_res:encode_json_export_logs_service_response - ~encode_pb_res:encode_pb_export_logs_service_response - ~decode_json_req:decode_json_export_logs_service_request - ~decode_pb_req:decode_pb_export_logs_service_request - () : _ Server.rpc) - - let make - ~export - () : _ Server.t = - { Server. - service_name="LogsService"; - package=["opentelemetry";"proto";"collector";"logs";"v1"]; - handlers=[ - (export _rpc_export); - ]; - } - end - -end diff --git a/src/proto/logs_service.mli b/src/proto/logs_service.mli index cb477313..5e3f24d9 100644 --- a/src/proto/logs_service.mli +++ b/src/proto/logs_service.mli @@ -99,24 +99,3 @@ val decode_pb_export_logs_partial_success : Pbrt.Decoder.t -> export_logs_partia val decode_pb_export_logs_service_response : Pbrt.Decoder.t -> export_logs_service_response (** [decode_pb_export_logs_service_response decoder] decodes a [export_logs_service_response] binary value from [decoder] *) - - -(** {2 Services} *) - -(** LogsService service *) -module LogsService : sig - open Pbrt_services - open Pbrt_services.Value_mode - - module Client : sig - - val export : (export_logs_service_request, unary, export_logs_service_response, unary) Client.rpc - end - - module Server : sig - (** Produce a server implementation from handlers *) - val make : - export:((export_logs_service_request, unary, export_logs_service_response, unary) Server.rpc -> 'handler) -> - unit -> 'handler Pbrt_services.Server.t - end -end diff --git a/src/proto/metrics.mli b/src/proto/metrics.mli index 61030369..d9626883 100644 --- a/src/proto/metrics.mli +++ b/src/proto/metrics.mli @@ -663,6 +663,3 @@ val decode_pb_metrics_data : Pbrt.Decoder.t -> metrics_data val decode_pb_data_point_flags : Pbrt.Decoder.t -> data_point_flags (** [decode_pb_data_point_flags decoder] decodes a [data_point_flags] binary value from [decoder] *) - - -(** {2 Services} *) diff --git a/src/proto/metrics_service.ml b/src/proto/metrics_service.ml index 04534bd3..6d1fa094 100644 --- a/src/proto/metrics_service.ml +++ b/src/proto/metrics_service.ml @@ -196,48 +196,3 @@ let rec decode_pb_export_metrics_service_response d = ({ partial_success = v.partial_success; } : export_metrics_service_response) - -module MetricsService = struct - open Pbrt_services.Value_mode - module Client = struct - open Pbrt_services - - let export : (export_metrics_service_request, unary, export_metrics_service_response, unary) Client.rpc = - (Client.mk_rpc - ~package:["opentelemetry";"proto";"collector";"metrics";"v1"] - ~service_name:"MetricsService" ~rpc_name:"Export" - ~req_mode:Client.Unary - ~res_mode:Client.Unary - ~encode_json_req:encode_json_export_metrics_service_request - ~encode_pb_req:encode_pb_export_metrics_service_request - ~decode_json_res:decode_json_export_metrics_service_response - ~decode_pb_res:decode_pb_export_metrics_service_response - () : (export_metrics_service_request, unary, export_metrics_service_response, unary) Client.rpc) - end - - module Server = struct - open Pbrt_services - - let _rpc_export : (export_metrics_service_request,unary,export_metrics_service_response,unary) Server.rpc = - (Server.mk_rpc ~name:"Export" - ~req_mode:Server.Unary - ~res_mode:Server.Unary - ~encode_json_res:encode_json_export_metrics_service_response - ~encode_pb_res:encode_pb_export_metrics_service_response - ~decode_json_req:decode_json_export_metrics_service_request - ~decode_pb_req:decode_pb_export_metrics_service_request - () : _ Server.rpc) - - let make - ~export - () : _ Server.t = - { Server. - service_name="MetricsService"; - package=["opentelemetry";"proto";"collector";"metrics";"v1"]; - handlers=[ - (export _rpc_export); - ]; - } - end - -end diff --git a/src/proto/metrics_service.mli b/src/proto/metrics_service.mli index 0d244b82..f3357d87 100644 --- a/src/proto/metrics_service.mli +++ b/src/proto/metrics_service.mli @@ -99,24 +99,3 @@ val decode_pb_export_metrics_partial_success : Pbrt.Decoder.t -> export_metrics_ val decode_pb_export_metrics_service_response : Pbrt.Decoder.t -> export_metrics_service_response (** [decode_pb_export_metrics_service_response decoder] decodes a [export_metrics_service_response] binary value from [decoder] *) - - -(** {2 Services} *) - -(** MetricsService service *) -module MetricsService : sig - open Pbrt_services - open Pbrt_services.Value_mode - - module Client : sig - - val export : (export_metrics_service_request, unary, export_metrics_service_response, unary) Client.rpc - end - - module Server : sig - (** Produce a server implementation from handlers *) - val make : - export:((export_metrics_service_request, unary, export_metrics_service_response, unary) Server.rpc -> 'handler) -> - unit -> 'handler Pbrt_services.Server.t - end -end diff --git a/src/proto/resource.mli b/src/proto/resource.mli index 8f778015..88f7cb9c 100644 --- a/src/proto/resource.mli +++ b/src/proto/resource.mli @@ -49,6 +49,3 @@ val encode_pb_resource : resource -> Pbrt.Encoder.t -> unit val decode_pb_resource : Pbrt.Decoder.t -> resource (** [decode_pb_resource decoder] decodes a [resource] binary value from [decoder] *) - - -(** {2 Services} *) diff --git a/src/proto/status.mli b/src/proto/status.mli index 1123c8bf..622f1256 100644 --- a/src/proto/status.mli +++ b/src/proto/status.mli @@ -52,6 +52,3 @@ val encode_pb_status : status -> Pbrt.Encoder.t -> unit val decode_pb_status : Pbrt.Decoder.t -> status (** [decode_pb_status decoder] decodes a [status] binary value from [decoder] *) - - -(** {2 Services} *) diff --git a/src/proto/trace.mli b/src/proto/trace.mli index b405cbea..bd7598e2 100644 --- a/src/proto/trace.mli +++ b/src/proto/trace.mli @@ -313,6 +313,3 @@ val decode_pb_resource_spans : Pbrt.Decoder.t -> resource_spans val decode_pb_traces_data : Pbrt.Decoder.t -> traces_data (** [decode_pb_traces_data decoder] decodes a [traces_data] binary value from [decoder] *) - - -(** {2 Services} *) diff --git a/src/proto/trace_service.ml b/src/proto/trace_service.ml index faab8ffc..79f5fe8d 100644 --- a/src/proto/trace_service.ml +++ b/src/proto/trace_service.ml @@ -196,48 +196,3 @@ let rec decode_pb_export_trace_service_response d = ({ partial_success = v.partial_success; } : export_trace_service_response) - -module TraceService = struct - open Pbrt_services.Value_mode - module Client = struct - open Pbrt_services - - let export : (export_trace_service_request, unary, export_trace_service_response, unary) Client.rpc = - (Client.mk_rpc - ~package:["opentelemetry";"proto";"collector";"trace";"v1"] - ~service_name:"TraceService" ~rpc_name:"Export" - ~req_mode:Client.Unary - ~res_mode:Client.Unary - ~encode_json_req:encode_json_export_trace_service_request - ~encode_pb_req:encode_pb_export_trace_service_request - ~decode_json_res:decode_json_export_trace_service_response - ~decode_pb_res:decode_pb_export_trace_service_response - () : (export_trace_service_request, unary, export_trace_service_response, unary) Client.rpc) - end - - module Server = struct - open Pbrt_services - - let _rpc_export : (export_trace_service_request,unary,export_trace_service_response,unary) Server.rpc = - (Server.mk_rpc ~name:"Export" - ~req_mode:Server.Unary - ~res_mode:Server.Unary - ~encode_json_res:encode_json_export_trace_service_response - ~encode_pb_res:encode_pb_export_trace_service_response - ~decode_json_req:decode_json_export_trace_service_request - ~decode_pb_req:decode_pb_export_trace_service_request - () : _ Server.rpc) - - let make - ~export - () : _ Server.t = - { Server. - service_name="TraceService"; - package=["opentelemetry";"proto";"collector";"trace";"v1"]; - handlers=[ - (export _rpc_export); - ]; - } - end - -end diff --git a/src/proto/trace_service.mli b/src/proto/trace_service.mli index f563aba3..4b555371 100644 --- a/src/proto/trace_service.mli +++ b/src/proto/trace_service.mli @@ -99,24 +99,3 @@ val decode_pb_export_trace_partial_success : Pbrt.Decoder.t -> export_trace_part val decode_pb_export_trace_service_response : Pbrt.Decoder.t -> export_trace_service_response (** [decode_pb_export_trace_service_response decoder] decodes a [export_trace_service_response] binary value from [decoder] *) - - -(** {2 Services} *) - -(** TraceService service *) -module TraceService : sig - open Pbrt_services - open Pbrt_services.Value_mode - - module Client : sig - - val export : (export_trace_service_request, unary, export_trace_service_response, unary) Client.rpc - end - - module Server : sig - (** Produce a server implementation from handlers *) - val make : - export:((export_trace_service_request, unary, export_trace_service_response, unary) Server.rpc -> 'handler) -> - unit -> 'handler Pbrt_services.Server.t - end -end