Skip to content
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

[Feature]: Severity filter support in BatchLogProcessor #1881

Open
scb01 opened this issue Jun 13, 2024 · 7 comments
Open

[Feature]: Severity filter support in BatchLogProcessor #1881

scb01 opened this issue Jun 13, 2024 · 7 comments
Labels
enhancement New feature or request triage:todo Needs to be traiged.

Comments

@scb01
Copy link

scb01 commented Jun 13, 2024

Related Problems?

No response

Describe the solution you'd like:

I would like to be able to configure an exporter to only exports logs at a specified severity or above. For example, in my app, I want to log at a default level of debug, but only export logs of level info and above to an open telemetry collector.

I looked at the logs_level_enabled feature, but based on what I saw in the implementation, it is just a place holder at this point as it is hardcoded to always return true.

A way to accomplish this would be to have a parameter, say export_severity added to the BatchLogConfig and have that be honored in the BatchLogProcessor. I am happy to send a PR if there is agreement with this approach, but wanted to check if this is in line with the plans for full support for the logs_level_enabled feature.

Considered Alternatives

No response

Additional Context

No response

@scb01 scb01 added enhancement New feature or request triage:todo Needs to be traiged. labels Jun 13, 2024
@cijothomas
Copy link
Member

You can do this upstream, even before OpenTelemetry itself. tracing offers filtering mechanism. An example within this repo can be found here : https://github.com/open-telemetry/opentelemetry-rust/blob/main/opentelemetry-otlp/examples/basic-otlp/src/main.rs#L108-L116

@lalitb
Copy link
Member

lalitb commented Jun 13, 2024

Any reason not to create a tokio tracing filter to achieve it, and so drop the event before reaching the otel pipeline.
In case the exporter needs to decide, as of now you would have to create a custom processor as done here.
I don't remember why BatchLogProcessor was hardwired to be always enabled, probably because the feature was more relevant for the synchronous processors.

@scb01
Copy link
Author

scb01 commented Jun 13, 2024

Sorry about not being clearer in my request. The idea is to be able to do this on a per exporter basis. For example, my application logs at debug level and I have two exporters a) stdout exporter and b) otlp exporter. I want to send all logs to exporter a, but only send logs of severity info and above to exporter b.

@cijothomas
Copy link
Member

mm.. 2 loggerproviders (1 with stdout, another with otlp), and create 2 layers with diff. filtering - this should be possible.

These are things typically done at Collector level.
Also - are you using stdout exporter in production in anyway ?

@scb01
Copy link
Author

scb01 commented Jun 13, 2024

No, not planning to use stdout exporter in production, but just using it here as an example.

@scb01
Copy link
Author

scb01 commented Jun 13, 2024

Also, should clarify that I'm using the rust log: https://crates.io/crates/log and not tracing: https://crates.io/crates/tracing for application logging.

@lalitb
Copy link
Member

lalitb commented Jun 13, 2024

mm.. 2 loggerproviders (1 with stdout, another with otlp), and create 2 layers with diff. filtering - this should be possible.

This is the right way to achieving it. Though it would more straightforward with tracing layers, should be also doable with log.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triage:todo Needs to be traiged.
Projects
None yet
Development

No branches or pull requests

3 participants