Open scb01 opened 3 months ago
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
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.
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
.
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 ?
No, not planning to use stdout exporter
in production, but just using it here as an example.
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.
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
.
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 levelinfo
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 theBatchLogConfig
and have that be honored in theBatchLogProcessor
. 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 thelogs_level_enabled
feature.Considered Alternatives
No response
Additional Context
No response