zio.telemetry.opentelemetry.trace.StatusMapper
See theStatusMapper companion object
sealed abstract class StatusMapper[-E, -A](val failure: PartialFunction[E, Result[Throwable]], val success: PartialFunction[A, Result[String]])
Maps the result of a wrapped ZIO effect to the status of the io.opentelemetry.api.trace.Span.
For more details, see: Set status
Usage examples:
StatusMapper.failure[MyError](_ => StatusCode.ERROR)(e => Some(new RuntimeException(e.message)))
StatusMapper.failureNoException(_ => StatusCode.ERROR)
StatusMapper.failureThrowable(StatusCode.ERROR)
StatusMapper.success[Response] {
resp => if(resp.code == 500) StatusCode.ERROR else StatusCode.OK
} { resp =>
if(resp.code == 500) Some(resp.errorMessage) else None
}
StatusMapper.successNoDescription[Response](_ => StatusCode.OK)
StatusMapper.both(
StatusMapper.failureThrowable(StatusCode.ERROR),
StatusMapper.successNoDescription[Any](_ => StatusCode.OK)
)
Value parameters
- failure
-
partial function to map the ZIO failure to io.opentelemetry.api.trace.StatusCode and java.lang.Throwable. The latter is used to record the exception, see: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/exceptions.md#recording-an-exception
- success
-
partial function to map the ZIO success to io.opentelemetry.api.trace.StatusCode and status description
Attributes
- Companion
- object
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
Members list
In this article