org.mvnsearch.spring.boot.dubbo.actuate.DubboMetrics Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spring-boot-starter-dubbo Show documentation
Show all versions of spring-boot-starter-dubbo Show documentation
provide a simple spring-boot-stater for dubbo
The newest version!
package org.mvnsearch.spring.boot.dubbo.actuate;
import org.mvnsearch.spring.boot.dubbo.filter.ConsumerInvokeStaticsFilter;
import org.mvnsearch.spring.boot.dubbo.filter.ProviderInvokeStaticsFilter;
import org.springframework.boot.actuate.endpoint.PublicMetrics;
import org.springframework.boot.actuate.metrics.Metric;
import org.springframework.stereotype.Component;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
/**
* dubbo metrics
*
* dubbo 的统计数据
*
* @author linux_china
*/
@Component
public class DubboMetrics implements PublicMetrics {
public Collection> metrics() {
List> metrics = new LinkedList>();
if (!ConsumerInvokeStaticsFilter.statics.isEmpty()) {
for (Map.Entry entry : ConsumerInvokeStaticsFilter.statics.entrySet()) {
metrics.add(new Metric("dubbo." + entry.getKey(), entry.getValue().get()));
}
}
if (!ProviderInvokeStaticsFilter.statics.isEmpty()) {
for (Map.Entry entry : ProviderInvokeStaticsFilter.statics.entrySet()) {
metrics.add(new Metric("dubbo." + entry.getKey(), entry.getValue().get()));
}
}
return metrics;
}
}