-
-
Notifications
You must be signed in to change notification settings - Fork 45
Open
Description
Hey, I'm currently implementing async-profiler profiling data to be linked with the traces.
This is one case in which custom SpanProcessor may actually be useful to be provided.
Obviously we can work around this by writing a wrapper around TracerProvider to call required methods by ourselves. See:
class ProfilingSpanProcessor(localSpan: LocalSpan) extends SpanProcessor[IO] {
override def name: String = "ProfilingSpanProcessor"
override def onStart: OnStart[IO] = new OnStart[IO] {
override def apply(parentContext: Option[SpanContext], span: SpanRef[IO]): IO[Unit] = {
val spanIdStr = span.context.spanIdHex
val spanId = java.lang.Long.parseUnsignedLong(spanIdStr, 16)
for {
_ <- span.addAttributes(Seq(Attribute("pyroscope.profile.id", spanIdStr)))
_ <- IO(localSpan.set(Some(TraceSpan(spanId))))
} yield ()
}
}
override def onEnd: OnEnd[IO] = new OnEnd[IO] {
override def apply(span: SpanData): IO[Unit] = IO(localSpan.set(None))
}
override def forceFlush: IO[Unit] = IO.unit
}I've also created a discussion that shows the concrete use case.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels