Skip to content

[processor/tailsampling] Give composite sub-policies omitted from rat… - #49857

Open
Atishyy27 wants to merge 2 commits into
open-telemetry:mainfrom
Atishyy27:fix/49828-composite-omitted-rate-allocation
Open

[processor/tailsampling] Give composite sub-policies omitted from rat…#49857
Atishyy27 wants to merge 2 commits into
open-telemetry:mainfrom
Atishyy27:fix/49828-composite-omitted-rate-allocation

Conversation

@Atishyy27

Copy link
Copy Markdown

Description

getRateAllocationMap previously iterated only over entries in rate_allocation. As a result, any configured composite sub-policy that was omitted from rate_allocation was never assigned a MaxSpansPerSecond value and implicitly defaulted to 0, preventing it from sampling any spans.

The documented behavior is that sub-policies without an explicit allocation receive the default equal share (max_total_spans_per_second / number of sub-policies). This is also the behavior already applied to entries with percent: 0.

This change iterates over every configured sub-policy, applying the configured percentage when present and falling back to the default equal-share allocation otherwise.

Link to tracking issue

Fixes #49828

Testing

Added a TestCompositeHelper test case covering the scenario where a configured sub-policy is omitted from rate_allocation. The test configures two sub-policies with a total rate of 1000 spans/second, assigns one policy an explicit allocation of 25%, and verifies that the omitted policy receives the default allocation of 500 (1000 / 2) rather than 0.

The test fails with the previous implementation and passes with this change.

Documentation

No documentation changes were required. This change aligns the implementation with the existing documented behavior for composite rate allocation.

Authorship

  • I, a human, wrote this pull request description myself.

…e_allocation their default share

getRateAllocationMap iterated only over RateAllocation entries, so any
sub-policy not listed there was never assigned a MaxSpansPerSecond and
defaulted to 0, permanently blocking it from sampling. Iterate over every
configured sub-policy instead, falling back to the equal-share default
(MaxTotalSpansPerSecond / number of sub-policies) already used for entries
with Percent == 0.

Fixes open-telemetry#49828.
@Atishyy27
Atishyy27 requested review from a team and jmacd as code owners July 23, 2026 21:15
@github-actions github-actions Bot added the first-time contributor PRs made by new contributors label Jul 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Welcome, contributor! Thank you for your contribution to opentelemetry-collector-contrib.

Important reminders:

  • Read our Contributing Guidelines.
  • Sign the CLA if you haven't already.
  • Follow the OpenTelemetry Generative AI policy: disclose any AI use in your contribution, and communicate (PR descriptions, review replies) in your own words rather than AI-generated text.
  • Give reviewers at least a few days before pinging them for feedback.
  • If you need help with general setup, development process, or contributor etiquette, ask in #opentelemetry-new-contributors.
  • First-time contributors should have at most one PR not marked as draft until their first PR is merged.
  • If your change isn't one of our priority components, reviews may take more time.
  • Raise technical or Collector-specific questions in #otel-collector-dev or a Collector SIG meeting.

@github-actions github-actions Bot added the processor/tailsampling Tail sampling processor label Jul 23, 2026
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Jul 23, 2026

Copy link
Copy Markdown

Pull request dashboard status

Status last refreshed: 2026-07-27 21:18:55 UTC.

  • Waiting on: Reviewers
  • Next step: Review the latest changes.

This automated status or its linked feedback items may be incorrect. If something looks wrong, please report it with the result you expected.

@paulojmdias

Copy link
Copy Markdown
Member

/workflow-approve

@singhvibhanshu

Copy link
Copy Markdown
Member

Please fix the linter issue.

golangci-lint (gocritic rangeValCopy) flagged the range-over-SubPolicyCfg
loop copying a 456-byte struct each iteration. Iterate by index and take a
pointer instead. No behavior change.
@Atishyy27

Copy link
Copy Markdown
Author

Switched to indexed iteration so the sub-policy loop no longer copies the struct, addressing the linter warning. This was fixed in commit 2b25da9. @singhvibhanshu, could you please review and re-run/approve the workflow when you have a chance? The latest run is waiting for maintainer approval.

@singhvibhanshu

Copy link
Copy Markdown
Member

/workflow-approve

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

first-time contributor PRs made by new contributors processor/tailsampling Tail sampling processor waiting-for-code-owners

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Composite tail sampling policy gives unspecified sub-policies a zero sampling rate instead of the documented default allocation

3 participants