From 198027a5194a77279433278c6a19d6c7a27a8fd5 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Thu, 28 Apr 2022 10:17:36 -0400 Subject: [PATCH] add histogram metrics (untested) --- src/opentelemetry.ml | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/opentelemetry.ml b/src/opentelemetry.ml index 5d09e8c9..58580172 100644 --- a/src/opentelemetry.ml +++ b/src/opentelemetry.ml @@ -625,15 +625,34 @@ module Metrics = struct ~aggregation_temporality ()) in default_metric ~name ?description ?unit_ ~data () - (* TODO + (** Histogram data + @param count number of values in population (non negative) + @param sum sum of values in population (0 if count is 0) + @param bucket_counts count value of histogram for each bucket. Sum of + the counts must be equal to [count]. + length must be [1+length explicit_bounds] + @param explicit_bounds strictly increasing list of bounds for the buckets *) + let histogram_data_point + ?(start_time_unix_nano=_program_start) + ?(now=Timestamp_ns.now_unix_ns()) + ?(attrs=[]) + ?(exemplars=[]) + ?(explicit_bounds=[]) + ?sum + ~bucket_counts + ~count + () : histogram_data_point = + let attributes = attrs |> List.map _conv_key_value in + default_histogram_data_point ~start_time_unix_nano ~time_unix_nano:now + ~attributes ~exemplars ~bucket_counts ~explicit_bounds ~count ?sum () + let histogram ~name ?description ?unit_ ?aggregation_temporality - (l:number_data_point list) : t = - let data h= + (l:histogram_data_point list) : t = + let data = Histogram (default_histogram ~data_points:l ?aggregation_temporality ()) in default_metric ~name ?description ?unit_ ~data () - *) (* TODO: exponential history *) (* TODO: summary *)