Skip to content

Commit

Permalink
Merge pull request #43 from imandra-ai/wip-otel-1.0
Browse files Browse the repository at this point in the history
move to otel 1.0
  • Loading branch information
c-cube authored Sep 8, 2023
2 parents c915730 + e40c999 commit af71df8
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

OPTS=--profile=release
OPTS="--profile=release --ignore-promoted-rules"
all:
@dune build @all $(OPTS)

Expand Down
18 changes: 9 additions & 9 deletions src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

(rule
(alias lint)
(mode fallback)
(mode promote)
(targets status_types.ml status_types.mli status_pb.ml status_pb.mli
status_pp.ml status_pp.mli)
(deps
Expand All @@ -20,7 +20,7 @@

(rule
(alias lint)
(mode fallback)
(mode promote)
(targets common_types.ml common_types.mli common_pb.ml common_pb.mli
common_pp.ml common_pp.mli)
(deps
Expand All @@ -33,7 +33,7 @@

(rule
(alias lint)
(mode fallback)
(mode promote)
(targets resource_types.ml resource_types.mli resource_pb.ml resource_pb.mli
resource_pp.ml resource_pp.mli)
(deps
Expand All @@ -46,7 +46,7 @@

(rule
(alias lint)
(mode fallback)
(mode promote)
(targets trace_types.ml trace_types.mli trace_pb.ml trace_pb.mli trace_pp.ml
trace_pp.mli)
(deps
Expand All @@ -59,7 +59,7 @@

(rule
(alias lint)
(mode fallback)
(mode promote)
(targets metrics_types.ml metrics_types.mli metrics_pb.ml metrics_pb.mli
metrics_pp.ml metrics_pp.mli)
(deps
Expand All @@ -72,7 +72,7 @@

(rule
(alias lint)
(mode fallback)
(mode promote)
(targets logs_types.ml logs_types.mli logs_pb.ml logs_pb.mli logs_pp.ml
logs_pp.mli)
(deps
Expand All @@ -85,7 +85,7 @@

(rule
(alias lint)
(mode fallback)
(mode promote)
(targets metrics_service_types.ml metrics_service_types.mli
metrics_service_pp.ml metrics_service_pp.mli metrics_service_pb.ml
metrics_service_pb.mli)
Expand All @@ -99,7 +99,7 @@

(rule
(alias lint)
(mode fallback)
(mode promote)
(targets trace_service_types.ml trace_service_types.mli trace_service_pp.ml
trace_service_pp.mli trace_service_pb.ml trace_service_pb.mli)
(deps
Expand All @@ -112,7 +112,7 @@

(rule
(alias lint)
(mode fallback)
(mode promote)
(targets logs_service_types.ml logs_service_types.mli logs_service_pp.ml
logs_service_pp.mli logs_service_pb.ml logs_service_pb.mli)
(deps
Expand Down
8 changes: 4 additions & 4 deletions src/logs_pb.ml
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ let rec decode_logs_data d =

let rec decode_log_record_flags d =
match Pbrt.Decoder.int_as_varint d with
| 0 -> (Logs_types.Log_record_flag_unspecified:Logs_types.log_record_flags)
| 255 -> (Logs_types.Log_record_flag_trace_flags_mask:Logs_types.log_record_flags)
| 0 -> (Logs_types.Log_record_flags_do_not_use:Logs_types.log_record_flags)
| 255 -> (Logs_types.Log_record_flags_trace_flags_mask:Logs_types.log_record_flags)
| _ -> Pbrt.Decoder.malformed_variant "log_record_flags"

let rec encode_severity_number (v:Logs_types.severity_number) encoder =
Expand Down Expand Up @@ -344,5 +344,5 @@ let rec encode_logs_data (v:Logs_types.logs_data) encoder =

let rec encode_log_record_flags (v:Logs_types.log_record_flags) encoder =
match v with
| Logs_types.Log_record_flag_unspecified -> Pbrt.Encoder.int_as_varint (0) encoder
| Logs_types.Log_record_flag_trace_flags_mask -> Pbrt.Encoder.int_as_varint 255 encoder
| Logs_types.Log_record_flags_do_not_use -> Pbrt.Encoder.int_as_varint (0) encoder
| Logs_types.Log_record_flags_trace_flags_mask -> Pbrt.Encoder.int_as_varint 255 encoder
4 changes: 2 additions & 2 deletions src/logs_pp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ let rec pp_logs_data fmt (v:Logs_types.logs_data) =

let rec pp_log_record_flags fmt (v:Logs_types.log_record_flags) =
match v with
| Logs_types.Log_record_flag_unspecified -> Format.fprintf fmt "Log_record_flag_unspecified"
| Logs_types.Log_record_flag_trace_flags_mask -> Format.fprintf fmt "Log_record_flag_trace_flags_mask"
| Logs_types.Log_record_flags_do_not_use -> Format.fprintf fmt "Log_record_flags_do_not_use"
| Logs_types.Log_record_flags_trace_flags_mask -> Format.fprintf fmt "Log_record_flags_trace_flags_mask"
6 changes: 3 additions & 3 deletions src/logs_types.ml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ type logs_data = {
}

type log_record_flags =
| Log_record_flag_unspecified
| Log_record_flag_trace_flags_mask
| Log_record_flags_do_not_use
| Log_record_flags_trace_flags_mask

let rec default_severity_number () = (Severity_number_unspecified:severity_number)

Expand Down Expand Up @@ -113,4 +113,4 @@ let rec default_logs_data
resource_logs;
}

let rec default_log_record_flags () = (Log_record_flag_unspecified:log_record_flags)
let rec default_log_record_flags () = (Log_record_flags_do_not_use:log_record_flags)
4 changes: 2 additions & 2 deletions src/logs_types.mli
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ type logs_data = {
}

type log_record_flags =
| Log_record_flag_unspecified
| Log_record_flag_trace_flags_mask
| Log_record_flags_do_not_use
| Log_record_flags_trace_flags_mask


(** {2 Default values} *)
Expand Down
18 changes: 14 additions & 4 deletions src/metrics_pb.ml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ type exponential_histogram_data_point_mutable = {
mutable exemplars : Metrics_types.exemplar list;
mutable min : float option;
mutable max : float option;
mutable zero_threshold : float;
}

let default_exponential_histogram_data_point_mutable () : exponential_histogram_data_point_mutable = {
Expand All @@ -132,6 +133,7 @@ let default_exponential_histogram_data_point_mutable () : exponential_histogram_
exemplars = [];
min = None;
max = None;
zero_threshold = 0.;
}

type exponential_histogram_mutable = {
Expand Down Expand Up @@ -625,6 +627,11 @@ let rec decode_exponential_histogram_data_point d =
end
| Some (13, pk) ->
Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(13)" pk
| Some (14, Pbrt.Bits64) -> begin
v.zero_threshold <- Pbrt.Decoder.float_as_bits64 d;
end
| Some (14, pk) ->
Pbrt.Decoder.unexpected_payload "Message(exponential_histogram_data_point), field(14)" pk
| Some (_, payload_kind) -> Pbrt.Decoder.skip d payload_kind
done;
({
Expand All @@ -641,6 +648,7 @@ let rec decode_exponential_histogram_data_point d =
Metrics_types.exemplars = v.exemplars;
Metrics_types.min = v.min;
Metrics_types.max = v.max;
Metrics_types.zero_threshold = v.zero_threshold;
} : Metrics_types.exponential_histogram_data_point)

let rec decode_exponential_histogram d =
Expand Down Expand Up @@ -924,8 +932,8 @@ let rec decode_metrics_data d =

let rec decode_data_point_flags d =
match Pbrt.Decoder.int_as_varint d with
| 0 -> (Metrics_types.Flag_none:Metrics_types.data_point_flags)
| 1 -> (Metrics_types.Flag_no_recorded_value:Metrics_types.data_point_flags)
| 0 -> (Metrics_types.Data_point_flags_do_not_use:Metrics_types.data_point_flags)
| 1 -> (Metrics_types.Data_point_flags_no_recorded_value_mask:Metrics_types.data_point_flags)
| _ -> Pbrt.Decoder.malformed_variant "data_point_flags"

let rec encode_exemplar_value (v:Metrics_types.exemplar_value) encoder =
Expand Down Expand Up @@ -1138,6 +1146,8 @@ let rec encode_exponential_histogram_data_point (v:Metrics_types.exponential_his
Pbrt.Encoder.float_as_bits64 x encoder;
| None -> ();
end;
Pbrt.Encoder.key (14, Pbrt.Bits64) encoder;
Pbrt.Encoder.float_as_bits64 v.Metrics_types.zero_threshold encoder;
()

let rec encode_exponential_histogram (v:Metrics_types.exponential_histogram) encoder =
Expand Down Expand Up @@ -1268,5 +1278,5 @@ let rec encode_metrics_data (v:Metrics_types.metrics_data) encoder =

let rec encode_data_point_flags (v:Metrics_types.data_point_flags) encoder =
match v with
| Metrics_types.Flag_none -> Pbrt.Encoder.int_as_varint (0) encoder
| Metrics_types.Flag_no_recorded_value -> Pbrt.Encoder.int_as_varint 1 encoder
| Metrics_types.Data_point_flags_do_not_use -> Pbrt.Encoder.int_as_varint (0) encoder
| Metrics_types.Data_point_flags_no_recorded_value_mask -> Pbrt.Encoder.int_as_varint 1 encoder
5 changes: 3 additions & 2 deletions src/metrics_pp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ let rec pp_exponential_histogram_data_point fmt (v:Metrics_types.exponential_his
Pbrt.Pp.pp_record_field ~first:false "exemplars" (Pbrt.Pp.pp_list pp_exemplar) fmt v.Metrics_types.exemplars;
Pbrt.Pp.pp_record_field ~first:false "min" (Pbrt.Pp.pp_option Pbrt.Pp.pp_float) fmt v.Metrics_types.min;
Pbrt.Pp.pp_record_field ~first:false "max" (Pbrt.Pp.pp_option Pbrt.Pp.pp_float) fmt v.Metrics_types.max;
Pbrt.Pp.pp_record_field ~first:false "zero_threshold" Pbrt.Pp.pp_float fmt v.Metrics_types.zero_threshold;
in
Pbrt.Pp.pp_brk pp_i fmt ()

Expand Down Expand Up @@ -172,5 +173,5 @@ let rec pp_metrics_data fmt (v:Metrics_types.metrics_data) =

let rec pp_data_point_flags fmt (v:Metrics_types.data_point_flags) =
match v with
| Metrics_types.Flag_none -> Format.fprintf fmt "Flag_none"
| Metrics_types.Flag_no_recorded_value -> Format.fprintf fmt "Flag_no_recorded_value"
| Metrics_types.Data_point_flags_do_not_use -> Format.fprintf fmt "Data_point_flags_do_not_use"
| Metrics_types.Data_point_flags_no_recorded_value_mask -> Format.fprintf fmt "Data_point_flags_no_recorded_value_mask"
9 changes: 6 additions & 3 deletions src/metrics_types.ml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ type exponential_histogram_data_point = {
exemplars : exemplar list;
min : float option;
max : float option;
zero_threshold : float;
}

type exponential_histogram = {
Expand Down Expand Up @@ -136,8 +137,8 @@ type metrics_data = {
}

type data_point_flags =
| Flag_none
| Flag_no_recorded_value
| Data_point_flags_do_not_use
| Data_point_flags_no_recorded_value_mask

let rec default_exemplar_value () : exemplar_value = As_double (0.)

Expand Down Expand Up @@ -247,6 +248,7 @@ let rec default_exponential_histogram_data_point
?exemplars:((exemplars:exemplar list) = [])
?min:((min:float option) = None)
?max:((max:float option) = None)
?zero_threshold:((zero_threshold:float) = 0.)
() : exponential_histogram_data_point = {
attributes;
start_time_unix_nano;
Expand All @@ -261,6 +263,7 @@ let rec default_exponential_histogram_data_point
exemplars;
min;
max;
zero_threshold;
}

let rec default_exponential_histogram
Expand Down Expand Up @@ -343,4 +346,4 @@ let rec default_metrics_data
resource_metrics;
}

let rec default_data_point_flags () = (Flag_none:data_point_flags)
let rec default_data_point_flags () = (Data_point_flags_do_not_use:data_point_flags)
6 changes: 4 additions & 2 deletions src/metrics_types.mli
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ type exponential_histogram_data_point = {
exemplars : exemplar list;
min : float option;
max : float option;
zero_threshold : float;
}

type exponential_histogram = {
Expand Down Expand Up @@ -139,8 +140,8 @@ type metrics_data = {
}

type data_point_flags =
| Flag_none
| Flag_no_recorded_value
| Data_point_flags_do_not_use
| Data_point_flags_no_recorded_value_mask


(** {2 Default values} *)
Expand Down Expand Up @@ -233,6 +234,7 @@ val default_exponential_histogram_data_point :
?exemplars:exemplar list ->
?min:float option ->
?max:float option ->
?zero_threshold:float ->
unit ->
exponential_histogram_data_point
(** [default_exponential_histogram_data_point ()] is the default value for type [exponential_histogram_data_point] *)
Expand Down
9 changes: 5 additions & 4 deletions src/opentelemetry.ml
Original file line number Diff line number Diff line change
Expand Up @@ -436,10 +436,11 @@ module Globals = struct
List.rev_append (List.filter not_redundant !global_attributes) into

(** Default span kind in {!Span.create}.
This will be used in all spans that do not specify [~kind] explicitly.
This will be used in all spans that do not specify [~kind] explicitly;
it is set to "internal", following directions from the [.proto] file.
It can be convenient to set "client" or "server" uniformly in here.
@since 0.4 *)
let default_span_kind = ref Proto.Trace.Span_kind_unspecified
let default_span_kind = ref Proto.Trace.Span_kind_internal

let mk_attributes ?(service_name = !service_name) ?(attrs = []) () : _ list =
let l = List.map _conv_key_value attrs in
Expand Down Expand Up @@ -924,8 +925,8 @@ module Logs = struct
let pp_severity = Logs_pp.pp_severity_number

type flags = Logs_types.log_record_flags =
| Log_record_flag_unspecified
| Log_record_flag_trace_flags_mask
| Log_record_flags_do_not_use
| Log_record_flags_trace_flags_mask

let pp_flags = Logs_pp.pp_log_record_flags

Expand Down

0 comments on commit af71df8

Please sign in to comment.