com.dwolla.tracing.RootSpanProvidingFunctionK
See theRootSpanProvidingFunctionK companion object
class RootSpanProvidingFunctionK[F[_]](entryPoint: EntryPoint[F])(implicit evidence$1: MonadCancelThrow[F]) extends FunctionK[[_] =>> Instrumentation[[_] =>> Kleisli[F, Span[F], _$5], _$6], F]
Use this FunctionK when you have an algebra in Instrumentation[Kleisli[F, Span[F], *], *]
and you want each method call on the algebra to create a new root span using the given EntryPoint[F]
.
Note that if you have an algebra Alg[F]
for which an Instrument[Alg]
exists, you can convert it to Alg[Instrumentation[Kleisli[F, Span[F], *], *]]
in two steps, using Kleisli.liftK
and Instrument[Alg].instrument
:
import cats.data._, cats.effect._, cats.tagless.aop._, cats.tagless.syntax.all._, cats._
trait Foo[F[_]] {
def foo: F[Unit]
}
object Foo {
implicit val fooInstrument: Instrument[Foo] = { // Derive.instrument
// TODO reintroduce derived instance when cats-tagless-macros supports Scala 3
new Instrument[Foo] {
override def instrument[F[_]](af: Foo[F]): Foo[Instrumentation[F, *]] =
new Foo[Instrumentation[F, *]] {
override def foo: Instrumentation[F, Unit] =
Instrumentation(af.foo, "Foo", "foo")
}
override def mapK[F[_], G[_]](af: Foo[F])(fk: F ~> G): Foo[G] =
new Foo[G] {
override def foo: G[Unit] = fk(af.foo)
}
}
}
}
def myFoo: Foo[IO] = new Foo[IO] {
def foo = IO.println("foo!")
}
val instrumentedFoo: Foo[Instrumentation[Kleisli[IO, natchez.Span[IO], *], *]] =
myFoo.mapK(Kleisli.liftK[IO, natchez.Span[IO]]).instrument
Value parameters
- entryPoint
-
the Natchez
EntryPoint[F]
that will construct the new root spans
Attributes
- Companion
- object
- Source
- RootSpanProvidingFunctionK.scala
- Graph
-
- Supertypes
Members list
In this article