Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core-trace: make Backend#end public #623

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions core/trace/src/main/scala/org/typelevel/otel4s/trace/Span.scala
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ object Span {
def setStatus(status: StatusCode): F[Unit]
def setStatus(status: StatusCode, description: String): F[Unit]

private[otel4s] def end: F[Unit]
private[otel4s] def end(timestamp: FiniteDuration): F[Unit]
def end: F[Unit]
def end(timestamp: FiniteDuration): F[Unit]

/** Modify the context `F` using the transformation `f`. */
def mapK[G[_]](f: F ~> G): Backend[G] = new Backend.MappedK(this)(f)
Expand Down Expand Up @@ -224,8 +224,8 @@ object Span {
def setStatus(status: StatusCode): F[Unit] = unit
def setStatus(status: StatusCode, description: String): F[Unit] = unit

private[otel4s] def end: F[Unit] = unit
private[otel4s] def end(timestamp: FiniteDuration): F[Unit] = unit
def end: F[Unit] = unit
def end(timestamp: FiniteDuration): F[Unit] = unit
}

/** Implementation for [[Backend.mapK]]. */
Expand Down Expand Up @@ -263,8 +263,8 @@ object Span {
f(backend.setStatus(status))
def setStatus(status: StatusCode, description: String): G[Unit] =
f(backend.setStatus(status, description))
private[otel4s] def end: G[Unit] = f(backend.end)
private[otel4s] def end(timestamp: FiniteDuration): G[Unit] =
def end: G[Unit] = f(backend.end)
def end(timestamp: FiniteDuration): G[Unit] =
f(backend.end(timestamp))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ private[oteljava] class SpanBackendImpl[F[_]: Sync](
()
}

private[otel4s] def end: F[Unit] =
def end: F[Unit] =
Sync[F].realTime.flatMap(now => end(now))

private[otel4s] def end(timestamp: FiniteDuration): F[Unit] =
def end(timestamp: FiniteDuration): F[Unit] =
Sync[F].delay(jSpan.end(timestamp.length, timestamp.unit))

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,17 @@ private final class SdkSpanBackend[F[_]: Monad: Clock: Console] private (
s.copy(status = StatusData(status, description))
}.void

private[otel4s] def end: F[Unit] =
def end: F[Unit] =
for {
now <- Clock[F].realTime
_ <- end(now)
} yield ()

private[otel4s] def end(timestamp: FiniteDuration): F[Unit] = {
def end(timestamp: FiniteDuration): F[Unit] =
for {
updated <- updateState("end")(s => s.copy(endTimestamp = Some(timestamp)))
_ <- toSpanData.flatMap(span => spanProcessor.onEnd(span)).whenA(updated)
} yield ()
}

private def addTimedEvent(event: EventData): F[Unit] =
updateState("addEvent")(s => s.copy(events = s.events :+ event)).void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@ class SimpleSpanProcessorSuite
def setStatus(status: StatusCode, description: String): IO[Unit] =
noopBackend.setStatus(status, description)

private[otel4s] def end: IO[Unit] =
def end: IO[Unit] =
noopBackend.end

private[otel4s] def end(timestamp: FiniteDuration): IO[Unit] =
def end(timestamp: FiniteDuration): IO[Unit] =
noopBackend.end(timestamp)
}
}
Expand Down