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: refactor SpanProcessor #856

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

iRevive
Copy link
Contributor

@iRevive iRevive commented Nov 29, 2024

The original implementation of SpanProcessor is highly influenced by OpenTelemetry Java internals.
For example, isStartRequired and isEndRequired are used for optimization purposes and also aren't required by the spec.

We can replace:

def onStart(parentContext: Option[SpanContext], span: SpanRef[F]): F[Unit]

with:

def onStart: SpanProcessor.OnStart[F]

trait OnStart[F[_]] {
  def apply(parentContext: Option[SpanContext], span: SpanRef[F]): F[Unit]
}

A noop implementation of OnStart can be filtered out when combining multiple processors.

@mergify mergify bot added module:sdk Features and improvements to the sdk module tracing Improvements to tracing module labels Nov 29, 2024
Comment on lines +223 to +228
val start = processors.filter { p =>
p.onStart match {
case _: OnStart.Noop[_] => false
case _ => true
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's how we can filter out noop implementations.

@iRevive iRevive force-pushed the sdk-trace/span-processor-rework branch from b515683 to fb17979 Compare November 29, 2024 10:03
@iRevive iRevive added the breaking The changes are semantically or binary breaking label Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking The changes are semantically or binary breaking 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.

1 participant