Skip to content

make include/exclude easier to use with empty but not null arguments#8185

Merged
jack-berg merged 15 commits intoopen-telemetry:mainfrom
SylvainJuge:fix-another-include-none-by-default
Apr 8, 2026
Merged

make include/exclude easier to use with empty but not null arguments#8185
jack-berg merged 15 commits intoopen-telemetry:mainfrom
SylvainJuge:fix-another-include-none-by-default

Conversation

@SylvainJuge
Copy link
Copy Markdown
Contributor

@SylvainJuge SylvainJuge commented Mar 13, 2026

Fixes a few other occurrences of the same bug fixed in #8177.

When using declarative configuration, we get empty collections when an attribute is not defined, and not null, when the include statement is omitted this will include none and thus exclude all.

I have found a few other usages of IncludeExcludePredicate that have the same bug as what was fixed in #8177, so I think it is better to provide a more generic solution, for example visible in this intermediate commit : c0e641d (this has now been replaced by the generic solution).

This change makes IncludeExcludePattern require that at least one of include and exclude arguments is non-null or empty, in other words we need to have at least one exclusion or one inclusion.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.33%. Comparing base (6d522eb) to head (ca63884).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8185      +/-   ##
============================================
+ Coverage     90.32%   90.33%   +0.01%     
  Complexity     7651     7651              
============================================
  Files           842      842              
  Lines         23075    23073       -2     
  Branches       2312     2308       -4     
============================================
+ Hits          20842    20843       +1     
- Misses         1514     1515       +1     
+ Partials        719      715       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@@ -74,6 +74,11 @@ public ViewBuilder setAggregation(Aggregation aggregation) {
*/
public ViewBuilder setAttributeFilter(Set<String> keysToRetain) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

[for reviewer] this is the only place where we use IncludeExcludePredicate to potentially remove all items, dealing with this as an exception allows to make most common use-case simpler to call without having to convert empty collection to null.

@SylvainJuge SylvainJuge changed the title declarative config fix other 'include none by default' make include/exclude easier to use with empty but not null arguments Mar 16, 2026
@SylvainJuge SylvainJuge marked this pull request as ready for review March 16, 2026 09:05
@SylvainJuge SylvainJuge requested a review from a team as a code owner March 16, 2026 09:05
if (included != null || excluded != null) {
builder.setAttributeFilter(IncludeExcludePredicate.createExactMatching(included, excluded));
}
builder.setAttributeFilter(IncludeExcludePredicate.createExactMatching(included, excluded));
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.

👍 ugh this was bad

SylvainJuge and others added 3 commits April 7, 2026 11:29
Co-authored-by: Jack Berg <34418638+jack-berg@users.noreply.github.com>
@jack-berg jack-berg merged commit ec002c3 into open-telemetry:main Apr 8, 2026
27 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.

3 participants