From a28f24d14feb250b154b00d4010e4b9c49b4d579 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Thu, 5 Mar 2026 14:46:46 -0500 Subject: [PATCH] metrics: use main clock by default for data points --- src/core/metrics.ml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/metrics.ml b/src/core/metrics.ml index 64f56dad..f9701d6d 100644 --- a/src/core/metrics.ml +++ b/src/core/metrics.ml @@ -16,15 +16,15 @@ type t = Metrics.metric let pp = Proto.Metrics.pp_metric (** Number data point, as a float *) -let float ?start_time_unix_nano ?(attrs = []) ~(now : Timestamp_ns.t) +let float ?start_time_unix_nano ?(attrs = []) ?(now = Clock.now_main ()) (d : float) : number_data_point = let attributes = attrs |> List.map Key_value.conv in make_number_data_point ?start_time_unix_nano ~time_unix_nano:now ~attributes ~value:(As_double d) () (** Number data point, as an int *) -let int ?start_time_unix_nano ?(attrs = []) ~(now : Timestamp_ns.t) (i : int) : - number_data_point = +let int ?start_time_unix_nano ?(attrs = []) ?(now = Clock.now_main ()) (i : int) + : number_data_point = let attributes = attrs |> List.map Key_value.conv in make_number_data_point ?start_time_unix_nano ~time_unix_nano:now ~attributes ~value:(As_int (Int64.of_int i)) @@ -61,7 +61,7 @@ type histogram_data_point = Metrics.histogram_data_point length 0) @param explicit_bounds strictly increasing list of bounds for the buckets *) let histogram_data_point ?start_time_unix_nano ?(attrs = []) ?(exemplars = []) - ~explicit_bounds ?sum ~(now : Timestamp_ns.t) ~bucket_counts ~count () : + ~explicit_bounds ?sum ?(now = Clock.now_main ()) ~bucket_counts ~count () : histogram_data_point = let attributes = attrs |> List.map Key_value.conv in make_histogram_data_point ?start_time_unix_nano ~time_unix_nano:now