-
Notifications
You must be signed in to change notification settings - Fork 36
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
Move SpanRunner
outside SpanBuilderImpl
#122
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,9 @@ trait SpanOps[F[_]] { | |
* This strategy can be used when it's necessary to end a span outside of the | ||
* scope (e.g. async callback). Make sure the span is ended properly. | ||
* | ||
* If the start timestamp is not configured explicitly in a builder, the | ||
* `Clock[F].realTime` is used to determine the timestamp. | ||
* | ||
* Leaked span: | ||
* {{{ | ||
* val tracer: Tracer[F] = ??? | ||
|
@@ -55,9 +58,13 @@ trait SpanOps[F[_]] { | |
* The finalization strategy is determined by [[SpanFinalizer.Strategy]]. By | ||
* default, the abnormal termination (error, cancelation) is recorded. | ||
* | ||
* If the start timestamp is not configured explicitly in a builder, the | ||
* `Clock[F].realTime` is used to determine the timestamp. | ||
* | ||
* `Clock[F].realTime` is always used as the end timestamp. | ||
* | ||
* @see | ||
* default finalization strategy [[SpanFinalizer.Strategy.reportAbnormal]] | ||
* | ||
* @example | ||
* {{{ | ||
* val tracer: Tracer[F] = ??? | ||
|
@@ -69,8 +76,33 @@ trait SpanOps[F[_]] { | |
*/ | ||
def use[A](f: Result => F[A]): F[A] | ||
|
||
/** Starts a span and ends it immediately. | ||
* | ||
* A shortcut for: | ||
* {{{ | ||
* val tracer: Tracer[F] = ??? | ||
* val ops: SpanOps.Aux[F, Span[F]] = tracer.spanBuilder("auto-span").build | ||
* ops.use(_ => F.unit) <-> ops.use_ | ||
* }}} | ||
* | ||
* @see | ||
* See [[use]] for more details regarding lifecycle strategy | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, thank you for adding these, too! |
||
def use_ : F[Unit] | ||
|
||
/** Starts a span, runs `fa` and ends the span once `fa` terminates, fails or | ||
* gets interrupted. | ||
* | ||
* A shortcut for: | ||
* {{{ | ||
* val tracer: Tracer[F] = ??? | ||
* val ops: SpanOps.Aux[F, Span[F]] = tracer.spanBuilder("auto-span").build | ||
* ops.use(_ => fa) <-> ops.surround(fa) | ||
* }}} | ||
* | ||
* @see | ||
* See [[use]] for more details regarding lifecycle strategy | ||
*/ | ||
def surround[A](fa: F[A]): F[A] | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ package java | |
package trace | ||
|
||
import cats.effect.Sync | ||
import cats.syntax.flatMap._ | ||
import io.opentelemetry.api.trace.{Span => JSpan} | ||
import io.opentelemetry.api.trace.{StatusCode => JStatusCode} | ||
import org.typelevel.otel4s.Attribute | ||
|
@@ -89,7 +90,7 @@ private[java] class SpanBackendImpl[F[_]: Sync]( | |
} | ||
|
||
private[otel4s] def end: F[Unit] = | ||
Sync[F].delay(jSpan.end()) | ||
Sync[F].realTime.flatMap(now => end(now)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technically, only |
||
|
||
private[otel4s] def end(timestamp: FiniteDuration): F[Unit] = | ||
Sync[F].delay(jSpan.end(timestamp.length, timestamp.unit)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of this code would be inlined by the macros, right? This just bit Circe on Scala 3...
I have a feeling our next release will be 0.2, but as long as we're not changing the public API, this is a noble effort.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, these classes shouldn't appear in the inline positions