All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mvnsearch.spring.boot.dubbo.actuate.DubboMetrics Maven / Gradle / Ivy

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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy