- metricsRegistry.histograms
- .mapKeys { it.key to it.key.toI18n() }
- .onEach { addHistogram(templateContext, it.key.first, it.key.second) }
- .keys
- .map(Pair<*, String>::second)
- .let { templateContext["histogramKeys"] = it }
- }
-
- private fun addHistogram(templateContext: TemplateContext, metricName: String, variablePrefix: String) {
- metricsRegistry.histogram(metricName).also { histogram ->
- templateContext["${variablePrefix}I18n"] = variablePrefix.capitalizeFirst()
- templateContext["${variablePrefix}Count"] = histogram.count
- histogram.snapshot.also { snapshot ->
- templateContext["${variablePrefix}Min"] = snapshot.min
- templateContext["${variablePrefix}Max"] = snapshot.max
- templateContext["${variablePrefix}Median"] = snapshot.median
- templateContext["${variablePrefix}Mean"] = snapshot.mean
- templateContext["${variablePrefix}Percentile75"] = snapshot.get75thPercentile()
- templateContext["${variablePrefix}Percentile95"] = snapshot.get95thPercentile()
- templateContext["${variablePrefix}Percentile98"] = snapshot.get98thPercentile()
- templateContext["${variablePrefix}Percentile99"] = snapshot.get99thPercentile()
- templateContext["${variablePrefix}Percentile999"] = snapshot.get999thPercentile()
- }
- }