From b9ea4c482fae0bd701f9de30b468a49764f1cf31 Mon Sep 17 00:00:00 2001 From: Maksym Ochenashko Date: Mon, 11 Mar 2024 20:06:06 +0200 Subject: [PATCH] oteljava: add `OtelJava.noop` --- .../org/typelevel/otel4s/oteljava/OtelJava.scala | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/oteljava/all/src/main/scala/org/typelevel/otel4s/oteljava/OtelJava.scala b/oteljava/all/src/main/scala/org/typelevel/otel4s/oteljava/OtelJava.scala index e00cd4225..7487a883e 100644 --- a/oteljava/all/src/main/scala/org/typelevel/otel4s/oteljava/OtelJava.scala +++ b/oteljava/all/src/main/scala/org/typelevel/otel4s/oteljava/OtelJava.scala @@ -16,6 +16,7 @@ package org.typelevel.otel4s.oteljava +import cats.Applicative import cats.effect.Async import cats.effect.Resource import cats.effect.Sync @@ -88,6 +89,16 @@ object OtelJava { ) } + /** Creates a no-op implementation of the [[OtelJava]]. + */ + def noop[F[_]: Applicative: LocalContext]: OtelJava[F] = + new OtelJava( + JOpenTelemetry.noop(), + ContextPropagators.noop, + MeterProvider.noop, + TracerProvider.noop + ) + /** Lifts the acquisition of a Java OpenTelemetrySdk instance to a Resource. * * @param acquire