Add exception handler overloads to ObserveDuration#396
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #396 +/- ##
==========================================
+ Coverage 88.83% 90.33% +1.50%
==========================================
Files 48 48
Lines 1738 1770 +32
Branches 233 234 +1
==========================================
+ Hits 1544 1599 +55
+ Misses 141 119 -22
+ Partials 53 52 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
d3e28a2 to
60f68f4
Compare
There was a problem hiding this comment.
Pull request overview
This PR extends IValueObserver duration-measurement extension methods to optionally route exceptions thrown by Observe(...) to a caller-provided exceptionHandler, while allowing exceptions from the measured user code to propagate normally.
Changes:
- Added
exceptionHandleroverloads forObserveDuration/ObserveDurationAsync(sync + generic, async + generic). - Introduced a shared helper to perform
Observe(...)with optional exception handling. - Added a new test suite covering success paths, method-exception paths, and observe-exception handling behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/Prometheus.Client.Abstractions/ValueObserverExtensions.cs |
Adds new overloads and a helper to handle exceptions thrown by Observe(...) separately from the measured method. |
tests/Prometheus.Client.Tests/ValueObserverExtensionsTests.cs |
Adds comprehensive tests for the new overloads and preserves existing behavior expectations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Close: #183
Add
onObserveExceptionoverloads toObserveDurationandObserveDurationAsync, allowing exceptions fromObserveto be handled separately from exceptions thrown by the measured code.Action<Exception> onObserveExceptionwhich is called only whenObservethrows