Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ability to swallow/ignore exceptions from Observe functionality; but throw from Func #183

Open
cscoon opened this issue Jan 31, 2022 · 0 comments

Comments

@cscoon
Copy link

cscoon commented Jan 31, 2022

When a histogram is observed, the code that is being measured is sent to ObserveDuration or ObserveDurationAsync as a Func parameter.

We have a requirement where if any Prometheus operations results in an exception (ex: IncTo, ObserveDuration, etc.), that exception should be swallowed/ignored so that it doesn't interrupt the execution path where IncTo or ObserveDuration was called.

However, if the code in the Func that was passed in throws an exception, we do want that exception to bubble up.

This is an issue with ObserveDuration because both ObserveDuration and the Func are called from the same line of code. This prevents us from taking the action we've taken in the past - using a try/catch to swallow the exception - because it would swallow the exception from the Func as well.

I've taken a brief look at the source code, and it appears that this would be very possible due to the fact that there are basically only two lines of code in ObserveDuration - one that executes the Func, and one that observes the value.

Note: All of these comments apply to both ObserveDuration and ObserveDurationAsync

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants