[CONFIGURATION] SDK default component builder libraries and example - #4367
[CONFIGURATION] SDK default component builder libraries and example#4367dbarker wants to merge 25 commits into
Conversation
| endif() | ||
|
|
||
| if(BUILD_TESTING) | ||
| add_test(NAME examples.example_yaml COMMAND "$<TARGET_FILE:example_yaml>") |
There was a problem hiding this comment.
The example is now tested here against three different yaml files covering all the default builders, extension builders, and composite sampler. These tests now fail on non-zero returns (thanks to the --test arg) or if the example logs an error.
|
For smooth integration - this PR depends on several others and review/merge of these should be completed first: |
…lace the default builders. add the sdk-default.yaml to the example's tests
| PRIVATE opentelemetry-cpp::prometheus_exporter_builder) | ||
| endif() | ||
|
|
||
| if(DEFINED OPENTELEMETRY_BUILD_DLL) |
There was a problem hiding this comment.
The DLL build is not supported or tested for OTLP or Configuration classes (most are missing the required exports). Removing this to make the example easier to understand by moving the important config targets to the top of the file.
…ite sampler builder and use it in the sdk builder. Enforce a max sampler depth for composable samplers
…e sampler config class and separating the composable config vistor from the top level sampler config visitor. cleanup the sdk builder to use the new composable config visitor.
| class ProbabilitySamplerConfiguration; | ||
| class TraceIdRatioBasedSamplerConfiguration; | ||
| class ExtensionSamplerConfiguration; | ||
| class ComposableAlwaysOffSamplerConfiguration; |
There was a problem hiding this comment.
The CompositeSampler was missing from the model and forced SamplerConfigurationVisitor to take on knowledge of composable samplers which are a different type (and class hierarchy) from top level samplers. This forced an anti-pattern in the SdkBuilder where the SamplerBuilder visitor repeated the same implementation for each composable sampler override and the ComposableSamplerBuilder visitor had to override methods for the top level (non-composable) samplers to throw an error. Additionally it forced the SdkBuilder to provide create methods for each composable sampler.
The fix is to make the CompositeSampler a formal model component that owns a composable sampler config, create a builder interface for it (added to the registry), and separate the sampler and composable sampler visitors.
|
|
||
| #pragma once | ||
|
|
||
| #include <cstddef> |
There was a problem hiding this comment.
I'm happy with the content of this PR and test coverage, but realize it has grown a bit and changes a lot especially after the sampler/composable sampler visitor refactor and adding CompositeSampler to the model (see discussion_r3744253342).
For context, this PR is step 2 from #4352 and the goal is to instantiate all the sdk component builders in separate trace, logs, metrics builders libraries then use the registered builders in the SdkBuilder. This breaks many direct dependencies on the signal libraries, just leaving the provider level dependencies in the SdkBuilder that will be addressed in step 3.
I'm interested in your feedback on the overall design and desired scope for review.
Questions:
- Any concerns with the high level changes in the PR?
- Creating
CompositeSampleras a formal model component with its own builder in the registry, and the separation of sampler and composable sampler visitors. - Adding a
ReigstryFactoryand changing theRegistryto be empty on construction, which is a breaking change.
- Creating
- Do you have a preference on scope of review?
-
I can break this into smaller PRs if that would help. A alternative to this one PR may be:
- PR 1: Add CompositeSampler model and builder to the registry and update tests
- New interface and visitor classes
- Update registry and tests
- PR 2: Trace builders
- Break out sdk trace builder components from SdkBuilder to the new trace_builders component
- Use the ComposableSamplerConfigurationVisitor (and update all impacted files)
- Update SdkBuilder to use builders from the registry for all trace components (except the provider)
- Add the registry factory and use it in the tests and examples
- PR 3: Logs builders
- Break out sdk log builder components from SdkBuilder to the new logs_builders component
- PR 4: Metrics builders
- Break out sdk metrics builder components from SdkBuilder to the new metrics_builders component
Note: PR 2 will still be a big one but needs to occur in one merge to avoid drift with the SdkBuilder. PRs 3 and 4 are fairly narrow after that.
- PR 1: Add CompositeSampler model and builder to the registry and update tests
-
Happy to adjust. I just want to make sure the direction is right before going further.
Contributes to #4352
Create configuration builder libraries per signal and update SdkBuilder to use them.
This brings a breaking change to how users create a default registry populated with SDK component builders.
Changes
opentelemetry-cpp::configuration_logs_builders(9846e83)opentelemetry-cpp::configuration_metrics_builders(f3328f3)opentelemetry-cpp::configuration_trace_builders(7977068)openetelemetry-cpp::configuration_registry_factory(d077f5f)For significant contributions please make sure you have completed the following items:
CHANGELOG.mdupdated for non-trivial changes