-
Notifications
You must be signed in to change notification settings - Fork 613
[CONFIGURATION] Apply general attribute_limits to tracer and logger providers #4468
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
Open
ayush-singh-0601
wants to merge
8
commits into
open-telemetry:main
Choose a base branch
from
ayush-singh-0601:config-general-attribute-limits
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+611
−99
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c82730a
[CONFIGURATION] Apply general attribute_limits to tracer and logger p…
ayush-singh-0601 65d8341
[CONFIGURATION] Fix clang-format alignment in attribute_limits tests
ayush-singh-0601 70d4dcc
Merge branch 'main' into config-general-attribute-limits
dbarker 66cf236
[CONFIGURATION] Add defaulted attribute_limits arg to Create*Provider
ayush-singh-0601 a1556d4
Merge branch 'main' into config-general-attribute-limits
dbarker a336cf9
[CONFIGURATION] Resolve attribute limits per field
ayush-singh-0601 e3e5c5d
Merge branch 'main' into config-general-attribute-limits
dbarker c995d4e
[CONFIGURATION] Fix attribute limits CI failures
ayush-singh-0601 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
Some comments aren't visible on the classic Files Changed page.
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
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
46 changes: 46 additions & 0 deletions
46
sdk/include/opentelemetry/sdk/configuration/optional_value.h
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,46 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "opentelemetry/version.h" | ||
|
|
||
| OPENTELEMETRY_BEGIN_NAMESPACE | ||
| namespace sdk | ||
| { | ||
| namespace configuration | ||
| { | ||
|
|
||
| /** | ||
| * C++14-friendly optional for configuration fields that may be set, omitted, or | ||
| * explicitly null in YAML. | ||
| */ | ||
| template <typename T> | ||
| class OptionalValue | ||
| { | ||
| public: | ||
| OptionalValue() = default; | ||
|
|
||
| explicit OptionalValue(T value) : has_value_(true), value_(value) {} | ||
|
|
||
| bool HasValue() const { return has_value_; } | ||
|
|
||
| const T &Value() const { return value_; } | ||
|
|
||
| T ValueOr(T fallback) const { return has_value_ ? value_ : fallback; } | ||
|
|
||
| OptionalValue &operator=(T value) | ||
| { | ||
| has_value_ = true; | ||
| value_ = value; | ||
| return *this; | ||
| } | ||
|
|
||
| private: | ||
| bool has_value_{false}; | ||
| T value_{}; | ||
| }; | ||
|
|
||
| } // namespace configuration | ||
| } // 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ | |
| #include "opentelemetry/sdk/common/global_log_handler.h" | ||
| #include "opentelemetry/sdk/configuration/document_node.h" | ||
| #include "opentelemetry/sdk/configuration/invalid_schema_exception.h" | ||
| #include "opentelemetry/sdk/configuration/optional_value.h" | ||
| #include "opentelemetry/sdk/configuration/ryml_document.h" | ||
| #include "opentelemetry/sdk/configuration/ryml_document_node.h" | ||
| #include "opentelemetry/version.h" | ||
|
|
@@ -297,6 +298,30 @@ size_t RymlDocumentNode::GetInteger(const std::string &name, size_t default_valu | |
| return IntegerFromString(value); | ||
| } | ||
|
|
||
| OptionalValue<std::size_t> RymlDocumentNode::GetOptionalInteger(const std::string &name) const | ||
| { | ||
| OTEL_INTERNAL_LOG_DEBUG("RymlDocumentNode::GetOptionalInteger(" << name << ")"); | ||
|
|
||
| auto ryml_child = GetRymlChildNode(name); | ||
|
|
||
| if (ryml_child.invalid() || !ryml_child.has_val()) | ||
| { | ||
| return OptionalValue<std::size_t>{}; | ||
| } | ||
|
|
||
| ryml::csubstr view = ryml_child.val(); | ||
| std::string value(view.str, view.len); | ||
|
|
||
| value = DoSubstitution(value); | ||
|
|
||
| if (value.empty() || value == "~" || value == "null" || value == "Null" || value == "NULL") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The DocumentNode and RymlDocumentNode now have an IsNull() method. Please use it where appropriate. |
||
| { | ||
| return OptionalValue<std::size_t>{}; | ||
| } | ||
|
|
||
| return OptionalValue<std::size_t>{IntegerFromString(value)}; | ||
| } | ||
|
|
||
| std::int64_t RymlDocumentNode::GetSignedInteger(const std::string &name, | ||
| std::int64_t default_value) const | ||
| { | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the Value method is called and there is no value then a runtime exception should be thrown. This more closely matches the behavior of std::optional.