telemetry: exists
condition is not triggered with some custom events
#5702
Labels
exists
condition is not triggered with some custom events
#5702
In some cases
exists
condition doesn't work properly. For example with a simple use case "I don't want to log for unnamed operation". We would be tempted to create this configuration:but the way it's implemented doesn't fit this use case. Because of custom instruments that can be triggered at any stages (
response
|request
|error
|...) we can't just return a boolean. Because for example if we want to create a metric measuring the duration with a condition onstatus_code
at router level then first when we will try to compute it we will check if the condition for request matches or not. If the selector is applied at the response level likestatus_code
once we will hiton_request
if we just return a boolean it will return false and then we won't compute it later. The reason is to optimize perf you don't want to compute something that is not going to be useful. That's why in this case we just returnNone
because nothing returned from theon_request
method on selector so we will continue to compute it later.I can see 2 solutions here:
We just remove this optimization and keep the instrument running even if we received
false
onon_request
call. Could we have side effects by doing this ?I think something that might be useful for future improvements. We should provide a new method on
Selector
trait to indicate at which stage it can get some values. Something likestage(&self) -> &[Stage]
which contains all the potential stages at which we can return some data. Thanks to this we will be able to know if we can directly shut down the instruments or even just not compute useless stages.The main question we should have is about side effects that this could create.
The current workaround if you're trying to achieve the example with
operation_name
is to useeq
with thedefault
configuration like this:The text was updated successfully, but these errors were encountered: