|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
/*
|
|
|
|
|
* Tencent is pleased to support the open source community by making spring-cloud-tencent available.
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
|
|
|
|
|
* Copyright (C) 2021 Tencent. All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the BSD 3-Clause License (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
@ -65,6 +65,11 @@ public class SuccessCircuitBreakerReporter implements EnhancedPlugin {
|
|
|
|
|
this.circuitBreakAPI = circuitBreakAPI;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static boolean existMetadataValue(MetadataObjectValue<?> metadataObjectValue) {
|
|
|
|
|
return Optional.ofNullable(metadataObjectValue).map(MetadataObjectValue::getObjectValue).
|
|
|
|
|
map(Optional::isPresent).orElse(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getName() {
|
|
|
|
|
return SuccessCircuitBreakerReporter.class.getName();
|
|
|
|
@ -82,7 +87,8 @@ public class SuccessCircuitBreakerReporter implements EnhancedPlugin {
|
|
|
|
|
}
|
|
|
|
|
EnhancedRequestContext request = context.getRequest();
|
|
|
|
|
EnhancedResponseContext response = context.getResponse();
|
|
|
|
|
ServiceInstance serviceInstance = Optional.ofNullable(context.getTargetServiceInstance()).orElse(new DefaultServiceInstance());
|
|
|
|
|
ServiceInstance serviceInstance = Optional.ofNullable(context.getTargetServiceInstance())
|
|
|
|
|
.orElse(new DefaultServiceInstance());
|
|
|
|
|
|
|
|
|
|
ResourceStat resourceStat = PolarisEnhancedPluginUtils.createInstanceResourceStat(
|
|
|
|
|
serviceInstance.getServiceId(),
|
|
|
|
@ -95,7 +101,8 @@ public class SuccessCircuitBreakerReporter implements EnhancedPlugin {
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
LOG.debug("Will report CircuitBreaker ResourceStat of {}. Request=[{} {}]. Response=[{}]. Delay=[{}]ms.",
|
|
|
|
|
resourceStat.getRetStatus().name(), request.getHttpMethod().name(), request.getUrl().getPath(), response.getHttpStatus(), context.getDelay());
|
|
|
|
|
resourceStat.getRetStatus().name(), request.getHttpMethod().name(), request.getUrl()
|
|
|
|
|
.getPath(), response.getHttpStatus(), context.getDelay());
|
|
|
|
|
|
|
|
|
|
circuitBreakAPI.report(resourceStat);
|
|
|
|
|
|
|
|
|
@ -141,9 +148,4 @@ public class SuccessCircuitBreakerReporter implements EnhancedPlugin {
|
|
|
|
|
public int getOrder() {
|
|
|
|
|
return CIRCUIT_BREAKER_REPORTER_PLUGIN_ORDER;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static boolean existMetadataValue(MetadataObjectValue<?> metadataObjectValue) {
|
|
|
|
|
return Optional.ofNullable(metadataObjectValue).map(MetadataObjectValue::getObjectValue).
|
|
|
|
|
map(Optional::isPresent).orElse(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|