Skip to content

Add logs sampler #7210

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

oliver-zhang
Copy link
Contributor

Sometimes we don't want to collect all the logs, we only need the logs associated with the call chain. The goal of this PR is to provide a mechanism for users to customize the log sampling rules to meet custom requirements.Add logs sampler

@oliver-zhang oliver-zhang requested a review from a team as a code owner March 19, 2025 09:19
@jkwatson
Copy link
Contributor

Do you have a link to the relevant specification that includes this feature? We'd need to have it merged into the spec before we could include it here.

@oliver-zhang
Copy link
Contributor Author

Do you have a link to the relevant specification that includes this feature? We'd need to have it merged into the spec before we could include it here.

No,I don't know if the specification has this implementation plan

@jack-berg
Copy link
Member

No,I don't know if the specification has this implementation plan

This repo is limited in scope to components which implement concepts defined in the spec.

I do think this is a useful concept, particularly the ability to only retain logs if they have an associated span which is sampled.

Your options include:

  • Use this PR / branch as a prototype and try to update the spec to include this concept.
  • Move to opentelemetry-java-contrib and refactor to work as a LogRecordProcessor. For example, you could have a FilteringLogRecordProcessor which accepts a Predicate<LogRecordData> and a delegate LogRecordProcessor as arguments. When FilteringLogRecordProcessor#onEmit is called, the implementation would: call delegate.onEmit(..) if predicate.test(logRecord) == true. The normal use would be be to pair FilteringLogRecordProcessor with a BatchLogRecordProcessor. I believe this would achieve the same effect as what you've shown in this PR.

@oliver-zhang oliver-zhang marked this pull request as draft April 1, 2025 10:03
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.

3 participants