class SofaRpcMetrics extends Subscriber implements MeterBinder, AutoCloseable {

    @Override
    public void bindTo(MeterRegistry registry) {
        Gauge.builder("sofa.threadpool.config.core", () -> Optional.of(serverConfig)
            .map(AtomicReference::get)
            .map(ServerConfig::getCoreThreads)
            .orElse(0))
            .tags(common)
            .baseUnit(BaseUnits.THREADS)
            .register(registry);
        Gauge.builder("sofa.threadpool.config.max", () -> Optional.of(serverConfig)
            .map(AtomicReference::get)
            .map(ServerConfig::getMaxThreads)
            .orElse(0))
            .tags(common)
            .baseUnit(BaseUnits.THREADS)
            .register(registry);
        Gauge.builder("sofa.threadpool.config.queue", () -> Optional.of(serverConfig)
            .map(AtomicReference::get)
            .map(ServerConfig::getQueues)
            .orElse(0))
            .tags(common)
            .baseUnit(BaseUnits.TASKS)
            .register(registry);
        Gauge.builder("sofa.threadpool.active", () -> Optional.of(executor)
            .map(AtomicReference::get)
            .map(ThreadPoolExecutor::getActiveCount)
            .orElse(0))
            .tags(common)
            .baseUnit(BaseUnits.THREADS)
            .register(registry);
        Gauge.builder("sofa.threadpool.idle", () -> Optional.of(executor)
            .map(AtomicReference::get)
            .map(e -> e.getPoolSize() - e.getActiveCount())
            .orElse(0))
            .tags(common)
            .baseUnit(BaseUnits.THREADS)
            .register(registry);
        Gauge.builder("sofa.threadpool.queue.size", () -> Optional.of(executor)
            .map(AtomicReference::get)
            .map(ThreadPoolExecutor::getQueue)
            .map(Collection::size)
            .orElse(0))
            .tags(common)
            .baseUnit(BaseUnits.TASKS)
            .register(registry);
        provider = Counter.builder("sofa.provider")
            .tags(common)
            .register(registry);
        consumer = Counter.builder("sofa.consumer")
            .tags(common)
            .register(registry);

        initialed.set(registry);
    }

    public  SofaRpcMetrics();
    public  SofaRpcMetrics(Iterable<Tag> common);

}