Skip to content

Instantly share code, notes, and snippets.

@adamw
Last active January 7, 2020 09:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamw/2ca27da671217d7370569467cf52986f to your computer and use it in GitHub Desktop.
Save adamw/2ca27da671217d7370569467cf52986f to your computer and use it in GitHub Desktop.
import io.prometheus.client.{Gauge, Histogram}
def reportRequestMetrics(request: HttpRequest): Try[RouteResult] => Unit = {
requestsInProgress.inc()
val requestTimer = requestLatencySeconds.startTimer()
result => {
requestsInProgress.dec()
result match {
case Success(Complete(_)) => requestTimer.observeDuration()
case _ => // do nothing
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment