use of com.tencent.polaris.api.plugin.stat.StatReporter in project polaris-java by polarismesh.
the class InMemoryRegistry method reportCircuitStat.
private void reportCircuitStat(Entry<StatusDimension, CircuitBreakerStatus> dimensionEntry, Instance instance) {
if (null != statPlugins) {
try {
for (Plugin statPlugin : statPlugins) {
if (statPlugin instanceof StatReporter) {
StatInfo info = new StatInfo();
info.setCircuitBreakGauge(convertToCircuitBreakGauge(dimensionEntry, instance));
((StatReporter) statPlugin).reportStat(info);
}
}
} catch (Exception ex) {
LOG.info("circuit breaker report encountered exception, e: {}", ex.getMessage());
}
}
}
use of com.tencent.polaris.api.plugin.stat.StatReporter in project polaris-java by polarismesh.
the class DefaultLimitAPI method reportRateLimit.
private void reportRateLimit(QuotaRequest req, QuotaResponse rsp) {
if (null != statPlugins) {
try {
DefaultRateLimitResult rateLimitGauge = new DefaultRateLimitResult();
rateLimitGauge.setLabels(formatLabelsToStr(req.getLabels()));
rateLimitGauge.setMethod(req.getMethod());
rateLimitGauge.setNamespace(req.getNamespace());
rateLimitGauge.setService(req.getService());
rateLimitGauge.setResult(rsp.getCode() == QuotaResultOk ? RateLimitGauge.Result.PASSED : RateLimitGauge.Result.LIMITED);
StatInfo statInfo = new StatInfo();
statInfo.setRateLimitGauge(rateLimitGauge);
for (Plugin statPlugin : statPlugins) {
if (statPlugin instanceof StatReporter) {
((StatReporter) statPlugin).reportStat(statInfo);
}
}
} catch (Exception ex) {
LOG.info("rate limit report encountered exception, e: {}", ex.getMessage());
}
}
}
Aggregations