Skip to content

Conversation

@iRevive
Copy link
Contributor

@iRevive iRevive commented Oct 29, 2025

The general idea is to make *Testkit entry point more flexible.

In the end, we will have three main entry points:

  1. *Testkit.builder[IO].withXXX(...).withYYY(...).build - creates an instance using customization
  2. *Testkit.inMemory[IO]() - creates an instance using defaults
  3. *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))

@mergify mergify bot added documentation Improvements or additions to documentation module:oteljava Features and improvements to the oteljava module module:sdk Features and improvements to the sdk module metrics Improvement to metrics module tracing Improvements to tracing module logs Improvements to logs module labels Oct 29, 2025
@iRevive iRevive changed the title Add builders to *Testkit Add builders for *Testkit Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation logs Improvements to logs module metrics Improvement to metrics module module:oteljava Features and improvements to the oteljava module module:sdk Features and improvements to the sdk module tracing Improvements to tracing module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant