-
Notifications
You must be signed in to change notification settings - Fork 38
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
Experimental sdk-trace
module
#325
Conversation
sdk/trace/src/main/scala/org/typelevel/otel4s/sdk/trace/ReadWriteSpan.scala
Outdated
Show resolved
Hide resolved
sdk/trace/src/main/scala/org/typelevel/otel4s/sdk/trace/SdkSpanBackend.scala
Outdated
Show resolved
Hide resolved
import org.typelevel.otel4s.trace.SpanContext | ||
import org.typelevel.otel4s.trace.Tracer | ||
|
||
final class SdkTracer[F[_]: Concurrent: Clock] private[trace] ( |
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.
Nearly identical to the TracerImpl
in the java module. The different part is:
def spanBuilder(name: String): SpanBuilder[F] =
new SdkSpanBuilder[F](name, scopeInfo, sharedState, scope)
import scala.concurrent.duration._ | ||
|
||
// Tree-like representation of a span | ||
final case class SpanNode( |
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.
Copy-pasted from the java module
import org.typelevel.otel4s.sdk.trace.exporter.BatchSpanProcessor | ||
import org.typelevel.otel4s.sdk.trace.exporter.InMemorySpanExporter | ||
|
||
object TraceSdkExample extends IOApp.Simple { |
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.
A fully functional example
sdk/common/src/main/scala/org/typelevel/otel4s/sdk/context/propagation/TextMapPropagator.scala
Outdated
Show resolved
Hide resolved
|
||
object instances { | ||
// We hope this instance is moved into Cats Effect. | ||
implicit def localForIoLocal[F[_]: MonadCancelThrow: LiftIO, E](implicit |
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.
Copy-pasted from the java module
if (attributes.isEmpty) Applicative[F].unit | ||
else | ||
mutableState.update { s => | ||
s.copy(attributes = s.attributes |+| Attributes(attributes: _*)) |
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.
The spanLimits
should be applied here.
To make it work, we should also tweak the implementation of the Attributes
class.
sdk/trace/src/main/scala/org/typelevel/otel4s/sdk/trace/SdkSpanBackend.scala
Outdated
Show resolved
Hide resolved
# Conflicts: # sdk/common/src/main/scala/org/typelevel/otel4s/sdk/autoconfigure/AutoConfigure.scala # sdk/trace/src/main/scala/org/typelevel/otel4s/sdk/trace/autoconfigure/SamplerAutoConfigure.scala
# Conflicts: # sdk-exporter/trace/shared/src/test/scala/org/typelevel/otel4s/sdk/exporter/otlp/trace/autoconfigure/OtlpSpanExporterAutoConfigureSuite.scala
# Conflicts: # sdk/trace/src/main/scala/org/typelevel/otel4s/sdk/trace/autoconfigure/SpanExportersAutoConfigure.scala
# Conflicts: # sdk/trace/src/main/scala/org/typelevel/otel4s/sdk/trace/SdkTracerProvider.scala # sdk/trace/src/test/scala/org/typelevel/otel4s/sdk/trace/autoconfigure/TracerProviderAutoConfigureSuite.scala
# Conflicts: # build.sbt # sdk/all/src/main/scala/org/typelevel/otel4s/sdk/OpenTelemetrySdk.scala # sdk/all/src/test/scala/org/typelevel/otel4s/sdk/OpenTelemetrySdkSuite.scala # sdk/trace/src/main/scala/org/typelevel/otel4s/sdk/trace/SdkTracerBuilder.scala # sdk/trace/src/main/scala/org/typelevel/otel4s/sdk/trace/SdkTraces.scala # sdk/trace/src/test/scala/org/typelevel/otel4s/sdk/trace/SdkTracesSuite.scala
Almost all changes from this branch exist in the main branch. |
Here is an experimental
sdk-trace
module fully written in Scala.Most of the design decisions were based on the Java implementation, and some can be reconsidered.
Currently, there is only
InMemoryExporter
but it's enough to run tests on Scala Native and ScalaJS platforms.I've copy-pasted the
TracerSuite
from Java module and all tests pass.All other cases work as expected:
W3CTraceContextPropagator
)W3CTraceContextPropagator
)PasstroughPropagator
)Current scope:
private
,private[trace]
, etcW3CTraceContextPropagator
core
andsdk
API. e.g. sdk should useTextMapPropagator
from coreNext steps: