Skip to content

[CONFIGURATION] File configuration - composable samplers - #3966

Merged
marcalff merged 40 commits into
open-telemetry:mainfrom
DCchoudhury15:feat/config-composable-samplers
Apr 23, 2026
Merged

[CONFIGURATION] File configuration - composable samplers#3966
marcalff merged 40 commits into
open-telemetry:mainfrom
DCchoudhury15:feat/config-composable-samplers

Conversation

@DCchoudhury15

Copy link
Copy Markdown
Contributor

Fixes #3914

Changes

This PR implements the necessary infrastructure and test coverage to fully support composable samplers. Specifically, the changes include:

  • Parser Logic: Implemented the YAML parsing logic to properly extract composable sampler configurations.
  • SDK Builder: Added SDK builder visitor instantiation to correctly wire the new sampler variants.
  • Test Safety: Replaced dangerous casts with the safe Visitor pattern in the testing suite.
  • Test Coverage: Expanded unit test coverage to ensure all composable sampler variants are accurately parsed and instantiated.

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

@DCchoudhury15
DCchoudhury15 requested a review from a team as a code owner April 3, 2026 10:02
Implements parser logic, SDK builder visitor instantiation, safe test patterns, and expands coverage for all composable sampler variants to resolve open-telemetry#3914.

Signed-off-by: DCchoudhury15 <divyanshuchoudhury3@gmail.com>
@DCchoudhury15
DCchoudhury15 force-pushed the feat/config-composable-samplers branch from 92ed254 to ae0c9dd Compare April 3, 2026 10:09
@codecov

codecov Bot commented Apr 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.33333% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.83%. Comparing base (c49458d) to head (8958736).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
sdk/src/configuration/configuration_parser.cc 87.20% 16 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3966      +/-   ##
==========================================
+ Coverage   81.75%   81.83%   +0.09%     
==========================================
  Files         374      389      +15     
  Lines       16083    16234     +151     
==========================================
+ Hits        13147    13284     +137     
- Misses       2936     2950      +14     
Files with missing lines Coverage Δ
...tion/composable_always_off_sampler_configuration.h 100.00% <100.00%> (ø)
...ation/composable_always_on_sampler_configuration.h 100.00% <100.00%> (ø)
...omposable_parent_threshold_sampler_configuration.h 100.00% <100.00%> (ø)
...ion/composable_probability_sampler_configuration.h 100.00% <100.00%> (ø)
...tion/composable_rule_based_sampler_configuration.h 100.00% <100.00%> (ø)
...ed_sampler_rule_attribute_patterns_configuration.h 100.00% <100.00%> (ø)
...ased_sampler_rule_attribute_values_configuration.h 100.00% <100.00%> (ø)
...composable_rule_based_sampler_rule_configuration.h 100.00% <100.00%> (ø)
...k/configuration/composable_sampler_configuration.h 100.00% <100.00%> (ø)
.../sdk/configuration/sampler_configuration_visitor.h 100.00% <ø> (ø)
... and 6 more

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@marcalff

marcalff commented Apr 3, 2026

Copy link
Copy Markdown
Member

@DCchoudhury15

Thanks for the PR.

Please check the CI logs for failures, and adjust the code accordingly.

In the mean time, I will start the code review and provide feedback.

Thanks for your contribution.

Examples of failures below


Include what you use:

[ 57%] Building CXX object sdk/src/configuration/CMakeFiles/opentelemetry_configuration.dir/yaml_configuration_parser.cc.o
Warning: include-what-you-use reported diagnostics:

/home/runner/work/opentelemetry-cpp/opentelemetry-cpp/sdk/src/configuration/configuration_parser.cc should add these lines:
#include "opentelemetry/sdk/configuration/composable_always_off_sampler_configuration.h"
#include "opentelemetry/sdk/configuration/composable_always_on_sampler_configuration.h"
#include "opentelemetry/sdk/configuration/composable_parent_threshold_sampler_configuration.h"
#include "opentelemetry/sdk/configuration/composable_probability_sampler_configuration.h"
#include "opentelemetry/sdk/configuration/composable_rule_based_sampler_configuration.h"
#include "opentelemetry/sdk/configuration/composable_sampler_configuration.h"

Build in maintainer mode

[ 53%] Building CXX object sdk/src/configuration/CMakeFiles/opentelemetry_configuration.dir/configuration_parser.cc.o
In file included from /home/runner/work/opentelemetry-cpp/opentelemetry-cpp/sdk/src/configuration/configuration_parser.cc:29:
In file included from /home/runner/work/opentelemetry-cpp/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/configuration_parser.h:20:
/home/runner/work/opentelemetry-cpp/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/composable_always_off_sampler_configuration.h:26:28: error: no newline at end of file [-Werror,-Wnewline-eof]
   26 | OPENTELEMETRY_END_NAMESPACE
      |                            ^

Clang-tidy

Download the clang-tidy report from ci, and inspect failures related to new code.


opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/composable_always_off_sampler_configuration.h (1 warnings)Line Check Message15 cppcoreguidelines-special-member-functions class ‘ComposableAlwaysOffSamplerConfiguration’ defines a default destructor but
does not define a copy constructor, a copy assignment operator, a move constructor
or a move assignment operator 

@DCchoudhury15

Copy link
Copy Markdown
Contributor Author

Hi @marcalff, addressed all the CI failures:

  • Added direct includes in configuration_parser.cc (IWYU)
  • Fixed missing newlines at end of the new headers (clang-tidy)
  • Dropped the explicit destructors since the base class already handles it
    Also did some changes in the test visitor for a SamplerType enum while I was at it.
    Thanks for the patience!

Signed-off-by: DCchoudhury15 <divyanshuchoudhury3@gmail.com>
@DCchoudhury15
DCchoudhury15 force-pushed the feat/config-composable-samplers branch from f5be4bf to 659aafe Compare April 4, 2026 07:24
Comment thread sdk/test/configuration/yaml_trace_test.cc
Comment thread sdk/src/configuration/configuration_parser.cc Outdated
Comment thread sdk/src/configuration/configuration_parser.cc Outdated
Comment thread sdk/src/configuration/configuration_parser.cc Outdated
Comment thread sdk/src/configuration/configuration_parser.cc Outdated
Comment thread sdk/src/configuration/configuration_parser.cc Outdated

@marcalff marcalff left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR.

Focusing on the yaml part for now: all the yaml nodes and properties should be parsed, and represented in memory in C++ classes.

This includes rules with attribute_values, attribute_patterns and span_kinds.

Comment thread sdk/src/configuration/configuration_parser.cc Outdated
Comment thread sdk/test/configuration/yaml_trace_test.cc Outdated
@DCchoudhury15
DCchoudhury15 force-pushed the feat/config-composable-samplers branch from 2e15234 to 758e3a5 Compare April 10, 2026 05:48
@DCchoudhury15

Copy link
Copy Markdown
Contributor Author

I have applied the changes given on the pr review , will resolve all the ci errors and commit again asap .

Signed-off-by: DCchoudhury15 <divyanshuchoudhury3@gmail.com>
@DCchoudhury15
DCchoudhury15 force-pushed the feat/config-composable-samplers branch from 13f24d4 to 1a4617d Compare April 11, 2026 01:07
Signed-off-by: DCchoudhury15 <divyanshuchoudhury3@gmail.com>
@DCchoudhury15
DCchoudhury15 force-pushed the feat/config-composable-samplers branch from e207db5 to e22556d Compare April 13, 2026 04:32
@DCchoudhury15
DCchoudhury15 force-pushed the feat/config-composable-samplers branch 2 times, most recently from 7b65db4 to b96bd0b Compare April 15, 2026 04:46
Signed-off-by: DCchoudhury15 <divyanshuchoudhury3@gmail.com>
DCchoudhury15 and others added 4 commits April 22, 2026 14:47
…sed_sampler_rule_attribute_values_configuration.h

Co-authored-by: Marc Alff <marc.alff@free.fr>
…sed_sampler_rule_attribute_patterns_configuration.h

Co-authored-by: Marc Alff <marc.alff@free.fr>
…sed_sampler_rule_attribute_patterns_configuration.h

Co-authored-by: Marc Alff <marc.alff@free.fr>
…sed_sampler_configuration.h

Co-authored-by: Marc Alff <marc.alff@free.fr>

@marcalff marcalff left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice work.

In this pass, changes are just cosmetic for style.

Will approve and merge once fixed.

Comment thread sdk/src/configuration/configuration_parser.cc Outdated
Comment thread sdk/src/configuration/configuration_parser.cc Outdated
Comment thread sdk/src/configuration/sdk_builder.cc
Comment thread sdk/test/configuration/yaml_trace_test.cc Outdated
Comment thread sdk/test/configuration/yaml_trace_test.cc Outdated
Comment thread sdk/test/configuration/yaml_trace_test.cc
Comment thread sdk/test/configuration/yaml_trace_test.cc
DCchoudhury15 and others added 8 commits April 22, 2026 14:49
…ion.cc

Co-authored-by: Marc Alff <marc.alff@free.fr>
…sed_sampler_configuration.h

Co-authored-by: Marc Alff <marc.alff@free.fr>
…lity_sampler_configuration.h

Co-authored-by: Marc Alff <marc.alff@free.fr>
…lity_sampler_configuration.h

Co-authored-by: Marc Alff <marc.alff@free.fr>
…threshold_sampler_configuration.h

Co-authored-by: Marc Alff <marc.alff@free.fr>
…on_sampler_configuration.h

Co-authored-by: Marc Alff <marc.alff@free.fr>
…on_sampler_configuration.h

Co-authored-by: Marc Alff <marc.alff@free.fr>
…threshold_sampler_configuration.h

Co-authored-by: Marc Alff <marc.alff@free.fr>
@DCchoudhury15
DCchoudhury15 force-pushed the feat/config-composable-samplers branch from f4d6dea to 096f4e9 Compare April 23, 2026 04:34
Comment thread sdk/test/configuration/yaml_trace_test.cc
Comment thread sdk/include/opentelemetry/sdk/configuration/composable_sampler_configuration.h Outdated
Co-authored-by: Marc Alff <marc.alff@free.fr>
@marcalff marcalff changed the title feat: add YAML parsing support for Composable Samplers [CONFIGURATION] File configuration - composable samplers Apr 23, 2026
Comment thread CHANGELOG.md Outdated
Co-authored-by: Marc Alff <marc.alff@free.fr>
Comment thread CHANGELOG.md Outdated
Co-authored-by: Marc Alff <marc.alff@free.fr>

@marcalff marcalff left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice work.

@marcalff
marcalff merged commit 62354e0 into open-telemetry:main Apr 23, 2026
69 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CONFIGURATION] File configuration - composable samplers

4 participants