Skip to content

Commit

Permalink
Update OpenTelemetryMetrics.scala
Browse files Browse the repository at this point in the history
  • Loading branch information
varshith257 authored Nov 28, 2024
1 parent c654d5a commit 6c54a03
Showing 1 changed file with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@ object OpenTelemetryMetrics {
"url.scheme" -> { case (_, req) => req.uri.scheme.getOrElse("unknown") },
"path" -> { case (ep, _) => ep.showPathTemplate(showQueryParam = None) }
),
forResponse = List(
"http.response.status_code" -> {
case Right(r) => Some(r.code.code.toString)
case Left(_) => Some("500")
},
"error.type" -> {
case Left(ex) => Some(ex.getClass.getName)
case Right(_) => None
}
).collect { case (k, Some(v)) => k -> v }

forResponse = List(
"http.response.status_code" -> {
case Right(r) => r.code.code.toString
// Default to 500 for exceptions
case Left(_) => "500"
},
"error.type" -> {
case Left(ex) => ex.getClass.getName // Exception class name for pre-response errors
case Right(_) => None // No error.type for successful responses
}
)
)

def apply[F[_]](meter: Meter): OpenTelemetryMetrics[F] = apply(meter, Nil)
Expand Down

0 comments on commit 6c54a03

Please sign in to comment.