-
Notifications
You must be signed in to change notification settings - Fork 571
[CONFIGURATION] File configuration - resource detectors #4113
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
rishitha957
wants to merge
2
commits into
open-telemetry:main
Choose a base branch
from
rishitha957:container-resource-detector
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.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
29 changes: 29 additions & 0 deletions
29
sdk/include/opentelemetry/sdk/configuration/container_resource_detector_configuration.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,29 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "opentelemetry/sdk/configuration/resource_detector_configuration.h" | ||
| #include "opentelemetry/sdk/configuration/resource_detector_configuration_visitor.h" | ||
| #include "opentelemetry/version.h" | ||
|
|
||
| OPENTELEMETRY_BEGIN_NAMESPACE | ||
| namespace sdk | ||
| { | ||
| namespace configuration | ||
| { | ||
|
|
||
| // YAML-SCHEMA: schema/resource.yaml | ||
| // YAML-NODE: ExperimentalContainerResourceDetector | ||
| class ContainerResourceDetectorConfiguration : public ResourceDetectorConfiguration | ||
| { | ||
| public: | ||
| void Accept(ResourceDetectorConfigurationVisitor *visitor) const override | ||
| { | ||
| visitor->VisitContainer(this); | ||
| } | ||
| }; | ||
|
|
||
| } // namespace configuration | ||
| } // namespace sdk | ||
| OPENTELEMETRY_END_NAMESPACE |
36 changes: 36 additions & 0 deletions
36
sdk/include/opentelemetry/sdk/configuration/extension_resource_detector_builder.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,36 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <memory> | ||
|
|
||
| #include "opentelemetry/sdk/configuration/extension_resource_detector_configuration.h" | ||
| #include "opentelemetry/sdk/resource/resource_detector.h" | ||
| #include "opentelemetry/version.h" | ||
|
|
||
| OPENTELEMETRY_BEGIN_NAMESPACE | ||
| namespace sdk | ||
| { | ||
| namespace configuration | ||
| { | ||
|
|
||
| class ExtensionResourceDetectorBuilder | ||
| { | ||
| public: | ||
| ExtensionResourceDetectorBuilder() = default; | ||
| ExtensionResourceDetectorBuilder(ExtensionResourceDetectorBuilder &&) = default; | ||
| ExtensionResourceDetectorBuilder(const ExtensionResourceDetectorBuilder &) = default; | ||
| ExtensionResourceDetectorBuilder &operator=(ExtensionResourceDetectorBuilder &&) = default; | ||
| ExtensionResourceDetectorBuilder &operator=(const ExtensionResourceDetectorBuilder &other) = | ||
| default; | ||
| virtual ~ExtensionResourceDetectorBuilder() = default; | ||
|
|
||
| virtual std::unique_ptr<opentelemetry::sdk::resource::ResourceDetector> Build( | ||
| const opentelemetry::sdk::configuration::ExtensionResourceDetectorConfiguration *model) | ||
| const = 0; | ||
| }; | ||
|
|
||
| } // namespace configuration | ||
| } // namespace sdk | ||
| OPENTELEMETRY_END_NAMESPACE |
34 changes: 34 additions & 0 deletions
34
sdk/include/opentelemetry/sdk/configuration/extension_resource_detector_configuration.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,34 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <memory> | ||
| #include <string> | ||
|
|
||
| #include "opentelemetry/sdk/configuration/document_node.h" | ||
| #include "opentelemetry/sdk/configuration/resource_detector_configuration.h" | ||
| #include "opentelemetry/sdk/configuration/resource_detector_configuration_visitor.h" | ||
| #include "opentelemetry/version.h" | ||
|
|
||
| OPENTELEMETRY_BEGIN_NAMESPACE | ||
| namespace sdk | ||
| { | ||
| namespace configuration | ||
| { | ||
|
|
||
| class ExtensionResourceDetectorConfiguration : public ResourceDetectorConfiguration | ||
| { | ||
| public: | ||
| void Accept(ResourceDetectorConfigurationVisitor *visitor) const override | ||
| { | ||
| visitor->VisitExtension(this); | ||
| } | ||
|
|
||
| std::string name; | ||
| std::unique_ptr<DocumentNode> node; | ||
| }; | ||
|
|
||
| } // 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
30 changes: 30 additions & 0 deletions
30
sdk/include/opentelemetry/sdk/configuration/resource_detection_configuration.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,30 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <memory> | ||
| #include <vector> | ||
|
|
||
| #include "opentelemetry/sdk/configuration/include_exclude_configuration.h" | ||
| #include "opentelemetry/sdk/configuration/resource_detector_configuration.h" | ||
| #include "opentelemetry/version.h" | ||
|
|
||
| OPENTELEMETRY_BEGIN_NAMESPACE | ||
| namespace sdk | ||
| { | ||
| namespace configuration | ||
| { | ||
|
|
||
| // YAML-SCHEMA: schema/resource.yaml | ||
| // YAML-NODE: ExperimentalResourceDetection | ||
| class ResourceDetectionConfiguration | ||
| { | ||
| public: | ||
| std::unique_ptr<IncludeExcludeConfiguration> attributes; | ||
| std::vector<std::unique_ptr<ResourceDetectorConfiguration>> detectors; | ||
| }; | ||
|
|
||
| } // namespace configuration | ||
| } // namespace sdk | ||
| OPENTELEMETRY_END_NAMESPACE |
33 changes: 33 additions & 0 deletions
33
sdk/include/opentelemetry/sdk/configuration/resource_detector_configuration.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,33 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "opentelemetry/version.h" | ||
|
|
||
| OPENTELEMETRY_BEGIN_NAMESPACE | ||
| namespace sdk | ||
| { | ||
| namespace configuration | ||
| { | ||
|
|
||
| class ResourceDetectorConfigurationVisitor; | ||
|
|
||
| // YAML-SCHEMA: schema/resource.yaml | ||
| // YAML-NODE: ExperimentalResourceDetector | ||
| class ResourceDetectorConfiguration | ||
| { | ||
| public: | ||
| ResourceDetectorConfiguration() = default; | ||
| ResourceDetectorConfiguration(ResourceDetectorConfiguration &&) = default; | ||
| ResourceDetectorConfiguration(const ResourceDetectorConfiguration &) = default; | ||
| ResourceDetectorConfiguration &operator=(ResourceDetectorConfiguration &&) = default; | ||
| ResourceDetectorConfiguration &operator=(const ResourceDetectorConfiguration &other) = default; | ||
| virtual ~ResourceDetectorConfiguration() = default; | ||
|
|
||
| virtual void Accept(ResourceDetectorConfigurationVisitor *visitor) const = 0; | ||
| }; | ||
|
|
||
| } // namespace configuration | ||
| } // namespace sdk | ||
| OPENTELEMETRY_END_NAMESPACE |
29 changes: 29 additions & 0 deletions
29
sdk/include/opentelemetry/sdk/configuration/resource_detector_configuration_visitor.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,29 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "opentelemetry/version.h" | ||
|
|
||
| OPENTELEMETRY_BEGIN_NAMESPACE | ||
| namespace sdk | ||
| { | ||
| namespace configuration | ||
| { | ||
|
|
||
| class ContainerResourceDetectorConfiguration; | ||
| class ExtensionResourceDetectorConfiguration; | ||
|
|
||
| class ResourceDetectorConfigurationVisitor | ||
| { | ||
| public: | ||
| ResourceDetectorConfigurationVisitor() = default; | ||
| virtual ~ResourceDetectorConfigurationVisitor() = default; | ||
|
|
||
| virtual void VisitContainer(const ContainerResourceDetectorConfiguration *model) = 0; | ||
| virtual void VisitExtension(const ExtensionResourceDetectorConfiguration *model) = 0; | ||
| }; | ||
|
|
||
| } // 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,6 +100,10 @@ | |
| #include "opentelemetry/sdk/configuration/pull_metric_reader_configuration.h" | ||
| #include "opentelemetry/sdk/configuration/push_metric_exporter_configuration.h" | ||
| #include "opentelemetry/sdk/configuration/resource_configuration.h" | ||
| #include "opentelemetry/sdk/configuration/resource_detection_configuration.h" | ||
| #include "opentelemetry/sdk/configuration/resource_detector_configuration.h" | ||
| #include "opentelemetry/sdk/configuration/container_resource_detector_configuration.h" | ||
| #include "opentelemetry/sdk/configuration/extension_resource_detector_configuration.h" | ||
| #include "opentelemetry/sdk/configuration/sampler_configuration.h" | ||
| #include "opentelemetry/sdk/configuration/severity_number.h" | ||
| #include "opentelemetry/sdk/configuration/simple_log_record_processor_configuration.h" | ||
|
|
@@ -2519,9 +2523,67 @@ std::unique_ptr<ResourceConfiguration> ConfigurationParser::ParseResourceConfigu | |
| model->detectors = ParseIncludeExcludeConfiguration(child); | ||
| } | ||
|
|
||
| child = node->GetChildNode("detection/development"); | ||
| if (child) | ||
| { | ||
| model->detection = ParseResourceDetectionConfiguration(child); | ||
| } | ||
|
|
||
| return model; | ||
| } | ||
|
|
||
| std::unique_ptr<ResourceDetectionConfiguration> | ||
| ConfigurationParser::ParseResourceDetectionConfiguration( | ||
| const std::unique_ptr<DocumentNode> &node) const | ||
| { | ||
| auto model = std::make_unique<ResourceDetectionConfiguration>(); | ||
| std::unique_ptr<DocumentNode> child; | ||
|
|
||
| child = node->GetChildNode("attributes"); | ||
| if (child) | ||
| { | ||
| model->attributes = ParseIncludeExcludeConfiguration(child); | ||
| } | ||
|
|
||
| child = node->GetChildNode("detectors"); | ||
| if (child) | ||
| { | ||
| for (auto it = child->begin(); it != child->end(); ++it) | ||
| { | ||
| std::unique_ptr<DocumentNode> detector_node(*it); | ||
| auto detector = ParseResourceDetectorConfiguration(detector_node); | ||
| model->detectors.push_back(std::move(detector)); | ||
| } | ||
| } | ||
|
|
||
| return model; | ||
| } | ||
|
|
||
| std::unique_ptr<ResourceDetectorConfiguration> | ||
| ConfigurationParser::ParseResourceDetectorConfiguration( | ||
| const std::unique_ptr<DocumentNode> &node) const | ||
| { | ||
| for (auto it = node->begin_properties(); it != node->end_properties(); ++it) | ||
| { | ||
| std::string name = it.Name(); | ||
|
|
||
| if (name == "container") | ||
| { | ||
| return std::make_unique<ContainerResourceDetectorConfiguration>(); | ||
| } | ||
| else | ||
| { | ||
| auto extension = std::make_unique<ExtensionResourceDetectorConfiguration>(); | ||
| extension->name = name; | ||
| extension->node = it.Value(); | ||
| return extension; | ||
| } | ||
| } | ||
|
Comment on lines
+2566
to
+2581
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. It is weird to have a for loop and return from the middle of it. Please check for example |
||
|
|
||
| std::string message("Illegal resource detector, 0 entries"); | ||
| throw InvalidSchemaException(node->Location(), message); | ||
| } | ||
|
|
||
| std::unique_ptr<DistributionConfiguration> ConfigurationParser::ParseDistributionConfiguration( | ||
| const std::unique_ptr<DocumentNode> &node) 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.
New member
detectionlooks ok.Please remove the existing member
detectors, it was misplaced and does not comply with the yaml schema.