Skip to content

Commit 66ef33b

Browse files
authored
[SDK] Remove TracerConfig copy from Tracer (#4712)
1 parent 2fc5227 commit 66ef33b

3 files changed

Lines changed: 5 additions & 11 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ Increment the:
3535
double range no longer downscales without end.
3636
[#4353](https://github.com/open-telemetry/opentelemetry-cpp/pull/4353)
3737

38+
* [SDK] Remove TracerConfig copy from Tracer
39+
[#4712](https://github.com/open-telemetry/opentelemetry-cpp/pull/4712)
40+
3841
* [LOGS] Fix undefined behavior in `Logger::EmitLogRecord()` when a logger is
3942
enabled (e.g. via `LoggerProvider::UpdateLoggerConfigurator()`) after
4043
`CreateLogRecord()` was called while it was still disabled. The disabled

‎sdk/include/opentelemetry/sdk/trace/tracer.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,6 @@ class Tracer final : public opentelemetry::trace::Tracer,
136136
// tracer-context.
137137
std::shared_ptr<InstrumentationScope> instrumentation_scope_;
138138
std::shared_ptr<TracerContext> context_;
139-
mutable std::mutex tracer_config_mutex_;
140-
TracerConfig tracer_config_;
141139
#if OPENTELEMETRY_ABI_VERSION_NO < 2
142140
std::atomic<bool> is_enabled_{false};
143141
#endif

‎sdk/src/trace/tracer.cc‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
#include <chrono>
55
#include <cstdint>
6-
#include <mutex>
76
#include <utility>
87

98
#include "opentelemetry/context/context.h"
@@ -40,11 +39,10 @@ Tracer::Tracer(std::shared_ptr<TracerContext> context,
4039
std::unique_ptr<InstrumentationScope> instrumentation_scope)
4140
: instrumentation_scope_{std::move(instrumentation_scope)},
4241
context_{std::move(context)},
43-
tracer_config_(context_->GetTracerConfigurator().ComputeConfig(*instrumentation_scope_)),
4442
noop_span_{std::make_shared<opentelemetry::trace::DefaultSpan>(
4543
opentelemetry::trace::SpanContext::GetInvalid())}
4644
{
47-
UpdateEnabled(tracer_config_.IsEnabled());
45+
UpdateTracerConfig(context_->GetTracerConfigurator().ComputeConfig(*instrumentation_scope_));
4846
}
4947

5048
nostd::shared_ptr<opentelemetry::trace::Span> Tracer::StartSpan(
@@ -196,12 +194,7 @@ void Tracer::CloseWithMicroseconds(uint64_t timeout) noexcept
196194

197195
void Tracer::UpdateTracerConfig(TracerConfig config) noexcept
198196
{
199-
const bool enabled = config.IsEnabled();
200-
{
201-
std::lock_guard<std::mutex> lock(tracer_config_mutex_);
202-
tracer_config_ = config;
203-
}
204-
UpdateEnabled(enabled);
197+
UpdateEnabled(config.IsEnabled());
205198
}
206199

207200
} // namespace trace

0 commit comments

Comments
 (0)