-
Notifications
You must be signed in to change notification settings - Fork 19
[1/2] feat: active configuration - rework configuration #97
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
7 commits
Select commit
Hold shift + click to select a range
886cb98
Rework configuration
dmehala 254618f
code review
dmehala 04a350f
final code review
dmehala 2482ff1
[2/2] feat: active configuration - report configuration to telemetry …
dmehala 8973861
Update README.md
dmehala 90cb30d
Merge branch 'main' into dmehala/active-config-v2
dmehala 9f81de6
Update src/datadog/config_manager.h
dmehala 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
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,72 @@ | ||
| #pragma once | ||
|
|
||
| #include "error.h" | ||
| #include "optional.h" | ||
|
|
||
| namespace datadog { | ||
| namespace tracing { | ||
|
|
||
| // Enumerates available configuration names for the tracing library | ||
| enum class ConfigName : char { | ||
| SERVICE_NAME, | ||
| SERVICE_ENV, | ||
| SERVICE_VERSION, | ||
| REPORT_TRACES, | ||
| TAGS, | ||
| EXTRACTION_STYLES, | ||
| INJECTION_STYLES, | ||
| STARTUP_LOGS, | ||
| REPORT_TELEMETRY, | ||
| DELEGATE_SAMPLING, | ||
| GENEREATE_128BIT_TRACE_IDS, | ||
| AGENT_URL, | ||
| RC_POLL_INTERVAL, | ||
| TRACE_SAMPLING_RATE, | ||
| TRACE_SAMPLING_LIMIT, | ||
| TRACE_SAMPLING_RULES, | ||
| SPAN_SAMPLING_RULES, | ||
| }; | ||
|
|
||
| // Represents metadata for configuration parameters | ||
| struct ConfigMetadata { | ||
| enum class Origin : char { | ||
| ENVIRONMENT_VARIABLE, // Originating from environment variables | ||
| CODE, // Defined in code | ||
| REMOTE_CONFIG, // Retrieved from remote configuration | ||
| DEFAULT // Default value | ||
| }; | ||
|
|
||
| // Name of the configuration parameter | ||
| ConfigName name; | ||
| // Value of the configuration parameter | ||
| std::string value; | ||
| // Origin of the configuration parameter | ||
| Origin origin; | ||
| // Optional error associated with the configuration parameter | ||
| Optional<Error> error; | ||
|
|
||
| ConfigMetadata() = default; | ||
| ConfigMetadata(ConfigName n, std::string v, Origin orig, | ||
| Optional<Error> err = nullopt) | ||
| : name(n), value(std::move(v)), origin(orig), error(std::move(err)) {} | ||
| }; | ||
|
|
||
| // Return a pair containing the configuration origin and value of a | ||
| // configuration value chosen from one of the specified `from_env`, | ||
| // `from_config`, and `fallback`. This function defines the relative precedence | ||
| // among configuration values originating from the environment, programmatic | ||
| // configuration, and default configuration. | ||
| template <typename Value, typename DefaultValue> | ||
| std::pair<ConfigMetadata::Origin, Value> pick(const Optional<Value> &from_env, | ||
| const Optional<Value> &from_user, | ||
| DefaultValue fallback) { | ||
| if (from_env) { | ||
| return {ConfigMetadata::Origin::ENVIRONMENT_VARIABLE, *from_env}; | ||
| } else if (from_user) { | ||
| return {ConfigMetadata::Origin::CODE, *from_user}; | ||
| } | ||
| return {ConfigMetadata::Origin::DEFAULT, fallback}; | ||
| } | ||
|
|
||
| } // namespace tracing | ||
| } // namespace datadog |
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
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.