From cafb3aa6360ca94b0e90d41ef2358b8bedf548df Mon Sep 17 00:00:00 2001 From: 47erbot Date: Sat, 18 Feb 2023 11:21:27 +0100 Subject: [PATCH] Update natchez-core, natchez-jaeger to 0.3.1 --- .../HaskellServerScalaClientSpec.scala | 2 +- .../mu/rpc/healthcheck/HealthService.scala | 2 +- .../mu/rpc/internal/tracing/implicits.scala | 5 ++-- .../mu/tests/rpc/ProtobufRPCTest.scala | 2 +- .../mu/rpc/protocol/Tracing.scala | 30 +++++++++++++++---- project/ProjectPlugin.scala | 2 +- 6 files changed, 31 insertions(+), 12 deletions(-) diff --git a/modules/haskell-integration-tests/src/test/scala/integrationtest/protobuf/HaskellServerScalaClientSpec.scala b/modules/haskell-integration-tests/src/test/scala/integrationtest/protobuf/HaskellServerScalaClientSpec.scala index d7ac4c3f8..f05a77289 100644 --- a/modules/haskell-integration-tests/src/test/scala/integrationtest/protobuf/HaskellServerScalaClientSpec.scala +++ b/modules/haskell-integration-tests/src/test/scala/integrationtest/protobuf/HaskellServerScalaClientSpec.scala @@ -17,7 +17,7 @@ package integrationtest.protobuf import cats.effect.{IO, Resource} -import fs2._ +import fs2.Stream import higherkindness.mu.rpc._ import higherkindness.mu.rpc.protocol.Empty import integrationtest._ diff --git a/modules/health-check/src/main/scala/higherkindness/mu/rpc/healthcheck/HealthService.scala b/modules/health-check/src/main/scala/higherkindness/mu/rpc/healthcheck/HealthService.scala index 4cb717947..6fbc88068 100644 --- a/modules/health-check/src/main/scala/higherkindness/mu/rpc/healthcheck/HealthService.scala +++ b/modules/health-check/src/main/scala/higherkindness/mu/rpc/healthcheck/HealthService.scala @@ -23,7 +23,7 @@ import _root_.fs2._ import _root_.fs2.concurrent._ import _root_.grpc.health.v1.health._ import _root_.grpc.health.v1.health.HealthCheckResponse.ServingStatus -import io.grpc.{Status, StatusException} +import _root_.io.grpc.{Status, StatusException} trait HealthService[F[_]] extends Health[F] { diff --git a/modules/service/src/main/scala/higherkindness/mu/rpc/internal/tracing/implicits.scala b/modules/service/src/main/scala/higherkindness/mu/rpc/internal/tracing/implicits.scala index 649457034..6aaa6fc91 100644 --- a/modules/service/src/main/scala/higherkindness/mu/rpc/internal/tracing/implicits.scala +++ b/modules/service/src/main/scala/higherkindness/mu/rpc/internal/tracing/implicits.scala @@ -22,6 +22,7 @@ import higherkindness.mu.rpc.internal.context.{ClientContext, ClientContextMetaD import io.grpc.Metadata.{ASCII_STRING_MARSHALLER, BINARY_HEADER_SUFFIX, Key} import io.grpc.{CallOptions, Channel, Metadata, MethodDescriptor} import natchez.{EntryPoint, Kernel, Span} +import org.typelevel.ci.CIString import scala.jdk.CollectionConverters._ @@ -55,7 +56,7 @@ object implicits { def tracingKernelToHeaders(kernel: Kernel): Metadata = { val headers = new Metadata() kernel.toHeaders.foreach { case (k, v) => - headers.put(Key.of(k, ASCII_STRING_MARSHALLER), v) + headers.put(Key.of(k.toString, ASCII_STRING_MARSHALLER), v) } headers } @@ -66,7 +67,7 @@ object implicits { .asScala .collect { case k if !k.endsWith(BINARY_HEADER_SUFFIX) => - k -> headers.get(Key.of(k, ASCII_STRING_MARSHALLER)) + CIString(k) -> headers.get(Key.of(k, ASCII_STRING_MARSHALLER)) } .toMap Kernel(asciiHeaders) diff --git a/modules/tests/rpc/proto/src/test/scala/higherkindness/mu/tests/rpc/ProtobufRPCTest.scala b/modules/tests/rpc/proto/src/test/scala/higherkindness/mu/tests/rpc/ProtobufRPCTest.scala index 17e02e3e0..73179ad57 100644 --- a/modules/tests/rpc/proto/src/test/scala/higherkindness/mu/tests/rpc/ProtobufRPCTest.scala +++ b/modules/tests/rpc/proto/src/test/scala/higherkindness/mu/tests/rpc/ProtobufRPCTest.scala @@ -16,7 +16,7 @@ package higherkindness.mu.tests.rpc -import _root_.fs2._ +import fs2.Stream import cats.effect.{IO, Resource} import higherkindness.mu.rpc.ChannelForAddress import higherkindness.mu.rpc.protocol.{Gzip, Identity} diff --git a/modules/tests/src/test/scala-2/higherkindness/mu/rpc/protocol/Tracing.scala b/modules/tests/src/test/scala-2/higherkindness/mu/rpc/protocol/Tracing.scala index bff8b1d5c..d84c6dab3 100644 --- a/modules/tests/src/test/scala-2/higherkindness/mu/rpc/protocol/Tracing.scala +++ b/modules/tests/src/test/scala-2/higherkindness/mu/rpc/protocol/Tracing.scala @@ -22,6 +22,7 @@ import natchez._ import java.net.URI import cats.effect.Ref +import org.typelevel.ci.CIString /* * A minimal Natchez tracing implementation that accumulates @@ -47,9 +48,9 @@ object Tracing { IO.unit // not implemented def kernel: IO[Kernel] = - IO.pure(Kernel(Map("span-id" -> id.toString))) + IO.pure(Kernel(Map(CIString("span-id") -> id.toString))) - def span(name: String): Resource[IO, Span[IO]] = + override def span(name: String, options: Span.Options): Resource[IO, Span[IO]] = Resource.make( for { spanId <- ref.modify(_.incrementNextSpanId) @@ -63,12 +64,21 @@ object Tracing { override def traceUri: IO[Option[URI]] = IO.pure(None) override def spanId: IO[Option[String]] = IO.pure(Some(id.toString)) + + override def log(fields: (String, TraceValue)*): IO[Unit] = + IO.unit // not implemented + + override def log(event: String): IO[Unit] = + IO.unit // not implemented + + override def attachError(err: Throwable, fields: (String, TraceValue)*): IO[Unit] = + IO.unit // not implemented } def entrypoint(ref: Ref[IO, TracingData]): EntryPoint[IO] = new EntryPoint[IO] { - def root(name: String): Resource[IO, Span[IO]] = + override def root(name: String, options: Span.Options): Resource[IO, Span[IO]] = Resource.make( for { spanId <- ref.modify(_.incrementNextSpanId) @@ -77,12 +87,16 @@ object Tracing { } yield span )(span => ref.update(_.append(s"End $span"))) - def continue(name: String, kernel: Kernel): Resource[IO, Span[IO]] = + override def continue( + name: String, + kernel: Kernel, + options: Span.Options + ): Resource[IO, Span[IO]] = Resource.make( for { parentSpanId <- IO { kernel.toHeaders - .get("span-id") + .get(CIString("span-id")) .map(_.toInt) .getOrElse(throw new Exception("Required trace header not found!")) } @@ -92,7 +106,11 @@ object Tracing { } yield span )(span => ref.update(_.append(s"End $span"))) - def continueOrElseRoot(name: String, kernel: Kernel): Resource[IO, Span[IO]] = + override def continueOrElseRoot( + name: String, + kernel: Kernel, + options: Span.Options + ): Resource[IO, Span[IO]] = continue(name, kernel).recoverWith { case _: Exception => root(name) } diff --git a/project/ProjectPlugin.scala b/project/ProjectPlugin.scala index ec64b8848..ddcc499e1 100644 --- a/project/ProjectPlugin.scala +++ b/project/ProjectPlugin.scala @@ -32,7 +32,7 @@ object ProjectPlugin extends AutoPlugin { val logback: String = "1.4.5" val munit: String = "0.7.29" val munitCE: String = "1.0.7" - val natchez: String = "0.1.6" + val natchez: String = "0.3.1" val nettySSL: String = "2.0.54.Final" val paradise: String = "2.1.1" val pbdirect: String = "0.7.0"