@@ -20,19 +20,35 @@ import OpenTelemetryApi
2020public class TracerProviderSdk : TracerProvider {
2121 private var tracerProvider = [ InstrumentationLibraryInfo: TracerSdk] ( )
2222 internal var sharedState : TracerSharedState
23+ internal static let emptyName = " unknown "
2324
2425 /// Returns a new TracerProviderSdk with default Clock, IdGenerator and Resource.
2526 public init ( clock: Clock = MillisClock ( ) ,
2627 idGenerator: IdGenerator = RandomIdGenerator ( ) ,
27- resource: Resource = EnvVarResource . resource)
28+ resource: Resource = EnvVarResource . resource,
29+ spanLimits: SpanLimits = SpanLimits ( ) ,
30+ sampler: Sampler = Samplers . parentBased ( root: Samplers . alwaysOn) ,
31+ spanProcessors: [ SpanProcessor ] = [ ] )
2832 {
29- sharedState = TracerSharedState ( clock: clock, idGenerator: idGenerator, resource: resource)
33+ sharedState = TracerSharedState ( clock: clock,
34+ idGenerator: idGenerator,
35+ resource: resource,
36+ spanLimits: spanLimits,
37+ sampler: sampler,
38+ spanProcessors: spanProcessors)
3039 }
3140
3241 public func get( instrumentationName: String , instrumentationVersion: String ? = nil ) -> Tracer {
3342 if sharedState. hasBeenShutdown {
3443 return DefaultTracer . instance
3544 }
45+
46+ var instrumentationName = instrumentationName
47+ if instrumentationName. isEmpty {
48+ // Per the spec, empty is "invalid"
49+ print ( " Tracer requested without instrumentation name. " )
50+ instrumentationName = TracerProviderSdk . emptyName
51+ }
3652 let instrumentationLibraryInfo = InstrumentationLibraryInfo ( name: instrumentationName, version: instrumentationVersion ?? " " )
3753 if let tracer = tracerProvider [ instrumentationLibraryInfo] {
3854 return tracer
0 commit comments