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

Experimental sdk-trace module #325

Closed
wants to merge 141 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
458dc5f
Draft Trace SDK module
iRevive Sep 29, 2023
6e7e9c0
Enable tests
iRevive Sep 30, 2023
84960aa
Add PassThrough and W3C propagators
iRevive Sep 30, 2023
7bc58f6
Rename `exporters` -> `exporter` package
iRevive Sep 30, 2023
affae32
clean up
iRevive Sep 30, 2023
33eb5c2
create headers
iRevive Sep 30, 2023
36a0762
Run `githubWorkflowGenerate`
iRevive Sep 30, 2023
849252f
Add `Hash` and `Show` instances
iRevive Oct 1, 2023
986b117
Add `BatchSpanProcessor`
iRevive Oct 1, 2023
6aeaa1c
Refactor `TracerSuite`
iRevive Oct 1, 2023
a4d8ce4
Add `TracerSdkExample`
iRevive Oct 1, 2023
6e06558
Run `scalafix` and `scalafmt`
iRevive Oct 1, 2023
673cf38
Fix compilation issue
iRevive Oct 1, 2023
e582c84
Create headers
iRevive Oct 1, 2023
75e2b50
Fix JS compilation issue
iRevive Oct 1, 2023
e9f9466
Fix JS compilation issue
iRevive Oct 1, 2023
a9381d0
Add samplers
iRevive Oct 1, 2023
3ce9aa5
Run scalafmt and scalafix
iRevive Oct 1, 2023
edc107d
Create headers
iRevive Oct 1, 2023
e0242f7
Fix doc
iRevive Oct 1, 2023
b3a72a8
Relax `Async` constraint, fix unidoc classpath issue
iRevive Oct 1, 2023
f718351
Remove duplicated `TextMapPropagator` and `ContextPropagators`
iRevive Oct 1, 2023
e327166
Make `SpanContext` sealed, move `vault` dependency to the `java-commo…
iRevive Oct 2, 2023
1ecb8b8
Add tests
iRevive Oct 2, 2023
021686d
run scalafix
iRevive Oct 2, 2023
a134642
Remove redundant fields from the `Sampler.shouldSample` interface
iRevive Oct 2, 2023
b21482b
Replace `ReadWriteSpan` with `SpanView`
iRevive Oct 2, 2023
3ccca90
Add additional tests
iRevive Oct 2, 2023
abaceeb
Fix no-op tracing scope
iRevive Oct 2, 2023
13a17c0
Rework W3CTraceContextPropagator
iRevive Oct 2, 2023
551b215
Merge branch 'upstream-main' into trace-sdk
iRevive Oct 3, 2023
fd7d506
Fix compilation issue
iRevive Oct 3, 2023
7f9f0a7
Merge branch 'upstream-main' into trace-sdk
iRevive Oct 3, 2023
87815e0
Merge upstream
iRevive Oct 3, 2023
9d1b80b
Update header
iRevive Oct 4, 2023
91e4cb1
Merge upstream
iRevive Oct 4, 2023
410e13a
Merge branch 'upstream-main' into trace-sdk
iRevive Nov 5, 2023
4e8d392
Merge upstream
iRevive Nov 5, 2023
17265ca
Remove redundant changes
iRevive Nov 5, 2023
02b6830
Merge branch 'upstream-main' into trace-sdk
iRevive Nov 9, 2023
0a448de
Merge upstream
iRevive Nov 9, 2023
682f219
Fix compilation issue
iRevive Nov 10, 2023
437963a
remove `InstrumentationScopeInfo` in favor of `InstrumentationScope`
iRevive Nov 10, 2023
767f45c
Merge branch 'upstream-main' into trace-sdk
iRevive Nov 10, 2023
54e3ef4
Merge branch 'upstream-main' into trace-sdk
iRevive Nov 13, 2023
17164ae
merge upstream
iRevive Nov 13, 2023
bf89736
Merge branch 'upstream-main' into trace-sdk
iRevive Nov 14, 2023
c17665b
merge upstream
iRevive Nov 14, 2023
e8fb815
Merge branch 'upstream-main' into trace-sdk
iRevive Nov 15, 2023
4d37b25
merge upstream
iRevive Nov 15, 2023
e2a876d
Merge branch 'upstream-main' into trace-sdk
iRevive Nov 15, 2023
457b4fd
merge upstream
iRevive Nov 15, 2023
80d609d
Rename `SpanView` -> `SpanRef`
iRevive Nov 15, 2023
301abeb
Redefine `SpanRef`
iRevive Nov 16, 2023
d14cd97
Merge branch 'upstream-main' into trace-sdk
iRevive Nov 25, 2023
f6e1cdd
Merge upstream
iRevive Nov 25, 2023
69f9bc5
Merge branch 'upstream-main' into trace-sdk
iRevive Nov 28, 2023
e95828f
merge upstream
iRevive Nov 28, 2023
ab21f4b
Merge branch 'upstream-main' into trace-sdk
iRevive Nov 28, 2023
8d22065
Implement `currentSpanOrNoop`
iRevive Dec 1, 2023
13a5362
Merge branch 'upstream-main' into trace-sdk
iRevive Dec 1, 2023
ac1eae9
Merge upstream
iRevive Dec 1, 2023
1cbcff8
Generate headers
iRevive Dec 1, 2023
95a4492
move `SdkTracerProviderBuilder` to `SdkTracerProvider.Builder`
iRevive Dec 6, 2023
a9b3a63
add docs and tests for `SdkTraceScope`
iRevive Dec 6, 2023
e134b6a
add headers
iRevive Dec 6, 2023
d70a75d
improve documentation of hte `SdkTraceScope`
iRevive Dec 8, 2023
b54f6df
create headers
iRevive Dec 8, 2023
7ca04b3
SpanStorage: use `Ref` instead of `AtomicCell`
iRevive Dec 8, 2023
5d3e3e5
SpanStorage: make it private
iRevive Dec 8, 2023
e7b4832
Merge branch 'upstream-main' into trace-sdk
iRevive Dec 8, 2023
c3585d0
merge upstream
iRevive Dec 8, 2023
40891c9
fix scaladoc
iRevive Dec 8, 2023
b19605a
Merge branch 'upstream-main' into trace-sdk
iRevive Dec 12, 2023
a150173
allow propagating spans but not recording them
iRevive Dec 16, 2023
43f9cc8
make `propagating` package-private
iRevive Dec 16, 2023
323514b
Merge branch 'upstream-main' into trace-sdk
iRevive Dec 16, 2023
d516195
merge upstream
iRevive Dec 16, 2023
8086d78
Merge branch 'upstream-main' into trace-sdk
iRevive Dec 16, 2023
d511a69
merge upstream
iRevive Dec 16, 2023
b827b2b
Merge branch 'upstream-main' into trace-sdk
iRevive Dec 25, 2023
8e2a9d7
Merge upstream
iRevive Dec 25, 2023
526f946
fix scaladoc
iRevive Dec 25, 2023
12a859c
remove old `PassThroughPropagator`
iRevive Dec 25, 2023
a883f8d
Add `OpenTelemetrySdk` and autoconfigured loader
iRevive Dec 25, 2023
6f8267c
Merge branch 'upstream-main' into trace-sdk
iRevive Dec 27, 2023
0e58bd0
merge upstream
iRevive Dec 27, 2023
9724a39
Merge branch 'upstream-main' into trace-sdk
iRevive Jan 7, 2024
331f8c7
merge upstream
iRevive Jan 7, 2024
c2d2b02
fix compilation issue
iRevive Jan 7, 2024
d33edec
Merge branch 'upstream-main' into trace-sdk
iRevive Jan 18, 2024
dec3c3e
merge upstream
iRevive Jan 18, 2024
4dd1fba
run scalafix & scalafmt
iRevive Jan 18, 2024
5ce21cc
Merge branch 'upstream-main' into trace-sdk
iRevive Jan 19, 2024
8c414c5
Merge branch 'upstream-main' into trace-sdk
iRevive Jan 20, 2024
fccaee5
Fix compilation issues
iRevive Jan 20, 2024
0f2b659
rollback non-mandatory scaladoc changes
iRevive Jan 20, 2024
2348a3a
rename `ContextCarrier` -> `LocalProvider`
iRevive Jan 20, 2024
3f2fa65
backport config changes
iRevive Jan 20, 2024
34a5092
backport changes
iRevive Jan 20, 2024
94e7386
Merge branch 'upstream-main' into trace-sdk
iRevive Jan 29, 2024
ec7f381
add b3 propagators to the configuration
iRevive Jan 29, 2024
0eb4824
Merge branch 'upstream-main' into trace-sdk
iRevive Feb 1, 2024
2c6adcf
merge upstream
iRevive Feb 1, 2024
220245f
resolve all propagators
iRevive Feb 1, 2024
b9ef6c3
add `configKeys` to the error
iRevive Feb 2, 2024
efb017c
Merge branch 'upstream-main' into trace-sdk
iRevive Feb 2, 2024
86c3fcf
Merge branch 'upstream-main' into trace-sdk
iRevive Feb 2, 2024
05f79dd
fix compilation issue
iRevive Feb 2, 2024
0ed1662
Merge branch 'upstream-main' into trace-sdk
iRevive Feb 4, 2024
b5e1fb3
Add `OtlpSpanExporterAutoConfigure`
iRevive Feb 5, 2024
14e8f24
fix compilation
iRevive Feb 5, 2024
cb11667
fix compilation
iRevive Feb 5, 2024
59ab4b9
add 'otlp missing' warning
iRevive Feb 5, 2024
6651392
add `OpenTelemetrySdk.autoConfigured`
iRevive Feb 5, 2024
be87a69
Merge branch 'upstream-main' into trace-sdk
iRevive Feb 5, 2024
7b76495
merge upstream
iRevive Feb 5, 2024
af028a0
clean up
iRevive Feb 5, 2024
08d2cd6
fix scalajs linker settings
iRevive Feb 5, 2024
072a397
backport changes
iRevive Feb 6, 2024
79cb9be
Merge branch 'upstream-main' into trace-sdk
iRevive Feb 7, 2024
bbcba90
Merge branch 'upstream-main' into trace-sdk
iRevive Feb 7, 2024
cb30fa0
Merge branch 'upstream-main' into trace-sdk
iRevive Feb 8, 2024
cddc710
remove `TracerProviderAutoConfigure`
iRevive Feb 8, 2024
015add6
fix compilation issue
iRevive Feb 8, 2024
9a172db
Merge branch 'upstream-main' into trace-sdk
iRevive Feb 8, 2024
2115fd8
backport changes
iRevive Feb 8, 2024
cc3d732
add `SdkTraces`
iRevive Feb 9, 2024
d27c4c0
Merge branch 'upstream-main' into trace-sdk
iRevive Feb 9, 2024
a0db1da
fix typo
iRevive Feb 9, 2024
70fc5e6
SdkTraces: add scaladocs
iRevive Feb 9, 2024
615e4b9
SdkTraces: add tests
iRevive Feb 10, 2024
e09a3c4
Merge branch 'upstream-main' into trace-sdk
iRevive Feb 13, 2024
02ca139
merge upstream
iRevive Feb 13, 2024
073bc27
add `TracerProviderAutoConfigure`
iRevive Feb 13, 2024
75c528c
Merge branch 'upstream-main' into trace-sdk
iRevive Feb 13, 2024
1b4ef0c
Merge branch 'upstream-main' into trace-sdk
iRevive Feb 14, 2024
712afd0
fix tests
iRevive Feb 14, 2024
0e4dd96
add `OpenTelemetrySdkSuite`
iRevive Feb 14, 2024
5816363
Merge branch 'upstream-main' into trace-sdk
iRevive Feb 19, 2024
82c98fa
run scalafmt
iRevive Feb 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ lazy val benchmarks = project
lazy val examples = project
.enablePlugins(NoPublishPlugin, JavaAgent)
.in(file("examples"))
.dependsOn(core.jvm, oteljava)
.dependsOn(core.jvm, oteljava, sdk.jvm, `sdk-exporter`.jvm)
.settings(
name := "otel4s-examples",
libraryDependencies ++= Seq(
Expand Down
40 changes: 40 additions & 0 deletions examples/src/main/scala/TraceSdkExample.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2022 Typelevel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import cats.effect._
import org.typelevel.otel4s.Attribute
import org.typelevel.otel4s.sdk.OpenTelemetrySdk
import org.typelevel.otel4s.sdk.exporter.otlp.trace.autoconfigure.OtlpSpanExporterAutoConfigure

object TraceSdkExample extends IOApp.Simple {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A fully functional example


def run: IO[Unit] =
OpenTelemetrySdk
.autoConfigured[IO](
_.addExporterConfigurer(OtlpSpanExporterAutoConfigure[IO])
)
.use { autoConfigured =>
val sdk = autoConfigured.sdk

for {
tracer <- sdk.tracerProvider.get("my-tracer")
_ <- tracer
.span("test", Attribute("test", "test123"))
.use(sd => IO.println(sd.context))
} yield ()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import org.typelevel.otel4s.sdk.autoconfigure.AutoConfigure
import org.typelevel.otel4s.sdk.autoconfigure.Config
import org.typelevel.otel4s.sdk.context.Context
import org.typelevel.otel4s.sdk.trace.NoopConsole
import org.typelevel.otel4s.sdk.trace.SpanLimits
import org.typelevel.otel4s.sdk.trace.context.propagation.W3CBaggagePropagator
import org.typelevel.otel4s.sdk.trace.context.propagation.W3CTraceContextPropagator
import org.typelevel.otel4s.sdk.trace.data.LinkData
Expand Down Expand Up @@ -272,7 +273,7 @@ class OpenTelemetrySdkSuite extends CatsEffectSuite {
"OpenTelemetrySdk.AutoConfigured{sdk=" +
"OpenTelemetrySdk{meterProvider=MeterProvider.Noop, " +
"tracerProvider=" +
s"SdkTracerProvider{resource=$resource, sampler=$sampler, " +
s"SdkTracerProvider{resource=$resource, spanLimits=${SpanLimits.Default}, sampler=$sampler, " +
"spanProcessor=SpanProcessor.Multi(" +
s"BatchSpanProcessor{exporter=$exporter, scheduleDelay=5 seconds, exporterTimeout=30 seconds, maxQueueSize=2048, maxExportBatchSize=512}, " +
"SpanStorage)}, " +
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright 2023 Typelevel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.typelevel.otel4s
package sdk
package internal

import org.typelevel.otel4s.sdk.common.InstrumentationScope

// todo: implement caching
final class ComponentRegistry[F[_], A](
factory: InstrumentationScope => F[A]
) {

def get(
name: String,
version: Option[String],
schemaUrl: Option[String],
attributes: Attributes
): F[A] = {
buildComponent(
InstrumentationScope(name, version, schemaUrl, attributes)
)
}

private def buildComponent(info: InstrumentationScope): F[A] = {
val component = factory(info)
component
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ import scala.concurrent.duration.FiniteDuration
* the higher-kinded type of a polymorphic effect
*/
private final class SdkSpanBackend[F[_]: Monad: Clock: Console] private (
spanLimits: SpanLimits,
spanProcessor: SpanProcessor[F],
immutableState: SdkSpanBackend.ImmutableState,
mutableState: Ref[F, SdkSpanBackend.MutableState]
Expand Down Expand Up @@ -146,7 +147,16 @@ private final class SdkSpanBackend[F[_]: Monad: Clock: Console] private (
}

private def addTimedEvent(event: EventData): F[Unit] =
updateState("addEvent")(s => s.copy(events = s.events :+ event)).void
updateState("addEvent") { s =>
if (s.events.sizeIs <= spanLimits.maxNumberOfEvents) {
s.copy(
events = s.events :+ event,
totalRecordedEvents = s.totalRecordedEvents + 1
)
} else {
s.copy(totalRecordedEvents = s.totalRecordedEvents + 1)
}
}.void

// applies modifications while the span is still active
// modifications are ignored when the span is ended
Expand Down Expand Up @@ -193,6 +203,10 @@ private final class SdkSpanBackend[F[_]: Monad: Clock: Console] private (
attributes = state.attributes,
events = state.events,
links = immutableState.links,
/*totalRecordedEvents = state.totalRecordedEvents,
totalRecordedLinks = immutableState.totalRecordedLinks,
totalAttributeCount =
state.attributes.size, // todo: incorrect when limits are applied,*/
instrumentationScope = immutableState.scopeInfo,
resource = immutableState.resource
)
Expand Down Expand Up @@ -255,9 +269,11 @@ private object SdkSpanBackend {
resource: TelemetryResource,
kind: SpanKind,
parentContext: Option[SpanContext],
spanLimits: SpanLimits,
processor: SpanProcessor[F],
attributes: Attributes,
links: Vector[LinkData],
totalRecordedLinks: Int,
userStartTimestamp: Option[FiniteDuration]
): F[SdkSpanBackend[F]] = {
def immutableState(startTimestamp: FiniteDuration) =
Expand All @@ -268,6 +284,7 @@ private object SdkSpanBackend {
parentContext = parentContext,
resource = resource,
links = links,
totalRecordedLinks = totalRecordedLinks,
startTimestamp = startTimestamp
)

Expand All @@ -276,13 +293,19 @@ private object SdkSpanBackend {
status = StatusData.Unset,
attributes = attributes,
events = Vector.empty,
totalRecordedEvents = 0,
endTimestamp = None
)

for {
start <- userStartTimestamp.fold(Clock[F].realTime)(_.pure)
state <- Ref[F].of(mutableState)
backend = new SdkSpanBackend[F](processor, immutableState(start), state)
backend = new SdkSpanBackend[F](
spanLimits,
processor,
immutableState(start),
state
)
_ <- processor.onStart(parentContext, backend)
} yield backend
}
Expand All @@ -294,6 +317,7 @@ private object SdkSpanBackend {
parentContext: Option[SpanContext],
resource: TelemetryResource,
links: Vector[LinkData],
totalRecordedLinks: Int,
startTimestamp: FiniteDuration
)

Expand All @@ -304,6 +328,7 @@ private object SdkSpanBackend {
status: StatusData,
attributes: Attributes,
events: Vector[EventData],
totalRecordedEvents: Int,
endTimestamp: Option[FiniteDuration]
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,11 @@ private final case class SdkSpanBuilder[F[_]: Temporal: Console](
resource = tracerSharedState.resource,
kind = spanKind,
parentContext = parentSpanContext,
spanLimits = tracerSharedState.spanLimits,
processor = tracerSharedState.spanProcessor,
attributes = attrs |+| samplingResult.attributes,
links = links,
totalRecordedLinks = links.size,
userStartTimestamp = startTimestamp
)
.widen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,18 @@
* limitations under the License.
*/

package org.typelevel.otel4s.sdk
package org.typelevel.otel4s
package sdk
package trace

import cats.effect.Temporal
import cats.effect.std.Console
import org.typelevel.otel4s.Attributes
import org.typelevel.otel4s.context.propagation.ContextPropagators
import org.typelevel.otel4s.sdk.common.InstrumentationScope
import org.typelevel.otel4s.sdk.context.Context
import org.typelevel.otel4s.sdk.trace.processor.SpanStorage
import org.typelevel.otel4s.trace.TraceScope
import cats.Functor
import cats.syntax.functor._
import org.typelevel.otel4s.sdk.internal.ComponentRegistry
import org.typelevel.otel4s.trace.Tracer
import org.typelevel.otel4s.trace.TracerBuilder

private final case class SdkTracerBuilder[F[_]: Temporal: Console](
propagators: ContextPropagators[Context],
traceScope: TraceScope[F, Context],
sharedState: TracerSharedState[F],
storage: SpanStorage[F],
private final case class SdkTracerBuilder[F[_]: Functor](
registry: ComponentRegistry[F, SdkTracer[F]],
name: String,
version: Option[String] = None,
schemaUrl: Option[String] = None
Expand All @@ -45,13 +38,5 @@ private final case class SdkTracerBuilder[F[_]: Temporal: Console](
copy(schemaUrl = Option(schemaUrl))

def get: F[Tracer[F]] =
Temporal[F].pure(
new SdkTracer[F](
InstrumentationScope(name, version, schemaUrl, Attributes.empty),
propagators,
sharedState,
traceScope,
storage
)
)
registry.get(name, version, schemaUrl, Attributes.empty).widen
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import org.typelevel.otel4s.context.propagation.ContextPropagators
import org.typelevel.otel4s.context.propagation.TextMapPropagator
import org.typelevel.otel4s.sdk.context.Context
import org.typelevel.otel4s.sdk.context.LocalContext
import org.typelevel.otel4s.sdk.internal.ComponentRegistry
import org.typelevel.otel4s.sdk.trace.processor.SpanProcessor
import org.typelevel.otel4s.sdk.trace.processor.SpanStorage
import org.typelevel.otel4s.sdk.trace.samplers.Sampler
Expand All @@ -36,6 +37,7 @@ import org.typelevel.otel4s.trace.TracerProvider
private class SdkTracerProvider[F[_]: Temporal: Parallel: Console](
idGenerator: IdGenerator[F],
resource: TelemetryResource,
spanLimits: SpanLimits,
sampler: Sampler,
propagators: ContextPropagators[Context],
spanProcessors: List[SpanProcessor[F]],
Expand All @@ -47,16 +49,33 @@ private class SdkTracerProvider[F[_]: Temporal: Parallel: Console](
TracerSharedState(
idGenerator,
resource,
spanLimits,
sampler,
SpanProcessor.of(spanProcessors: _*)
)

private val registry: ComponentRegistry[F, SdkTracer[F]] =
new ComponentRegistry[F, SdkTracer[F]](scopeInfo =>
Temporal[F].pure(
new SdkTracer[F](
scopeInfo,
propagators,
sharedState,
traceScope,
storage
)
)
)

def tracer(name: String): TracerBuilder[F] =
new SdkTracerBuilder[F](propagators, traceScope, sharedState, storage, name)
new SdkTracerBuilder[F](registry, name)

override def toString: String =
s"SdkTracerProvider{resource=$resource, sampler=$sampler, spanProcessor=${sharedState.spanProcessor}}"

"SdkTracerProvider{" +
s"resource=$resource, " +
s"spanLimits=$spanLimits, " +
s"sampler=$sampler, " +
s"spanProcessor=${sharedState.spanProcessor}}"
}

object SdkTracerProvider {
Expand Down Expand Up @@ -105,6 +124,16 @@ object SdkTracerProvider {
*/
def addResource(resource: TelemetryResource): Builder[F]

/** Sets an initial [[SpanLimits]] that should be used with this SDK.
*
* The limits will be used for every
* [[org.typelevel.otel4s.trace.Span Span]].
*
* @param limits
* the [[SpanLimits]] to use
*/
def withSpanLimits(limits: SpanLimits): Builder[F]

/** Sets a [[org.typelevel.otel4s.sdk.trace.samplers.Sampler Sampler]].
*
* The sampler will be called each time a
Expand Down Expand Up @@ -161,6 +190,7 @@ object SdkTracerProvider {
BuilderImpl[F](
idGenerator = IdGenerator.random,
resource = TelemetryResource.default,
spanLimits = SpanLimits.Default,
sampler = Sampler.parentBased(Sampler.AlwaysOn),
propagators = Nil,
spanProcessors = Nil
Expand All @@ -171,6 +201,7 @@ object SdkTracerProvider {
](
idGenerator: IdGenerator[F],
resource: TelemetryResource,
spanLimits: SpanLimits,
sampler: Sampler,
propagators: List[TextMapPropagator[Context]],
spanProcessors: List[SpanProcessor[F]]
Expand All @@ -185,6 +216,9 @@ object SdkTracerProvider {
def addResource(resource: TelemetryResource): Builder[F] =
copy(resource = this.resource.mergeUnsafe(resource))

def withSpanLimits(limits: SpanLimits): Builder[F] =
copy(spanLimits = limits)

def withSampler(sampler: Sampler): Builder[F] =
copy(sampler = sampler)

Expand All @@ -201,6 +235,7 @@ object SdkTracerProvider {
new SdkTracerProvider[F](
idGenerator,
resource,
spanLimits,
sampler,
ContextPropagators.of(propagators: _*),
spanProcessors :+ storage,
Expand Down
Loading