Skip to content

Commit

Permalink
Update Metric.scala
Browse files Browse the repository at this point in the history
  • Loading branch information
varshith257 authored Dec 11, 2024
1 parent f5ccae4 commit 8252467
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ case class MetricLabels(
def namesForResponse: List[String] = forResponse.map { case (name, _) => name }

def valuesForRequest(ep: AnyEndpoint, req: ServerRequest): List[String] = forRequest.map { case (_, f) => f(ep, req) }
def valuesForResponse(res: ServerResponse[_]): List[String] = forResponse.map { case (_, f) => f(Right(res)) }
def valuesForResponse(ex: Throwable): List[String] = forResponse.map { case (_, f) => f(Left(ex)) }
def valuesForResponse(res: ServerResponse[_]): List[String] = forResponse.flatMap { case (_, f) => f(Right(res)).toList }
def valuesForResponse(ex: Throwable): List[String] = forResponse.flatMap { case (_, f) => f(Left(ex)).toList }
}

object MetricLabels {
Expand All @@ -51,15 +51,15 @@ object MetricLabels {
forResponse = List(
"status" -> {
case Right(r) =>
r.code match {
Some(r.code match {
case c if c.isInformational => "1xx"
case c if c.isSuccess => "2xx"
case c if c.isRedirect => "3xx"
case c if c.isClientError => "4xx"
case c if c.isServerError => "5xx"
case _ => ""
}
case Left(_) => "5xx"
})
case Left(_) => Some("5xx")
}
)
)
Expand Down

0 comments on commit 8252467

Please sign in to comment.