Skip to content

Migrate sampler to non-contrib SDK incubator implementation#1091

Closed
anuraaga wants to merge 1 commit into
elastic:mainfrom
anuraaga:sdk-composable-sampler
Closed

Migrate sampler to non-contrib SDK incubator implementation#1091
anuraaga wants to merge 1 commit into
elastic:mainfrom
anuraaga:sdk-composable-sampler

Conversation

@anuraaga
Copy link
Copy Markdown
Contributor

@anuraaga anuraaga commented May 1, 2026

No description provided.

@anuraaga anuraaga requested a review from a team as a code owner May 1, 2026 01:23
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 1, 2026

📋 Changelog

Generated changelog entry for docs/changelog/1091\.yaml:

prs:
- "1091"
type: enhancement
products:
- product: edot-java
  lifecycle: ga
title: Migrate sampler to non-contrib SDK incubator implementation

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 1, 2026

📝 Walkthrough

Walkthrough

The changes replace the consistent sampling library with the composite sampler framework. The libs.contribConsistentSampling dependency and its transitive exclusions are removed from the build configuration. The sampler implementation is updated to use composite sampler construction via parentThreshold() combined with probability(ratio) instead of ConsistentSampler. Imports are updated accordingly to reflect the new sampler types.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • 🛠️ Update Documentation: Commit on current branch
  • 🛠️ Update Documentation: Create PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
custom/src/main/java/co/elastic/otel/compositesampling/DynamicCompositeParentBasedTraceIdRatioBasedSampler.java (1)

54-57: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Fix the recursive description implementation.

getDescription() calls INSTANCE.getDescription(), which recurses on the same singleton and will overflow the stack as soon as the SDK asks for a description.

Suggested fix
 `@Override`
 public String getDescription() {
-  return INSTANCE.getDescription();
+  return delegate.getDescription();
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@custom/src/main/java/co/elastic/otel/compositesampling/DynamicCompositeParentBasedTraceIdRatioBasedSampler.java`
around lines 54 - 57, The getDescription method currently calls
INSTANCE.getDescription(), causing infinite recursion; change it to return the
description of the underlying/wrapped sampler used by this composite (not the
singleton INSTANCE). In other words, inside
DynamicCompositeParentBasedTraceIdRatioBasedSampler.getDescription() return the
wrapped sampler's description (e.g., wrappedSampler.getDescription() or
delegateSampler.getDescription() — whatever field holds the underlying sampler
in this class) or a fixed descriptive string for this composite, instead of
delegating to INSTANCE.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In
`@custom/src/main/java/co/elastic/otel/compositesampling/DynamicCompositeParentBasedTraceIdRatioBasedSampler.java`:
- Around line 54-57: The getDescription method currently calls
INSTANCE.getDescription(), causing infinite recursion; change it to return the
description of the underlying/wrapped sampler used by this composite (not the
singleton INSTANCE). In other words, inside
DynamicCompositeParentBasedTraceIdRatioBasedSampler.getDescription() return the
wrapped sampler's description (e.g., wrappedSampler.getDescription() or
delegateSampler.getDescription() — whatever field holds the underlying sampler
in this class) or a fixed descriptive string for this composite, instead of
delegating to INSTANCE.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 081d07c9-6e2a-4820-8ae1-3c72eb894023

📥 Commits

Reviewing files that changed from the base of the PR and between 9e8e95b and 5766185.

📒 Files selected for processing (2)
  • custom/build.gradle.kts
  • custom/src/main/java/co/elastic/otel/compositesampling/DynamicCompositeParentBasedTraceIdRatioBasedSampler.java
💤 Files with no reviewable changes (1)
  • custom/build.gradle.kts

@jackshirazi
Copy link
Copy Markdown
Contributor

there's no need for this. we'll migrate the entire dynamic control to the contributed implementation when that's available, then this sampler gets removed, so there's no point in doing this in the interim

@jackshirazi jackshirazi closed this May 1, 2026
@anuraaga
Copy link
Copy Markdown
Contributor Author

anuraaga commented May 1, 2026

@jackshirazi - Just to confirm what do you mean by that? This is the implementation I wrote based on the spec vs contrib which was a pre-spec POC. Isn't it good to switch to the maintained implementation?

I mean I can send a PR to remove the contrib implementation which I think would be merged - would it help? 😉

@jackshirazi
Copy link
Copy Markdown
Contributor

This agent will move to use the dynamic control extension currently being added to contrib. That dynamic control extension already uses the SDK incubator sampler. So applying this PR would soon be pointless, so we'll avoid that additional work for now. Thanks for the contribution though, it would be right if we weren't aiming to switch relatively soon

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.

2 participants