I have some unit tests referring to code that makes calls to OpenTelemetry io.opentelemetry.api.trace.Tracer
and Span
etc.
Can someone please help me get an instance of the io.opentelemetry.api.trace.DefaultTracer
where it uses NoopSpanBuilder
to provide a stubbed out code?
I don’t want to test anything to do with the tracing, so I don’t want to use the MockServer approach. I also don’t want to use Mockito to mock the tracing classes because there is a lot of concurrency that causes trouble with Mockito.
I started to write a couple of classes with stubbed out methods and then found that is what the io.opentelemetry.api.trace.DefaultTracer
class has, but I can’t seem to get an instance of it.
I have been calling
Tracer tracer = GlobalOpenTelemetry.getTracerProvider().tracerBuilder("LocalTracer").build();
but I think there is probably some unwanted overhead of calling the real tracer.
I appreciate any help you may be able to provide.