Skip to content

Commit ed84877

Browse files
[SDK] Swap Tracer/Meter/LoggerConfig disabled for enabled (#3942)
1 parent 61e550e commit ed84877

File tree

7 files changed

+26
-15
lines changed

7 files changed

+26
-15
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,19 @@ Increment the:
8181
* [CODE HEALTH] Fix clang-tidy performance warnings
8282
[#3941](https://github.com/open-telemetry/opentelemetry-cpp/pull/3941)
8383

84+
* [SDK] Swap Tracer/Meter/LoggerConfig disabled for enabled
85+
[#3942](https://github.com/open-telemetry/opentelemetry-cpp/pull/3942)
86+
8487
Important changes:
8588

89+
* [SDK] Swap Tracer/Meter/LoggerConfig disabled for enabled
90+
[#3942](https://github.com/open-telemetry/opentelemetry-cpp/pull/3942)
91+
92+
* In TracerConfig(bool), MeterConfig(bool), and LoggerConfig(bool),
93+
the boolean parameter now represents `enabled` instead of `disabled`.
94+
* User code calling these constructors explicitly must be adjusted
95+
to pass `false` to disable.
96+
8697
* [BUILD] Revisit EventLogger deprecation
8798
[#3855](https://github.com/open-telemetry/opentelemetry-cpp/pull/3855)
8899

sdk/include/opentelemetry/sdk/logs/logger_config.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ class OPENTELEMETRY_EXPORT LoggerConfig
4949
static LoggerConfig Default();
5050

5151
private:
52-
explicit LoggerConfig(const bool disabled = false) : disabled_(disabled) {}
52+
explicit LoggerConfig(const bool enabled = true) : enabled_(enabled) {}
5353

54-
bool disabled_;
54+
bool enabled_;
5555
};
5656
} // namespace logs
5757
} // namespace sdk

sdk/include/opentelemetry/sdk/metrics/meter_config.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ class OPENTELEMETRY_EXPORT MeterConfig
4949
static MeterConfig Default();
5050

5151
private:
52-
explicit MeterConfig(const bool disabled = false) : disabled_(disabled) {}
53-
bool disabled_;
52+
explicit MeterConfig(const bool enabled = true) : enabled_(enabled) {}
53+
bool enabled_;
5454
};
5555
} // namespace metrics
5656
} // namespace sdk

sdk/include/opentelemetry/sdk/trace/tracer_config.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ class OPENTELEMETRY_EXPORT TracerConfig
4949
static TracerConfig Default();
5050

5151
private:
52-
explicit TracerConfig(const bool disabled = false) : disabled_(disabled) {}
53-
bool disabled_;
52+
explicit TracerConfig(const bool enabled = true) : enabled_(enabled) {}
53+
bool enabled_;
5454
};
5555
} // namespace trace
5656
} // namespace sdk

sdk/src/logs/logger_config.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ namespace logs
1111

1212
OPENTELEMETRY_EXPORT bool LoggerConfig::operator==(const LoggerConfig &other) const noexcept
1313
{
14-
return disabled_ == other.disabled_;
14+
return enabled_ == other.enabled_;
1515
}
1616

1717
OPENTELEMETRY_EXPORT bool LoggerConfig::IsEnabled() const noexcept
1818
{
19-
return !disabled_;
19+
return enabled_;
2020
}
2121

2222
OPENTELEMETRY_EXPORT LoggerConfig LoggerConfig::Enabled()
@@ -26,7 +26,7 @@ OPENTELEMETRY_EXPORT LoggerConfig LoggerConfig::Enabled()
2626

2727
OPENTELEMETRY_EXPORT LoggerConfig LoggerConfig::Disabled()
2828
{
29-
static const auto kDisabledConfig = LoggerConfig(true);
29+
static const auto kDisabledConfig = LoggerConfig(false);
3030
return kDisabledConfig;
3131
}
3232

sdk/src/metrics/meter_config.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ namespace metrics
1010

1111
OPENTELEMETRY_EXPORT bool MeterConfig::operator==(const MeterConfig &other) const noexcept
1212
{
13-
return disabled_ == other.disabled_;
13+
return enabled_ == other.enabled_;
1414
}
1515

1616
OPENTELEMETRY_EXPORT bool MeterConfig::IsEnabled() const noexcept
1717
{
18-
return !disabled_;
18+
return enabled_;
1919
}
2020

2121
OPENTELEMETRY_EXPORT MeterConfig MeterConfig::Disabled()
2222
{
23-
static const auto kDisabledConfig = MeterConfig(true);
23+
static const auto kDisabledConfig = MeterConfig(false);
2424
return kDisabledConfig;
2525
}
2626

sdk/src/trace/tracer_config.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace trace
1111

1212
OPENTELEMETRY_EXPORT TracerConfig TracerConfig::Disabled()
1313
{
14-
static const auto kDisabledConfig = TracerConfig(true);
14+
static const auto kDisabledConfig = TracerConfig(false);
1515
return kDisabledConfig;
1616
}
1717

@@ -28,12 +28,12 @@ OPENTELEMETRY_EXPORT TracerConfig TracerConfig::Default()
2828

2929
OPENTELEMETRY_EXPORT bool TracerConfig::IsEnabled() const noexcept
3030
{
31-
return !disabled_;
31+
return enabled_;
3232
}
3333

3434
OPENTELEMETRY_EXPORT bool TracerConfig::operator==(const TracerConfig &other) const noexcept
3535
{
36-
return disabled_ == other.disabled_;
36+
return enabled_ == other.enabled_;
3737
}
3838

3939
} // namespace trace

0 commit comments

Comments
 (0)