make include/exclude easier to use with empty but not null arguments#8185
Open
SylvainJuge wants to merge 11 commits intoopen-telemetry:mainfrom
Open
make include/exclude easier to use with empty but not null arguments#8185SylvainJuge wants to merge 11 commits intoopen-telemetry:mainfrom
SylvainJuge wants to merge 11 commits intoopen-telemetry:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8185 +/- ##
============================================
+ Coverage 90.29% 90.31% +0.01%
- Complexity 7652 7655 +3
============================================
Files 843 843
Lines 23066 23066
Branches 2310 2307 -3
============================================
+ Hits 20827 20831 +4
+ Misses 1520 1519 -1
+ Partials 719 716 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…nto fix-another-include-none-by-default
SylvainJuge
commented
Mar 16, 2026
| @@ -74,6 +74,11 @@ public ViewBuilder setAggregation(Aggregation aggregation) { | |||
| */ | |||
| public ViewBuilder setAttributeFilter(Set<String> keysToRetain) { | |||
Contributor
Author
There was a problem hiding this comment.
[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.
robsunday
reviewed
Mar 17, 2026
sdk/common/src/main/java/io/opentelemetry/sdk/common/internal/IncludeExcludePredicate.java
Outdated
Show resolved
Hide resolved
…nto fix-another-include-none-by-default
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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 theincludestatement is omitted this will include none and thus exclude all.I have found a few other usages of
IncludeExcludePredicatethat 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
IncludeExcludePatternrequire 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.