@@ -16,7 +16,7 @@ func EvaluateHistogram(rule rules.Rule, metrics parser.MetricsData, loadLevel ru
1616 result := rules.EvaluationResult {
1717 RuleName : rule .MetricName ,
1818 Status : rules .StatusGreen ,
19- Details : make ( map [ string ] interface {}) ,
19+ Details : [] string {} ,
2020 Timestamp : time .Now (),
2121 }
2222
@@ -65,9 +65,11 @@ func EvaluateHistogram(rule rules.Rule, metrics parser.MetricsData, loadLevel ru
6565 }
6666
6767 result .Value = p95
68- result .Details ["p95" ] = p95
69- result .Details ["p99" ] = p99
70- result .Details ["count" ] = totalCount
68+ result .Details = append (result .Details ,
69+ fmt .Sprintf ("p95: %.3f" , p95 ),
70+ fmt .Sprintf ("p99: %.3f" , p99 ),
71+ fmt .Sprintf ("count: %.0f" , totalCount ),
72+ )
7173
7274 // Select thresholds based on load level
7375 thresholds := selectThresholds (rule , loadLevel )
@@ -120,7 +122,7 @@ func evaluateSingleHistogramInfOverflow(baseName string, metrics parser.MetricsD
120122 result := & rules.EvaluationResult {
121123 RuleName : baseName + " (+Inf overflow check)" ,
122124 Status : rules .StatusGreen ,
123- Details : make ( map [ string ] interface {}) ,
125+ Details : [] string {} ,
124126 Timestamp : time .Now (),
125127 }
126128
@@ -211,10 +213,17 @@ func evaluateSingleHistogramInfOverflow(baseName string, metrics parser.MetricsD
211213 }
212214
213215 result .Status = worstStatus
214- result .Details ["Total Number of Observations" ] = formatHumanNumber (worstTotalCount )
215- result .Details ["Observations in +Inf bucket" ] = formatHumanNumber (worstInfObservations )
216- result .Details ["Percentage of observations in +Inf bucket" ] = formatHumanNumber (worstInfPercentage ) + " %"
217- result .Details ["Highest non-infinity bucket" ] = formatHumanNumber (worstHighestFiniteLe ) + " units"
216+ if baseMetric , ok := metrics .GetMetric (baseName ); ok && baseMetric .Help != "" {
217+ result .Details = append (result .Details , "Metric Description: " + baseMetric .Help )
218+ } else if bucketMetric , ok := metrics .GetMetric (baseName + "_bucket" ); ok && bucketMetric .Help != "" {
219+ result .Details = append (result .Details , "Metric Description: " + bucketMetric .Help )
220+ }
221+ result .Details = append (result .Details ,
222+ "Total Number of Observations: " + formatHumanNumber (worstTotalCount )+ " unit" ,
223+ "Observations in +Inf bucket: " + formatHumanNumber (worstInfObservations )+ " unit" ,
224+ "Percentage of observations in +Inf bucket: " + formatHumanNumber (worstInfPercentage )+ " %" ,
225+ "Highest non-infinity bucket: " + formatHumanNumber (worstHighestFiniteLe )+ " unit" ,
226+ )
218227
219228 // Build message based on worst case
220229 result .Message = fmt .Sprintf ("%s%% of observations in +Inf bucket (acceptable). Highest non-infinity bucket: %s" ,
@@ -247,7 +256,7 @@ func getSeriesKey(labels map[string]string) string {
247256}
248257
249258func formatHumanNumber (value float64 ) string {
250- raw := strconv .FormatFloat (value , 'f' , - 1 , 64 )
259+ raw := strconv .FormatFloat (value , 'f' , 2 , 64 )
251260 sign := ""
252261 if strings .HasPrefix (raw , "-" ) {
253262 sign = "-"
0 commit comments