Skip to content

Add AlwaysRecordSampler#7877

Merged
jack-berg merged 1 commit into
open-telemetry:mainfrom
majanjua-amzn:main
Jan 22, 2026
Merged

Add AlwaysRecordSampler#7877
jack-berg merged 1 commit into
open-telemetry:mainfrom
majanjua-amzn:main

Conversation

@majanjua-amzn

@majanjua-amzn majanjua-amzn commented Nov 27, 2025

Copy link
Copy Markdown
Contributor

Background

Spec issue: open-telemetry/opentelemetry-specification#4698
Spec PR: open-telemetry/opentelemetry-specification#4699

Adding built in access to the RECORD_ONLY flag for sampling to allow for users to process spans without exporting them.

Changes

Testing

Added unit tests, ./gradlew spotlessApply && ./gradlew build && ./gradlew check as per CONTRIBUTING.md guide

@codecov

codecov Bot commented Nov 27, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.15%. Comparing base (18f8a13) to head (f699191).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #7877   +/-   ##
=========================================
  Coverage     90.15%   90.15%           
- Complexity     7476     7481    +5     
=========================================
  Files           836      837    +1     
  Lines         22551    22567   +16     
  Branches       2224     2225    +1     
=========================================
+ Hits          20330    20346   +16     
  Misses         1517     1517           
  Partials        704      704           

☔ 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.

@majanjua-amzn

Copy link
Copy Markdown
Contributor Author

Ready for review!

@breedx-splk breedx-splk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the PR. I think my biggest question is about how this will get used (if internal), but otherwise is looking good to me. There's also a merge conflict that needs to be resolved before merge.

// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package io.opentelemetry.sdk.trace.internal;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this the correct package? How are you planning for this to be consumed by users if it's internal?

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.

Experimental SDK components is the place we've been least consistent about in terms of packaging, since sometimes the concept needs to be bundled into the SDK internals to work (i.e. ExceptionAttributeResolver). But for components which are SDK extension plugin interfaces (span processor, sampler, etc), we've been keeping them in opentelemetry-sdk-extension-incubator. Here's the relevant package for samplers: https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/trace/samplers

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.

Moved the code to the incubator package

@jack-berg jack-berg left a comment

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.

Couple small things that need adjusting. Thanks for working on this!

@jack-berg jack-berg linked an issue Dec 19, 2025 that may be closed by this pull request
@breedx-splk

Copy link
Copy Markdown
Contributor

bump @majanjua-amzn in case you can circle back to this now in the new year. 😉 Thanks again!

@majanjua-amzn
majanjua-amzn force-pushed the main branch 2 times, most recently from 7d9e351 to 3dd5a79 Compare January 21, 2026 00:05
@majanjua-amzn

Copy link
Copy Markdown
Contributor Author

Ready for review again! Apologies for the delay, cc @jack-berg since you marked it as requested change, thanks in advance

@jack-berg jack-berg left a comment

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.

Thanks!

@jack-berg
jack-berg merged commit 8e332fc into open-telemetry:main Jan 22, 2026
27 checks passed
@otelbot

otelbot Bot commented Jan 22, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution @majanjua-amzn! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey.

github-merge-queue Bot pushed a commit to open-telemetry/opentelemetry-specification that referenced this pull request Mar 13, 2026
The `AlwaysRecord` sampler has been in our development since the
December 2025 release, and it has prototypes in the following languages:

* Java: open-telemetry/opentelemetry-java#7877
* Go: open-telemetry/opentelemetry-go#7714
* PHP: open-telemetry/opentelemetry-php#1834
* Javascript:
open-telemetry/opentelemetry-js#6168
* Python:
open-telemetry/opentelemetry-python#4823
* DotNet:
open-telemetry/opentelemetry-dotnet#6732 (got
closed but hopefully we bring it back)
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.

Add alwaysRecord Sampler

3 participants