X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FMetricsPage.kt;fp=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FMetricsPage.kt;h=041e75535f30b89764d64240a5c1ee10931140dc;hb=6562eedae6d6b25ecfb2f662a827db85f7026d50;hp=0000000000000000000000000000000000000000;hpb=021ebc63f3a1bc2b6d3faed1a56386dacc11eeae;p=Sone.git diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/MetricsPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/MetricsPage.kt new file mode 100644 index 0000000..041e755 --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/MetricsPage.kt @@ -0,0 +1,30 @@ +package net.pterodactylus.sone.web.pages + +import com.codahale.metrics.* +import net.pterodactylus.sone.main.* +import net.pterodactylus.sone.web.* +import net.pterodactylus.sone.web.page.* +import net.pterodactylus.util.template.* +import javax.inject.* + +@MenuName("Metrics") +@TemplatePath("/templates/metrics.html") +@ToadletPath("metrics.html") +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").snapshot.also { snapshot -> + templateContext["soneParsingDurationCount"] = snapshot.size() + 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() + } + } + +}