Trace[F]
in the context bound for those and call it a day.
Hi! Need some help with wiring with natchez.
I have one big wire function:
def wireAll[F[_]: ContextShift: Timer: Parallel: Concurrent: Async]: Resource[F, HttpRoutes[F]]
And one run function:
def run[F[_]: ContextShift: ConcurrentEffect: Timer: Parallel: Bracket[*[_], Throwable]]: F[Fiber[F, Unit]] = {
val resource = for {
traceEntryPoint <- entryPoint[F]: Resource[F, EntryPoint[F]]
httpRoutes <- wireAll[Kleisli[F, Span[F], *]]: Resource[Kleisli[F, Span[F], *], HttpRoutes[Kleisli[F, Span[F], *]]
//after that I can obtain HttpRoutes[F] from HttpRoutes[Kleisli[F, Span[F], *] using middleware and run server
...
} yield ()
...
}
The problem is in the first Resource
type parameter - Kleisli[F, Span[F], *]
(F
needed)
Do you know how to rewrite this correctly?
Kleisli.applyK
, but you'll still need a Span[F]
. You can probably use one that you get from the entrypoint - this will basically be the span of "starting the application"
httpRoutes <- traceEntryPoint.root("init").use { span => wireAll[Kleisli[F, Span[F], *]].mapK(Kleisli.applyK(span)) }
- roughly
F[Fiber[F, Unit]]
, it's easy to make a mistake. See if you can use .background
instead of .start
wherever it is.
It's me again. I am trying to wrap Client[F]. (I have Trace[F] instance there)
def apply[F[_]: Trace: Sync](client: Client[F]): Client[F] = {
Client[F] { request =>
val spanName: String = ???
for {
b <- Trace[F].span(spanName) { //should be F[]
}
//only have Resource[F, Response[F]] type for
//client.run(modifiedRequest))
} yield ???
}
}
Can't get how to transform Resource
to wrap it with Trace[F].span
Trace[F].span(“stream”)(s.compile.drain)
Stream.eval(Kleisli.ask).flatMap(span => Stream.resource(span.subspan("name"))) >> innerStream