mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-09 04:17:56 -04:00
test: improve t_size
This commit is contained in:
parent
6e8877f177
commit
4066cad663
2 changed files with 160 additions and 4 deletions
|
|
@ -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 = "";
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
open Opentelemetry
|
open Opentelemetry
|
||||||
|
|
||||||
let m =
|
let res1 =
|
||||||
Metrics.make_resource_metrics
|
Metrics.make_resource_metrics
|
||||||
[
|
[
|
||||||
Metrics.sum ~name:"sum.foo"
|
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 () =
|
||||||
let str = Opentelemetry_client.Signal.Encode.metrics [ m; m ] in
|
let dec = Pbrt.Decoder.of_string str in
|
||||||
Printf.printf "metrics size: %dB\n" (String.length str)
|
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;
|
||||||
|
()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue