Skip to content

baggage delegate to IncludeExcludePredicate and allow wildcards in auto-configuration#2802

Merged
jaydeluca merged 20 commits intoopen-telemetry:mainfrom
SylvainJuge:baggage-minor-simplification
May 7, 2026
Merged

baggage delegate to IncludeExcludePredicate and allow wildcards in auto-configuration#2802
jaydeluca merged 20 commits intoopen-telemetry:mainfrom
SylvainJuge:baggage-minor-simplification

Conversation

@SylvainJuge
Copy link
Copy Markdown
Contributor

@SylvainJuge SylvainJuge commented Apr 29, 2026

Baggage processor already delegates to IncludeExcludePredicate.

When using declarative configuration:

  • include and exclude configuration attributes can be used to include/exclude and directly delegate to IncludeExcludePredicate

When using auto-configuration

  • baggage attributes are only opt-in, equivalent to only having include set in declarative configuration
  • exact matching is being used
  • the * value can be used as "include-all"
  • no other form of wildcard matching is supported

This PR:

  • makes the delegation to IncludeExcludePredicate applied in both configuration types
  • adds the ability to use wildcards when not using declarative configuration (not limited anymore to *)
  • refactor implementation and tests following this change
  • deprecates the following constructors to push using the include/exclude variants.
    • BaggageSpanProcessor(Predicate<String> baggageKeyPredicate)
    • BaggageLogRecordProcessor(Predicate<String> baggageKeyPredicate)

Copilot AI review requested due to automatic review settings April 29, 2026 10:01
@SylvainJuge SylvainJuge requested a review from a team as a code owner April 29, 2026 10:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the baggage span/log processors to consistently use IncludeExcludePredicate across declarative config and auto-configuration, enabling wildcard pattern matching in auto-config include lists.

Changes:

  • Refactors BaggageSpanProcessor / BaggageLogRecordProcessor to construct their key-filter predicate via IncludeExcludePredicate.createPatternMatching(included, excluded).
  • Updates auto-configuration and declarative component providers to pass include/exclude pattern lists into the processors.
  • Refactors/extends tests and updates README auto-config docs to mention wildcard pattern matching.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
baggage-processor/src/main/java/io/opentelemetry/contrib/baggage/processor/BaggageSpanProcessor.java Switches processor construction to include/exclude pattern matching via IncludeExcludePredicate.
baggage-processor/src/main/java/io/opentelemetry/contrib/baggage/processor/BaggageLogRecordProcessor.java Same include/exclude pattern matching refactor for logs processor.
baggage-processor/src/main/java/io/opentelemetry/contrib/baggage/processor/BaggageProcessorCustomizer.java Auto-config now instantiates processors with include patterns (wildcards supported).
baggage-processor/src/main/java/io/opentelemetry/contrib/baggage/processor/BaggageSpanComponentProvider.java Declarative config provider now passes included/excluded lists to the processor.
baggage-processor/src/main/java/io/opentelemetry/contrib/baggage/processor/BaggageLogRecordComponentProvider.java Declarative config provider now passes included/excluded lists to the processor.
baggage-processor/src/test/java/io/opentelemetry/contrib/baggage/processor/BaggageSpanProcessorTest.java Updates tests to use include/exclude pattern lists (wildcards + exclude).
baggage-processor/src/test/java/io/opentelemetry/contrib/baggage/processor/BaggageProcessorCustomizerTest.java Refactors tests for new constructor signature; adds include/exclude test for logs processor.
baggage-processor/README.md Updates auto-config docs to reference wildcard pattern matching support.

Comment thread baggage-processor/README.md Outdated
}

