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

sdk-trace: add SpanProcessor #374

Merged
merged 1 commit into from
Nov 25, 2023

Conversation

iRevive
Copy link
Contributor

@iRevive iRevive commented Nov 16, 2023

Reference Link
Spec https://opentelemetry.io/docs/specs/otel/trace/sdk/#span-processor
Java implementation SpanProcessor.java
ReadWriteSpan.java
ReadableSpan.java

Why do we need a SpanRef?

Some SpanProcessors may require access to the internal state of a span (e.g. actual name, SpanData, etc). The changes made to the span must be accessible by the processor. For example, we can implement a span leak detector that determines whether the span is leaked based on the state.

P.S. Java SDK calls the interface ReadableSpan rather than SpanRef. So, I'm open to better name suggestions :)

@iRevive iRevive added tracing Improvements to tracing module module:sdk Features and improvements to the sdk module labels Nov 16, 2023
@iRevive iRevive force-pushed the sdk-trace/span-processor branch 2 times, most recently from d488cd9 to 04d067c Compare November 16, 2023 18:14
@iRevive iRevive merged commit 827f5f0 into typelevel:main Nov 25, 2023
10 checks passed
@iRevive iRevive deleted the sdk-trace/span-processor branch November 25, 2023 08:36
* @tparam F
* the higher-kinded type of a polymorphic effect
*/
trait SpanRef[F[_]] { self: Span.Backend[F] =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to be late 😅 but I do think we should bikeshed this name. As far as I understand there is nothing Ref-like here, i.e. you can't set anything. But you may read effectually, which does make it similar to RefSource.

Sorry, I don't have better naming ideas 😕

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Java SDK uses ReadWriteSpan and ReadableSpan.
ReadWriteSpan is not ideal, but more meaningful

def isEndRequired: Boolean = endOnly.nonEmpty

def onStart(parentCtx: Option[SpanContext], span: SpanRef[F]): F[Unit] =
startOnly.parTraverse_(_.onStart(parentCtx, span))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usual issue here about failure and short-circuiting.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.attempt should be enough

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module:sdk Features and improvements to the sdk module tracing Improvements to tracing module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants