You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "AlbumenJ (via GitHub)" <gi...@apache.org> on 2023/07/31 05:49:39 UTC
[GitHub] [dubbo] AlbumenJ commented on a diff in pull request #12817: :ambulance: avoid metric bug
AlbumenJ commented on code in PR #12817:
URL: https://github.com/apache/dubbo/pull/12817#discussion_r1278817038
##########
dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/MetricsEventBus.java:
##########
@@ -63,27 +68,49 @@ public static <T> T post(MetricsEvent event, Supplier<T> targetSupplier) {
*/
public static <T> T post(MetricsEvent event, Supplier<T> targetSupplier, Function<T, Boolean> trFunction) {
T result;
- before(event);
+ tryInvoke(() -> {
+ before(event);
+ });
if (trFunction == null) {
try {
result = targetSupplier.get();
} catch (Throwable e) {
- error(event);
+ tryInvoke(() -> {
+ error(event);
+ });
throw e;
}
- after(event, result);
+ tryInvoke(() -> {
+ after(event, result);
+ });
} else {
// Custom failure status
result = targetSupplier.get();
if (trFunction.apply(result)) {
- after(event, result);
+ tryInvoke(() -> {
+ after(event, result);
+ });
} else {
- error(event);
+ tryInvoke(() -> {
+ error(event);
+ });
}
}
return result;
}
+ interface TryCallBack {
+ void callback();
+ }
+
+ public static void tryInvoke(TryCallBack tryCallBack) {
+ try {
+ tryCallBack.callback();
+ } catch (Throwable e2) {
+ logger.debug("MetricsEventBus tryInvoke error", e2);
Review Comment:
```suggestion
logger.warn("MetricsEventBus tryInvoke error", e2);
```
warn with error code
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org