Skip to content

Commit

Permalink
Bare minimum to fix compile
Browse files Browse the repository at this point in the history
  • Loading branch information
armanbilge committed Jan 24, 2023
1 parent 2d93303 commit ec6edc4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions modules/mock/src/main/scala/MockEntryPoint.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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()
}
Expand All @@ -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 =>
Expand Down
8 changes: 4 additions & 4 deletions modules/mock/src/main/scala/MockSpan.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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] =
Expand All @@ -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
) >>
Expand All @@ -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)
Expand All @@ -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())
Expand Down

0 comments on commit ec6edc4

Please sign in to comment.