static BaggageLogRecordProcessor createBaggageLogRecordProcessor(List<String> keys) {
if (keys.size() == 1 && keys.get(0).equals("*")) {
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 optimization is not really necessary as an equivalent is implemented in GlobUtils, we could however do this in IncludeExcludePredicate as a follow-up improvement.

Comment on lines -47 to -49
if (keys.size() == 1 && keys.get(0).equals("*")) {
return BaggageSpanProcessor.allowAllBaggageKeys();
}
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 optimization is not really necessary as an equivalent is implemented in GlobUtils, we could however do this in IncludeExcludePredicate as a follow-up improvement.

@SylvainJuge SylvainJuge self-assigned this Apr 29, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.

Comment thread baggage-processor/README.md Outdated
Comment thread baggage-processor/README.md Outdated
Comment on lines +65 to +66
import io.opentelemetry.contrib.baggage.processor;

Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

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

In the Java snippet, import io.opentelemetry.contrib.baggage.processor; is not a valid Java import (it imports a package, not a type). Update the example to import the concrete classes used (e.g., BaggageSpanProcessor, BaggageLogRecordProcessor, and any SDK types).

Copilot uses AI. Check for mistakes.
Comment thread baggage-processor/README.md
SylvainJuge and others added 6 commits April 29, 2026 13:44
…ge/processor/BaggageSpanProcessor.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ge/processor/BaggageLogRecordProcessor.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@SylvainJuge SylvainJuge changed the title baggage delegate to IncludeExcludePredicate and allow wildcards in configuration baggage delegate to IncludeExcludePredicate and allow wildcards in auto-configuration Apr 29, 2026
Copy link
Copy Markdown
Member

@MikeGoldsmith MikeGoldsmith left a comment

Choose a reason for hiding this comment

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

Over all looks good, thanks @SylvainJuge 👍🏻

Some docs notes:

The switch from exact matching (keys::contains) to a glob pattern match via IncludeExcludePredicate is a behavioural change for auto-configuration users. Config values containing glob-special characters (?, [, ]) would now be interpreted as patterns instead of literal key names. I think it's unlikely to affect anyone but worth noting it.

Deprecating the Predicate<String> constructor removes the ability to express some filtering logic options (eg startsWith). The glob pattern constructor covers common cases but isn't a full replacement. I think we should document the trade-off in the deprecation notice.

Co-authored-by: Mike Goldsmith <goldsmith.mike@gmail.com>
@github-actions github-actions Bot requested a review from MikeGoldsmith May 4, 2026 17:23
Copy link
Copy Markdown
Contributor

@breedx-splk breedx-splk left a comment

Choose a reason for hiding this comment

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

Looks good to me. I'm not sure if this was previously covered, but if both the include and exclude are provided, and an entry matches both, which one wins out? Is there a test that shows/covers that?

@SylvainJuge
Copy link
Copy Markdown
Contributor Author

I'm not sure if this was previously covered, but if both the include and exclude are provided, and an entry matches both, which one wins out? Is there a test that shows/covers that?

I've opened open-telemetry/opentelemetry-java#8371 to add a dedicated test for the case where both include and exclude match the provided value, the spec is quite clear in this case: when both match then the exclusion has priority and thus the value is excluded.

@jaydeluca
Copy link
Copy Markdown
Member

@MikeGoldsmith just wanted to check in to see if you had any other concerns or if this is now good to go? thanks!

Copy link
Copy Markdown
Member

@MikeGoldsmith MikeGoldsmith left a comment

Choose a reason for hiding this comment

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

I think only thing I'd like to see is a deprecation notice for Predicate<String> to describe how it's different from the new one. They don't work the same, so we should let people know.

@SylvainJuge
Copy link
Copy Markdown
Contributor Author

I think only thing I'd like to see is a deprecation notice for Predicate<String> to describe how it's different from the new one. They don't work the same, so we should let people know.

@MikeGoldsmith, can you clarify what and where would you like to see this added ?

  • in the code examples in the readme
  • in this PR description
  • in the release notes
  • somewhere in the javadoc comments that isn't yet covered
  • all of the above

@github-actions github-actions Bot requested a review from MikeGoldsmith May 6, 2026 08:16
Copy link
Copy Markdown
Member

@MikeGoldsmith MikeGoldsmith left a comment

Choose a reason for hiding this comment

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

This looks good to me, thanks @SylvainJuge.

Sorry the ask for docs wasn't clear. I've left a note for where I think it would be useful. In the changelog / PR desc would also be good for easier discoverability.

@github-actions github-actions Bot requested a review from MikeGoldsmith May 6, 2026 11:56
@MikeGoldsmith
Copy link
Copy Markdown
Member

Thanks @SylvainJuge 👍🏻

@jaydeluca jaydeluca added this pull request to the merge queue May 7, 2026
Merged via the queue into open-telemetry:main with commit 2ecad69 May 7, 2026
20 checks passed
@SylvainJuge SylvainJuge deleted the baggage-minor-simplification branch May 7, 2026 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants