@@ -38,30 +38,28 @@ namespace sdk
3838{
3939namespace trace
4040{
41- const std::shared_ptr<opentelemetry::trace::NoopTracer> Tracer::kNoopTracer =
42- std::make_shared<opentelemetry::trace::NoopTracer>();
41+ opentelemetry::trace::NoopTracer Tracer::kNoopTracer = opentelemetry::trace::NoopTracer();
4342
4443Tracer::Tracer (std::shared_ptr<TracerContext> context,
4544 std::unique_ptr<InstrumentationScope> instrumentation_scope) noexcept
46- : instrumentation_scope_{std::move (instrumentation_scope)}, context_{std::move (context)}
47- {
48- tracer_config_ =
49- std::make_unique<TracerConfig>(context_->GetTracerConfigurator ()(*instrumentation_scope_));
50- }
45+ : instrumentation_scope_{std::move (instrumentation_scope)},
46+ context_{std::move (context)},
47+ tracer_config_ (context_->GetTracerConfigurator ()(*instrumentation_scope_))
48+ {}
5149
5250nostd::shared_ptr<opentelemetry::trace::Span> Tracer::StartSpan (
5351 nostd::string_view name,
5452 const opentelemetry::common::KeyValueIterable &attributes,
5553 const opentelemetry::trace::SpanContextKeyValueIterable &links,
5654 const opentelemetry::trace::StartSpanOptions &options) noexcept
5755{
56+ if (!tracer_config_.IsEnabled ())
57+ {
58+ return kNoopTracer .StartSpan (name, attributes, links, options);
59+ }
5860 opentelemetry::trace::SpanContext parent_context = GetCurrentSpan ()->GetContext ();
5961 if (nostd::holds_alternative<opentelemetry::trace::SpanContext>(options.parent ))
6062 {
61- if (!tracer_config_->IsEnabled ())
62- {
63- return kNoopTracer ->StartSpan (name, attributes, links, options);
64- }
6563 auto span_context = nostd::get<opentelemetry::trace::SpanContext>(options.parent );
6664 if (span_context.IsValid ())
6765 {
@@ -176,7 +174,7 @@ void Tracer::ForceFlushWithMicroseconds(uint64_t timeout) noexcept
176174void Tracer::CloseWithMicroseconds (uint64_t timeout) noexcept
177175{
178176 // Trace context is shared by many tracers.So we just call ForceFlush to flush all pending spans
179- // and do not shutdown it.
177+ // and do not shutdown it.
180178 if (context_)
181179 {
182180 context_->ForceFlush (
0 commit comments