Skip to content

Commit 48a2fe3

Browse files
committed
Make enabled_ mutable
1 parent c028fda commit 48a2fe3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

api/include/opentelemetry/trace/tracer.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,11 @@ class Tracer
233233

234234
private:
235235
#if OPENTELEMETRY_ABI_VERSION_NO >= 2
236-
// variable to support implementation of Enabled method introduced in ABI V2.
237-
bool enabled_ = true;
236+
// Variable to support implementation of Enabled method introduced in ABI V2.
237+
// Mutable allows enabled_ to be used as 'bool *' (instead of 'const bool *'), with the
238+
// OPENTELEMETRY_ATOMIC_READ_8 macro's internal casts when used from a const function.
239+
// std::atomic can not be used here because it is not ABI compatible for OpenTelemetry C++ API.
240+
mutable bool enabled_ = true;
238241
#endif
239242
};
240243
} // namespace trace

0 commit comments

Comments
 (0)