TraceInstrumentation

com.dwolla.tracing.TraceInstrumentation
See theTraceInstrumentation companion object
class TraceInstrumentation[F[_]] extends FunctionK[[_] =>> Instrumentation[F, _$4], F]

Use this FunctionK when you have an algebra in Instrumentation[F, *] and you want each method call on the algebra to introduce a new child span, using the ambient Trace[F]. Each child span will be named using the algebra name and method name as captured in the Instrumentation[F, A].

Note if you have an algebra Alg[F] for which an Instrument[Alg] exists, it can be converted to Alg[Instrumentation[F, *]] using Instrument[Alg].instrument:

import 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[IO, *]] =
  myFoo.instrument

Attributes

Companion
object
Source
TraceInstrumentation.scala
Graph
Supertypes
trait FunctionK[[_] =>> Instrumentation[F, _$4], F]
trait Serializable
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

override def apply[A](fa: Instrumentation[F, A]): F[A]

Applies this functor transformation from F to G

Applies this functor transformation from F to G

Attributes

Definition Classes
Source
TraceInstrumentation.scala

Inherited methods

def and[H[_]](h: FunctionK[[_] =>> Instrumentation[F, _$4], H]): FunctionK[F, [_] =>> Tuple2K[G, H, _$9]]

Composes two instances of FunctionK into a new FunctionK that transforms one single functor to a cats.data.Tuple2K of two functors.

Composes two instances of FunctionK into a new FunctionK that transforms one single functor to a cats.data.Tuple2K of two functors.

scala> import cats.arrow.FunctionK
scala> val list2option = λ[FunctionK[List, Option]](_.headOption)
scala> val list2vector = λ[FunctionK[List, Vector]](_.toVector)
scala> val optionAndVector = list2option and list2vector
scala> optionAndVector(List(1,2,3))
res0: cats.data.Tuple2K[Option,Vector,Int] = Tuple2K(Some(1),Vector(1, 2, 3))

Attributes

Inherited from:
FunctionK
Source
FunctionK.scala
def andThen[H[_]](f: FunctionK[F, H]): FunctionK[F, H]

Composes two instances of FunctionK into a new FunctionK with this transformation applied first.

Composes two instances of FunctionK into a new FunctionK with this transformation applied first.

Attributes

Inherited from:
FunctionK
Source
FunctionK.scala
def compose[E[_]](f: FunctionK[E, [_] =>> Instrumentation[F, _$4]]): FunctionK[E, G]

Composes two instances of FunctionK into a new FunctionK with this transformation applied last.

Composes two instances of FunctionK into a new FunctionK with this transformation applied last.

Attributes

Inherited from:
FunctionK
Source
FunctionK.scala
def narrow[F0 <: ([x] =>> Instrumentation[F, x])]: FunctionK[F0, G]

Narrows the input type of this FunctionK from F to F0

Narrows the input type of this FunctionK from F to F0

Attributes

Inherited from:
FunctionK
Source
FunctionK.scala
def or[H[_]](h: FunctionK[H, F]): FunctionK[[_] =>> EitherK[F, H, _$6], G]

Composes two instances of FunctionK into a new FunctionK that transforms a cats.data.EitherK to a single functor.

Composes two instances of FunctionK into a new FunctionK that transforms a cats.data.EitherK to a single functor.

This transformation will be used to transform left F values while h will be used to transform right H values.

Attributes

Inherited from:
FunctionK
Source
FunctionK.scala
def widen[G0[x]]: FunctionK[F, G0]

Widens the output type of this FunctionK from G to G0

Widens the output type of this FunctionK from G to G0

Attributes

Inherited from:
FunctionK
Source
FunctionK.scala