Last active
January 7, 2020 09:26
-
-
Save adamw/2ca27da671217d7370569467cf52986f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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