-
Notifications
You must be signed in to change notification settings - Fork 500
[SDK] Add logger scope configurator #3282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
3a4c5fe
[SDK] Add logger scope configurator
psx95 23e7fbf
Implement logger configurator logic
psx95 4952e08
Add logger config tests
psx95 b8d0b01
Add sdk logger tests
psx95 18ca192
Fix file formatting
psx95 83897ea
Fix valgrind memory leaks
psx95 7290f73
Fix CMakeLists formatting
psx95 f86e8b8
Update CHANGELOG
psx95 3e8861d
Fix iwyu warnings
psx95 4b9cfe1
Fix MSVC maintainer mode CI checks
psx95 b1f0fe9
Update assertion comparison to be more robust
psx95 e1943a8
Merge branch 'main' into add-logger-scope-config
psx95 07daca3
Add documentation for header files
psx95 49a30ab
Use static local variables for logger configs
psx95 ed51800
empty commit re-run CI
psx95 511f7a1
Add OPENTELEMETRY_EXPORT to member functions of logger_config
psx95 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
|
||
#include "opentelemetry/version.h" | ||
|
||
OPENTELEMETRY_BEGIN_NAMESPACE | ||
namespace sdk | ||
{ | ||
namespace logs | ||
{ | ||
/** | ||
* LoggerConfig defines various configurable aspects of a Logger's behavior. | ||
* This class should not be used directly to configure a Logger's behavior, instead a | ||
* ScopeConfigurator should be used to compute the desired LoggerConfig which can then be used to | ||
* configure a Logger. | ||
*/ | ||
class OPENTELEMETRY_EXPORT LoggerConfig | ||
{ | ||
public: | ||
bool operator==(const LoggerConfig &other) const noexcept; | ||
|
||
/** | ||
* Returns if the Logger is enabled or disabled. Loggers are enabled by default. | ||
* @return a boolean indicating if the Logger is enabled. Defaults to true. | ||
*/ | ||
bool IsEnabled() const noexcept; | ||
|
||
/** | ||
* Returns a LoggerConfig that represents an enabled Logger. | ||
* @return a static constant LoggerConfig that represents an enabled logger. | ||
*/ | ||
static LoggerConfig Enabled(); | ||
|
||
/** | ||
* Returns a LoggerConfig that represents a disabled Logger. A disabled logger behaves like a | ||
* no-op logger. | ||
* @return a static constant LoggerConfig that represents a disabled logger. | ||
*/ | ||
static LoggerConfig Disabled(); | ||
|
||
/** | ||
* Returns a LoggerConfig that represents a Logger configured with the default behavior. | ||
* The default behavior is guided by the OpenTelemetry specification. | ||
* @return a static constant LoggerConfig that represents a logger configured with default | ||
* behavior. | ||
*/ | ||
static LoggerConfig Default(); | ||
|
||
private: | ||
explicit LoggerConfig(const bool disabled = false) : disabled_(disabled) {} | ||
|
||
bool disabled_; | ||
}; | ||
} // namespace logs | ||
} // namespace sdk | ||
OPENTELEMETRY_END_NAMESPACE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include "opentelemetry/sdk/logs/logger_config.h" | ||
|
||
OPENTELEMETRY_BEGIN_NAMESPACE | ||
namespace sdk | ||
{ | ||
namespace logs | ||
{ | ||
|
||
OPENTELEMETRY_EXPORT bool LoggerConfig::operator==(const LoggerConfig &other) const noexcept | ||
{ | ||
return disabled_ == other.disabled_; | ||
} | ||
|
||
OPENTELEMETRY_EXPORT bool LoggerConfig::IsEnabled() const noexcept | ||
{ | ||
return !disabled_; | ||
} | ||
|
||
OPENTELEMETRY_EXPORT LoggerConfig LoggerConfig::Enabled() | ||
{ | ||
return Default(); | ||
} | ||
|
||
OPENTELEMETRY_EXPORT LoggerConfig LoggerConfig::Disabled() | ||
{ | ||
static const auto kDisabledConfig = LoggerConfig(true); | ||
return kDisabledConfig; | ||
} | ||
|
||
OPENTELEMETRY_EXPORT LoggerConfig LoggerConfig::Default() | ||
{ | ||
static const auto kDefaultConfig = LoggerConfig(); | ||
return kDefaultConfig; | ||
} | ||
|
||
} // namespace logs | ||
} // namespace sdk | ||
OPENTELEMETRY_END_NAMESPACE |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.