diff --git a/tests/core/t_size.expected b/tests/core/t_size.expected index 391ca120..b45d61a1 100644 --- a/tests/core/t_size.expected +++ b/tests/core/t_size.expected @@ -1 +1,147 @@ -metrics size: 492B +metrics size: 243B +res1: { resource = + Some( + { attributes = + [{ key = "service.name"; + value = Some(String_value("unknown_service")); + } + ]; + dropped_attributes_count = 0; + }); + scope_metrics = + [{ scope = + Some( + { name = "ocaml-otel"; + version = "%%VERSION_NUM%%"; + attributes = []; + dropped_attributes_count = 0; + }); + metrics = + [{ name = "sum.foo"; + description = ""; + unit_ = ""; + data = + Sum( + { data_points = + [{ attributes = []; + start_time_unix_nano = 42; + time_unix_nano = 45; + value = As_int(10); + exemplars = []; + flags = 0; + }; + { attributes = []; + start_time_unix_nano = 52; + time_unix_nano = 55; + value = As_int(20); + exemplars = []; + flags = 0; + } + ]; + aggregation_temporality = + Aggregation_temporality_cumulative; + is_monotonic = false; + }); + }; + { name = "gauge.bar"; + description = ""; + unit_ = ""; + data = + Gauge( + { data_points = + [{ attributes = []; + start_time_unix_nano = 42; + time_unix_nano = 45; + value = As_double(10.); + exemplars = []; + flags = 0; + }; + { attributes = []; + start_time_unix_nano = 52; + time_unix_nano = 55; + value = As_double(20.); + exemplars = []; + flags = 0; + } + ]; + }); + } + ]; + schema_url = ""; + } + ]; + schema_url = ""; + } +res1: { resource = + Some( + { attributes = + [{ key = "service.name"; + value = Some(String_value("unknown_service")); + } + ]; + dropped_attributes_count = 0; + }); + scope_metrics = + [{ scope = + Some( + { name = "ocaml-otel"; + version = "%%VERSION_NUM%%"; + attributes = []; + dropped_attributes_count = 0; + }); + metrics = + [{ name = "sum.foo"; + description = ""; + unit_ = ""; + data = + Sum( + { data_points = + [{ attributes = []; + start_time_unix_nano = 42; + time_unix_nano = 45; + value = As_int(10); + exemplars = []; + flags = 0; + }; + { attributes = []; + start_time_unix_nano = 52; + time_unix_nano = 55; + value = As_int(20); + exemplars = []; + flags = 0; + } + ]; + aggregation_temporality = + Aggregation_temporality_cumulative; + is_monotonic = false; + }); + }; + { name = "gauge.bar"; + description = ""; + unit_ = ""; + data = + Gauge( + { data_points = + [{ attributes = []; + start_time_unix_nano = 42; + time_unix_nano = 45; + value = As_double(10.); + exemplars = []; + flags = 0; + }; + { attributes = []; + start_time_unix_nano = 52; + time_unix_nano = 55; + value = As_double(20.); + exemplars = []; + flags = 0; + } + ]; + }); + } + ]; + schema_url = ""; + } + ]; + schema_url = ""; + } diff --git a/tests/core/t_size.ml b/tests/core/t_size.ml index 97e989df..bda2e186 100644 --- a/tests/core/t_size.ml +++ b/tests/core/t_size.ml @@ -2,7 +2,7 @@ open Opentelemetry -let m = +let res1 = Metrics.make_resource_metrics [ Metrics.sum ~name:"sum.foo" @@ -17,6 +17,16 @@ let m = ]; ] +let str = + let enc = Pbrt.Encoder.create () in + Proto.Metrics.encode_pb_resource_metrics res1 enc; + Pbrt.Encoder.to_string enc + +let () = Printf.printf "metrics size: %dB\n" (String.length str) + let () = - let str = Opentelemetry_client.Signal.Encode.metrics [ m; m ] in - Printf.printf "metrics size: %dB\n" (String.length str) + let dec = Pbrt.Decoder.of_string str in + let res2 = Proto.Metrics.decode_pb_resource_metrics dec in + Format.printf "res1: %a@." Proto.Metrics.pp_resource_metrics res1; + Format.printf "res1: %a@." Proto.Metrics.pp_resource_metrics res2; + ()