-
Notifications
You must be signed in to change notification settings - Fork 40
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
sdk-trace: add SdkSpanBackend
#395
Conversation
iRevive
commented
Dec 6, 2023
Reference | Link |
---|---|
Java implementation | SdkSpan.java |
af7a3fa
to
6d8dd32
Compare
6d8dd32
to
810556e
Compare
private[trace] final class SdkSpanBackend[F[_]: Monad: Clock: Console] private ( | ||
spanProcessor: SpanProcessor[F], | ||
immutableState: SdkSpanBackend.ImmutableState, | ||
mutableState: AtomicCell[F, SdkSpanBackend.MutableState] |
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.
Can this be a Ref
instead of an AtomicCell
?
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.
Yes, it can
Console[F] | ||
.println( | ||
s"SdkSpanBackend: calling [$method] on the ended span $context" | ||
) |
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.
Since Console
is not a real logger and a lot of users might just pass the default, is this annoying? Or was it just for debugging?
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.
It shouldn't be logged often. If a user uses a library in a general way, these messages will not be logged at all.
The log message may occur if you try to update the span that has already ended.
For example:
for {
escapedSpan <- Tracer[F].span("my-span").use { span =>
IO.pure(span)
}
_ <- escapedSpan.updateName("new name") // <- 'SdkSpanBackend: calling [updateName] on the ended span ...' will be logged
} yield ()
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.
Hmm, right. But it doesn't serious enough to be an errorln
I suppose.
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.
We can hide these warnings behind a config (e.g. traceProvider.enableConsoleWarnings
).
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.
Hmm, right. But it doesn't serious enough to be an
errorln
I suppose.
yeah. If we had a proper logging system, I would use warn
.
} | ||
|
||
private def addTimedEvent(event: EventData): F[Unit] = | ||
updateState("addEvent")(s => s.copy(events = s.events :+ event)).void |
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.
events
is a List
, isn't this pretty inefficient?
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.
Valid point. Let's use Vector
under the hood.
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.
Seems good, didn't look closely at everything, it's private anyway.