I’m trying to filter out the PartitionEOF
error log messages that the rdkafka
crate produces when you have enable.partition.eof
set to true
.
We’re using the tracing
and tracing-subscriber
traits for logging.
The log messages look like this:
{
"timestamp": ...,
"level": "ERROR",
"fields": {
"message": "librdkafka: Global error: PartitionEOF (Broker: No more messages): Fetch from broker 1 reached end of partition at offset ... (HighwaterMark ...)",
"log.target": "rdkafka::client",
...
},
"target": "rdkafka::client",
"threadId": ...
}
As I understand from the tracing-subscriber
documentation, I should be able to do something like this:
let filter = EnvFilter::from_default_env()
.add_directive("rdkafka::client[{message="librdkafka: Global error: PartitionEOF.*"}]=off".parse().unwrap());
tracing_subscriber::fmt()
.json()
.with_env_filter(filter)
.with_thread_ids(true)
.init();
However, that filter isn’t working. And futhermore, I can’t get any filter to work where I specify the value for a message.
For example, suppose I have the following:
let filter = EnvFilter::from_default_env()
.add_directive("[{message="asdf"}]=off".parse().unwrap());
tracing_subscriber::fmt()
.json()
.with_env_filter(filter)
.with_thread_ids(true)
.init();
info!("asdf");
… in that case, the "asdf"
message is not filtered out.
Similarly, changing the filter to "[{message=asdf}]=off"
does not filter out the "asdf"
log message.
However, changing the filter to "[{message}]=off"
does filter the message.
What’s going on here? Why is specifying a value not working as per the syntax described in the documentation?
target[span{field=value}]=level