Closed
Description
I'm unable to figure out how Metric.timer
is supposed to work. Documentation as well as Tests are missing
Sample code:
def timeReq(req: HttpRequest, uriOverride: Option[String]): Metric[MetricKeyType.Histogram,
zio.Duration,
MetricState.Histogram] = Metric
.timer("http_server_requests", ChronoUnit.SECONDS)
.tagged(
MetricLabel("method", req.method.name),
MetricLabel("uri", uriOverride.getOrElse(req.uri.path.toString()))
)
def handleReqTypesPrinted(req: HttpReq) = {
for {
_ <- ZIO.unit
someEffect: ZIO[Any, Throwable, String] = ZIO.attempt("hello")
valueTry1: ZIO[Any, LowerE, LowerA] = someEffect @@ timeReq(req, None) // does not compile cause its giving me these LowerE, LowerA
valueTry2: ZIO[Any, Throwable, zio.Duration] = timeReq(req, None)(someEffect.timed.map(_._1)) // does not give me the String I need
value <- valueTry2
} yield value
}
def handleReqTypesAbsent(req: HttpReq) = {
for {
_ <- ZIO.unit
someEffect = ZIO.attempt("hello")
valueTry1 = someEffect @@ timeReq(req, None) // does not compile cause its giving me these LowerE, LowerA
valueTry2 = timeReq(req, None)(someEffect.timed.map(_._1)) // does not give me the String I need
value <- valueTry2
} yield value
}