otel4s
otel4s copied to clipboard
Add builders for `*Testkit`
The general idea is to make *Testkit entry point more flexible.
In the end, we will have three main entry points:
*Testkit.builder[IO].withXXX(...).withYYY(...).build- creates an instance using customization*Testkit.inMemory[IO]()- creates an instance using defaults*Testkit.inMemory[IO](_.withXXX(...))- a mix of 1st and 2nd option, a bit more ergonomic when you need to apply a few customizations
Questions:
1. Do we need option 3: *Testkit.inMemory[IO](_.withXXX(...))?
It requires a default argument to be resolved properly:
def inMemory[F[_]: Async: LocalContextProvider](
customize: Builder[F] => Builder[F] = identity[Builder[F]](_)
): Resource[F, MetricsTestkit[F]] =
customize(builder[F]).build
Two overloaded variants for some reason don't work:
def inMemory[F[_]: Async: LocalContextProvider]: Resource[F, MetricsTestkit[F]] =
builder[F].build
def inMemory[F[_]: Async: LocalContextProvider](
customize: Builder[F] => Builder[F]
): Resource[F, MetricsTestkit[F]] =
customize(builder[F]).build
///
MetricsTestkit.inMemory[IO] // compiles fine
MetricsTestkit.inMemory[IO](_.addMeterProviderCustomizer(null)) // fails with
// missing parameter type for expanded function ((<x$19: error>) => x$19.addMeterProviderCustomizer(null))