diff --git a/build.sbt b/build.sbt index 5f8966d3..96a94805 100644 --- a/build.sbt +++ b/build.sbt @@ -83,6 +83,7 @@ lazy val root = tlCrossRootProject.aggregate( datadog, log, newrelic, + mock, mtl, noop, xray, @@ -331,7 +332,8 @@ lazy val mock = project description := "Mock Open Tracing implementation", libraryDependencies ++= Seq( "io.opentracing" % "opentracing-mock" % "0.33.0" - ) + ), + tlVersionIntroduced := List("2.12", "2.13", "3").map(_ -> "0.3.1").toMap ) lazy val examples = project diff --git a/modules/mock/src/main/scala/MockEntryPoint.scala b/modules/mock/src/main/scala/MockEntryPoint.scala index 03cdb0b0..5fe61ff4 100644 --- a/modules/mock/src/main/scala/MockEntryPoint.scala +++ b/modules/mock/src/main/scala/MockEntryPoint.scala @@ -5,8 +5,6 @@ package natchez package mock -import scala.jdk.CollectionConverters._ - import cats.effect.{Resource, Sync} import io.opentracing.mock.MockTracer import io.opentracing.propagation.{Format, TextMapAdapter} @@ -15,21 +13,22 @@ final case class MockEntrypoint[F[_]: Sync]() extends EntryPoint[F] { val mockTracer = new MockTracer() - override def root(name: String): Resource[F, Span[F]] = + override def root(name: String, options: Span.Options): Resource[F, Span[F]] = Resource .make(Sync[F].delay(mockTracer.buildSpan(name).start()))(span => Sync[F].delay(span.finish())) .map(MockSpan(mockTracer, _)) override def continue( name: String, - kernel: Kernel + kernel: Kernel, + options: Span.Options ): Resource[F, Span[F]] = Resource .make( Sync[F].delay { val spanCtxt = mockTracer.extract( Format.Builtin.HTTP_HEADERS, - new TextMapAdapter(kernel.toHeaders.asJava) + new TextMapAdapter(kernel.toJava) ) mockTracer.buildSpan(name).asChildOf(spanCtxt).start() } @@ -38,7 +37,8 @@ final case class MockEntrypoint[F[_]: Sync]() extends EntryPoint[F] { override def continueOrElseRoot( name: String, - kernel: Kernel + kernel: Kernel, + options: Span.Options ): Resource[F, Span[F]] = continue(name, kernel).flatMap { case null => diff --git a/modules/mock/src/main/scala/MockSpan.scala b/modules/mock/src/main/scala/MockSpan.scala index 5302feae..ec10591e 100644 --- a/modules/mock/src/main/scala/MockSpan.scala +++ b/modules/mock/src/main/scala/MockSpan.scala @@ -27,7 +27,7 @@ final case class MockSpan[F[_]: Sync](tracer: ot.mock.MockTracer, span: ot.mock. Format.Builtin.HTTP_HEADERS, new TextMapAdapter(m) ) - Kernel(m.asScala.toMap) + Kernel.fromJava(m) } def put(fields: (String, TraceValue)*): F[Unit] = @@ -37,7 +37,7 @@ final case class MockSpan[F[_]: Sync](tracer: ot.mock.MockTracer, span: ot.mock. case (k, BooleanValue(v)) => Sync[F].delay(span.setTag(k, v)) } - def attachError(err: Throwable): F[Unit] = + def attachError(err: Throwable, fields: (String, TraceValue)*): F[Unit] = put( Tags.ERROR.getKey -> true ) >> @@ -61,7 +61,7 @@ final case class MockSpan[F[_]: Sync](tracer: ot.mock.MockTracer, span: ot.mock. override def log(event: String): F[Unit] = Sync[F].delay(span.log(event)).void - def span(name: String): Resource[F, Span[F]] = + def span(name: String, options: Span.Options): Resource[F, Span[F]] = Resource .make { Sync[F].delay(tracer.buildSpan(name).asChildOf(span).start) @@ -72,7 +72,7 @@ final case class MockSpan[F[_]: Sync](tracer: ot.mock.MockTracer, span: ot.mock. def span(name: String, kernel: Kernel): Resource[F, Span[F]] = { val parent = - tracer.extract(Format.Builtin.HTTP_HEADERS, new TextMapAdapter(kernel.toHeaders.asJava)) + tracer.extract(Format.Builtin.HTTP_HEADERS, new TextMapAdapter(kernel.toJava)) Resource .make(Sync[F].delay(tracer.buildSpan(name).asChildOf(span).asChildOf(parent).start)) { s => Sync[F].delay(s.finish())