class MetricsPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer, private val metricsRegistry: MetricRegistry) : SoneTemplatePage(webInterface, loaders, templateRenderer, "Page.Metrics.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
- metricsRegistry.histogram("sone.parsing.duration").also { histogram ->
- templateContext["soneParsingDurationCount"] = histogram.count
+ addHistogram(templateContext, "sone.parsing.duration", "soneParsingDuration")
+ addHistogram(templateContext, "sone.insert.duration", "soneInsertDuration")
+ }
+
+ private fun addHistogram(templateContext: TemplateContext, metricName: String, variablePrefix: String) {
+ metricsRegistry.histogram(metricName).also { histogram ->
+ templateContext["${variablePrefix}Count"] = histogram.count
histogram.snapshot.also { snapshot ->
- templateContext["soneParsingDurationMin"] = snapshot.min
- templateContext["soneParsingDurationMax"] = snapshot.max
- templateContext["soneParsingDurationMedian"] = snapshot.median
- templateContext["soneParsingDurationMean"] = snapshot.mean
- templateContext["soneParsingDurationPercentile75"] = snapshot.get75thPercentile()
- templateContext["soneParsingDurationPercentile95"] = snapshot.get95thPercentile()
- templateContext["soneParsingDurationPercentile98"] = snapshot.get98thPercentile()
- templateContext["soneParsingDurationPercentile99"] = snapshot.get99thPercentile()
- templateContext["soneParsingDurationPercentile999"] = snapshot.get999thPercentile()
+ 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()
}
}
}
</thead>
<tbody>
<tr>
+ <td><%= Page.Metrics.SoneInsertDuration.Title|l10n|html></td>
+ <td class="numeric"><% soneInsertDurationCount|html></td>
+ <td class="numeric"><% soneInsertDurationMin|html>μs</td>
+ <td class="numeric"><% soneInsertDurationMax|html>μs</td>
+ <td class="numeric"><% soneInsertDurationMean|format format=='%.0f'|html>μs</td>
+ <td class="numeric"><% soneInsertDurationMedian|format format=='%.0f'|html>μs</td>
+ <td class="numeric"><% soneInsertDurationPercentile75|format format=='%.0f'|html>μs</td>
+ <td class="numeric"><% soneInsertDurationPercentile95|format format=='%.0f'|html>μs</td>
+ <td class="numeric"><% soneInsertDurationPercentile98|format format=='%.0f'|html>μs</td>
+ <td class="numeric"><% soneInsertDurationPercentile99|format format=='%.0f'|html>μs</td>
+ <td class="numeric"><% soneInsertDurationPercentile999|format format=='%.0f'|html>μs</td>
+ </tr>
+ <tr>
<td><%= Page.Metrics.SoneParsingDuration.Title|l10n|html></td>
<td class="numeric"><% soneParsingDurationCount|html></td>
<td class="numeric"><% soneParsingDurationMin|html>μs</td>