Repository navigation
[CONFIGURATION] Provider builder interfaces #4426
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
Changes from all commits
b6f9e2f
0fcac13
c946291
dec84b2
f3542f1
0638ab9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <memory> | ||
|
|
||
| #include "opentelemetry/sdk/configuration/logger_provider_builder_context.h" | ||
| #include "opentelemetry/sdk/configuration/logger_provider_configuration.h" | ||
| #include "opentelemetry/version.h" | ||
|
|
||
| OPENTELEMETRY_BEGIN_NAMESPACE | ||
| namespace sdk | ||
| { | ||
| namespace logs | ||
| { | ||
| class LoggerProvider; | ||
| } // namespace logs | ||
|
|
||
| namespace configuration | ||
| { | ||
|
|
||
| /** | ||
| * Builds a logger provider from a logger provider configuration model. | ||
| */ | ||
| class LoggerProviderBuilder | ||
| { | ||
| public: | ||
| LoggerProviderBuilder() = default; | ||
| LoggerProviderBuilder(LoggerProviderBuilder &&) = default; | ||
| LoggerProviderBuilder(const LoggerProviderBuilder &) = default; | ||
| LoggerProviderBuilder &operator=(LoggerProviderBuilder &&) = default; | ||
| LoggerProviderBuilder &operator=(const LoggerProviderBuilder &other) = default; | ||
| virtual ~LoggerProviderBuilder() = default; | ||
|
|
||
| virtual std::shared_ptr<opentelemetry::sdk::logs::LoggerProvider> Build( | ||
| const LoggerProviderBuilderContext &context, | ||
| const opentelemetry::sdk::configuration::LoggerProviderConfiguration *model) const = 0; | ||
| }; | ||
|
|
||
| } // namespace configuration | ||
| } // namespace sdk | ||
| OPENTELEMETRY_END_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "opentelemetry/version.h" | ||
|
|
||
| OPENTELEMETRY_BEGIN_NAMESPACE | ||
| namespace sdk | ||
| { | ||
| namespace resource | ||
| { | ||
| class Resource; | ||
| } // namespace resource | ||
|
|
||
| namespace configuration | ||
| { | ||
|
|
||
| class AttributeLimitsConfiguration; | ||
| class Registry; | ||
|
|
||
| /** | ||
| * Configuration context for building a logger provider. | ||
| */ | ||
| struct LoggerProviderBuilderContext | ||
| { | ||
| /** Registry is required and must not be null. */ | ||
| const Registry *registry{nullptr}; | ||
|
|
||
| /** Resource is required and must not be null. */ | ||
| const opentelemetry::sdk::resource::Resource *resource{nullptr}; | ||
|
|
||
| /** AttributeLimits are optional and may be null. */ | ||
| const AttributeLimitsConfiguration *attribute_limits{nullptr}; | ||
| }; | ||
|
|
||
| } // namespace configuration | ||
| } // namespace sdk | ||
| OPENTELEMETRY_END_NAMESPACE | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <memory> | ||
|
|
||
| #include "opentelemetry/sdk/configuration/meter_provider_builder_context.h" | ||
| #include "opentelemetry/sdk/configuration/meter_provider_configuration.h" | ||
| #include "opentelemetry/version.h" | ||
|
|
||
| OPENTELEMETRY_BEGIN_NAMESPACE | ||
| namespace sdk | ||
| { | ||
| namespace metrics | ||
| { | ||
| class MeterProvider; | ||
| } // namespace metrics | ||
|
|
||
| namespace configuration | ||
| { | ||
|
|
||
| /** | ||
| * Builds a meter provider from a meter provider configuration model. | ||
| */ | ||
| class MeterProviderBuilder | ||
| { | ||
| public: | ||
| MeterProviderBuilder() = default; | ||
| MeterProviderBuilder(MeterProviderBuilder &&) = default; | ||
| MeterProviderBuilder(const MeterProviderBuilder &) = default; | ||
| MeterProviderBuilder &operator=(MeterProviderBuilder &&) = default; | ||
| MeterProviderBuilder &operator=(const MeterProviderBuilder &other) = default; | ||
| virtual ~MeterProviderBuilder() = default; | ||
|
|
||
| virtual std::shared_ptr<opentelemetry::sdk::metrics::MeterProvider> Build( | ||
| const MeterProviderBuilderContext &context, | ||
| const opentelemetry::sdk::configuration::MeterProviderConfiguration *model) const = 0; | ||
| }; | ||
|
|
||
| } // namespace configuration | ||
| } // namespace sdk | ||
| OPENTELEMETRY_END_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "opentelemetry/version.h" | ||
|
|
||
| OPENTELEMETRY_BEGIN_NAMESPACE | ||
| namespace sdk | ||
| { | ||
| namespace resource | ||
| { | ||
| class Resource; | ||
| } // namespace resource | ||
|
|
||
| namespace configuration | ||
| { | ||
|
|
||
| class Registry; | ||
|
|
||
| /** | ||
| * Configuration context for building a meter provider. | ||
| */ | ||
| struct MeterProviderBuilderContext | ||
| { | ||
| /** Registry is required and must not be null. */ | ||
| const Registry *registry{nullptr}; | ||
|
Member
Author
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. Passing in the registry allows the provider builders to take over the role of building signal specific SDK components. This means those |
||
|
|
||
| /** Resource is required and must not be null. */ | ||
| const opentelemetry::sdk::resource::Resource *resource{nullptr}; | ||
| }; | ||
|
|
||
| } // namespace configuration | ||
| } // namespace sdk | ||
| OPENTELEMETRY_END_NAMESPACE | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <memory> | ||
|
|
||
| #include "opentelemetry/sdk/configuration/tracer_provider_builder_context.h" | ||
| #include "opentelemetry/sdk/configuration/tracer_provider_configuration.h" | ||
| #include "opentelemetry/version.h" | ||
|
|
||
| OPENTELEMETRY_BEGIN_NAMESPACE | ||
| namespace sdk | ||
| { | ||
| namespace trace | ||
| { | ||
| class TracerProvider; | ||
| } // namespace trace | ||
|
|
||
| namespace configuration | ||
| { | ||
|
|
||
| /** | ||
| * Builds a tracer provider from a tracer provider configuration model. | ||
| */ | ||
| class TracerProviderBuilder | ||
| { | ||
| public: | ||
| TracerProviderBuilder() = default; | ||
| TracerProviderBuilder(TracerProviderBuilder &&) = default; | ||
| TracerProviderBuilder(const TracerProviderBuilder &) = default; | ||
| TracerProviderBuilder &operator=(TracerProviderBuilder &&) = default; | ||
| TracerProviderBuilder &operator=(const TracerProviderBuilder &other) = default; | ||
| virtual ~TracerProviderBuilder() = default; | ||
|
|
||
| virtual std::shared_ptr<opentelemetry::sdk::trace::TracerProvider> Build( | ||
|
Member
Author
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. Using shared_ptr for the return type allows the SDK provider to be forward declared and the SdkBuilder (which will get the provider builder from the registry and call Build when creating the ConfiguredSdk object) to not require a link to the signal libraries (metrics, trace, logs). |
||
| const TracerProviderBuilderContext &context, | ||
| const opentelemetry::sdk::configuration::TracerProviderConfiguration *model) const = 0; | ||
| }; | ||
|
|
||
| } // namespace configuration | ||
| } // namespace sdk | ||
| OPENTELEMETRY_END_NAMESPACE | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "opentelemetry/version.h" | ||
|
|
||
| OPENTELEMETRY_BEGIN_NAMESPACE | ||
| namespace sdk | ||
| { | ||
| namespace resource | ||
| { | ||
| class Resource; | ||
| } // namespace resource | ||
|
|
||
| namespace configuration | ||
| { | ||
|
|
||
| class AttributeLimitsConfiguration; | ||
| class Registry; | ||
|
|
||
| /** | ||
| * Configuration context for building a tracer provider. | ||
| */ | ||
| struct TracerProviderBuilderContext | ||
| { | ||
| /** Registry is required and must not be null. */ | ||
| const Registry *registry{nullptr}; | ||
|
|
||
| /** Resource is required and must not be null. */ | ||
| const opentelemetry::sdk::resource::Resource *resource{nullptr}; | ||
|
|
||
| /** AttributeLimits are optional and may be null. */ | ||
| const AttributeLimitsConfiguration *attribute_limits{nullptr}; | ||
| }; | ||
|
|
||
| } // namespace configuration | ||
| } // namespace sdk | ||
| OPENTELEMETRY_END_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,15 +38,23 @@ namespace metrics | |
| class OPENTELEMETRY_EXPORT MeterProvider final : public opentelemetry::metrics::MeterProvider | ||
| { | ||
| public: | ||
| /** | ||
| * Initialize a new meter provider with default configuration. | ||
| * This will create a MeterProvider with a default ViewRegistry, | ||
| * a Resource using the OTELResourceDetector, and | ||
| * a default ScopeConfigurator that applies the default MeterConfig to all Meters. | ||
| */ | ||
| MeterProvider(); | ||
|
|
||
| /** | ||
| * Initialize a new meter provider. | ||
| * @param views The views for this meter provider | ||
| * @param resource The resources for this meter provider. | ||
| * @param meter_configurator Provides access to a function that computes the MeterConfig for | ||
| * Meters provided by this MeterProvider. | ||
| */ | ||
| MeterProvider( | ||
|
Member
Author
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. This three arg constructor takes In This change to add a default constructor and make the three arg constructor explicit resolves the issue and Windows DLL builds can support |
||
| std::unique_ptr<ViewRegistry> views = std::unique_ptr<ViewRegistry>(new ViewRegistry()), | ||
| explicit MeterProvider( | ||
| std::unique_ptr<ViewRegistry> views, | ||
| const sdk::resource::Resource &resource = sdk::resource::Resource::Create({}), | ||
| std::unique_ptr<instrumentationscope::ScopeConfigurator<MeterConfig>> meter_configurator = | ||
| std::make_unique<instrumentationscope::ScopeConfigurator<MeterConfig>>( | ||
|
|
||
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.
The rationale for adding these builder context structs is to support future args being passed from the root configuration node into the provider builders without requiring a change to the builder interface virtual functions.