Skip to content

Commit

Permalink
use ocaml-protoc 3.0.1 for codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
c-cube committed Dec 11, 2023
1 parent 2a6136c commit f63df22
Show file tree
Hide file tree
Showing 15 changed files with 19 additions and 291 deletions.
8 changes: 4 additions & 4 deletions src/client-cohttp-lwt/opentelemetry_client_cohttp_lwt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -318,23 +318,23 @@ 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
let x =
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
let x =
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 =
Expand Down
8 changes: 4 additions & 4 deletions src/client-ocurl/opentelemetry_client_ocurl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 =
Expand All @@ -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 =
Expand All @@ -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

Expand Down
78 changes: 11 additions & 67 deletions src/core/opentelemetry.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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} *)

Expand Down Expand Up @@ -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].
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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 ())
Expand Down
3 changes: 0 additions & 3 deletions src/proto/common.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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} *)
3 changes: 0 additions & 3 deletions src/proto/logs.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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} *)
45 changes: 0 additions & 45 deletions src/proto/logs_service.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 0 additions & 21 deletions src/proto/logs_service.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 0 additions & 3 deletions src/proto/metrics.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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} *)
45 changes: 0 additions & 45 deletions src/proto/metrics_service.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 0 additions & 21 deletions src/proto/metrics_service.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 0 additions & 3 deletions src/proto/resource.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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} *)
3 changes: 0 additions & 3 deletions src/proto/status.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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} *)
3 changes: 0 additions & 3 deletions src/proto/trace.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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} *)
Loading

0 comments on commit f63df22

Please sign in to comment.