8000 Unable to figure out how `Metric.timer` is supposed to work · Issue #7344 · zio/zio · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Unable to figure out how Metric.timer is supposed to work #7344
Closed
@domdorn

Description

@domdorn

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
} 

Metadata

Metadata

Assignees

Labels

documentationDocumentation improvements

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0