From c238c3bc837192f84b4bdef88d69cfb88da69476 Mon Sep 17 00:00:00 2001 From: Vishal Raj Date: Wed, 31 Jul 2024 14:50:51 +0100 Subject: [PATCH] [connector/spanmetrics] Add micro and nano secs unit to histogram --- connector/spanmetricsconnectorv2/config.go | 2 ++ connector/spanmetricsconnectorv2/histogram.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/connector/spanmetricsconnectorv2/config.go b/connector/spanmetricsconnectorv2/config.go index 330f135c..21cec2cd 100644 --- a/connector/spanmetricsconnectorv2/config.go +++ b/connector/spanmetricsconnectorv2/config.go @@ -38,6 +38,8 @@ var ( type MetricUnit string const ( + MetricUnitNs MetricUnit = "ns" + MetricUnitUs MetricUnit = "us" MetricUnitMs MetricUnit = "ms" MetricUnitS MetricUnit = "s" ) diff --git a/connector/spanmetricsconnectorv2/histogram.go b/connector/spanmetricsconnectorv2/histogram.go index 4e2d0bd9..a68e75bf 100644 --- a/connector/spanmetricsconnectorv2/histogram.go +++ b/connector/spanmetricsconnectorv2/histogram.go @@ -35,6 +35,8 @@ var ( // metricUnitToDivider gives a value that could used to divide the // nano precision duration to the required unit specified in config. metricUnitToDivider = map[MetricUnit]float64{ + MetricUnitNs: float64(time.Nanosecond.Nanoseconds()), + MetricUnitUs: float64(time.Microsecond.Nanoseconds()), MetricUnitMs: float64(time.Millisecond.Nanoseconds()), MetricUnitS: float64(time.Second.Nanoseconds()), }