Rate limiter for tracing #3006
-
I'm new to Rust and Tracing library. I need a way to limit the number of messages logged per duration, lets assume second for discussion. I was reading through the documentation of tracing crate and what I understood is tracing has concept of span and event. In our case, span is created when request starts and there are some events not in context of a span like when service starts up. Then there is method name enabled on Subscriber, Layer and Filter. If enabled returns false for a span that was created (which in our case is per request) then all events logged in the context of the span will also be skipped i.e., not logged. So I wrote a simple filter to test. The filter maintains limit for span and out of span events. When I tested, I noticed even if the Filter.enabled method returned false for span the events in scope of span were logged. Like example below, I wasn't expecting the event in "span 3" to be logged because we had reached the limit. Is following understanding correct, if a Filter.enabled returns false for a span (span 3 here) then events in scope of the span (event in span 3) are not logged?
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
No, filtering the span does not filter out any events. They'll just have a different parent or no parent if they are not in any other span. |
Beta Was this translation helpful? Give feedback.
No, filtering the span does not filter out any events. They'll just have a different parent or no parent if they are not in any other span.