zio.telemetry.opentelemetry.tracing

Members list

Type members

Classlikes

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.

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
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Failure[E]
class Success[A]
object StatusMapper

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
trait Tracing

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Self type
object Tracing

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Tracing.type