public static HistogramGauges registerWithCommonFormat ( Timer timer , MeterRegistry registry ) { Meter . Id id = timer . getId ( ) ; return HistogramGauges . register ( timer , registry , percentile -> id . getName ( ) + ".percentile" , percentile -> Tags . concat ( id . getTagsAsIterable ( ) , "phi" , DoubleFormat . decimalOrNan ( percentile . percentile ( ) ) ) , percentile -> percentile . value ( timer . baseTimeUnit ( ) ) , bucket -> id . getName ( ) + ".histogram" , // We look for Long.MAX_VALUE to ensure a sensible tag on our +Inf bucket bucket -> Tags . concat ( id . getTagsAsIterable ( ) , "le" , bucket . bucket ( ) != Long . MAX_VALUE ? DoubleFormat . decimalOrWhole ( bucket . bucket ( timer . baseTimeUnit ( ) ) ) : "+Inf" ) ) ; }
Register a set of gauges for percentiles and histogram buckets that follow a common format when the monitoring system doesn t have an opinion about the structure of this data .