Swallow exceptions from ObserveDurationAsync, but throw from Func input? #182
-
We wrap our Prometheus metric emitting calls in a wrapper class which essentially catches any exceptions thrown while incrementing a metric and swallows it. The reason is that if we are performing an important business process, we would rather ignore the exception from This works great for most Prometheus.Client methods such as What we'd like to do is ignore/swallow any exception that results from Does Prometheus.Client provide a pattern for doing this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
No. We do not have anything like this for now, but probably can add this as a extension method argument or even metric config. The first approach allow us to localize the changes, but last one looks more generic. But not sure if it makes sense. @phnx47 what do you think? Is adding new metric family configuration (for any kind of metric metrics) to ignore any exceptions while observations is valuable? I mean suppress any exception that could appear inside Inc, Dec, etc methods. If we go this way we probably have to at least report the exception to diagnostics source. |
Beta Was this translation helpful? Give feedback.
No. We do not have anything like this for now, but probably can add this as a extension method argument or even metric config. The first approach allow us to localize the changes, but last one looks more generic. But not sure if it makes sense.
@phnx47 what do you think? Is adding new metric family configuration (for any kind of metric metrics) to ignore any exceptions while observations is valuable? I mean suppress any exception that could appear inside Inc, Dec, etc methods. If we go this way we probably have to at least report the exception to diagnostics source.