MetricSystem.java 文件源码

java
阅读 32 收藏 0 点赞 0 评论 0

项目:Microservices-Deployment-Cookbook 作者:
@PostConstruct
    public void init() {
        //      ConsoleReporter consoleReporter = ConsoleReporter.forRegistry(metricRegistry)
        //              .convertRatesTo(TimeUnit.SECONDS)
        //              .convertDurationsTo(TimeUnit.MILLISECONDS)
        //              .build();
        //
        //      consoleReporter.start(10, TimeUnit.SECONDS);

//      Graphite graphite = new Graphite(new InetSocketAddress("192.168.99.100", 2003));
//      GraphiteReporter graphiteReporter = GraphiteReporter.forRegistry(metricRegistry)
//              .prefixedWith("com.packt.microservices.geolocation")
//              .convertRatesTo(TimeUnit.SECONDS)
//              .convertDurationsTo(TimeUnit.MILLISECONDS)
//              .filter(MetricFilter.ALL)
//              .build(graphite);
//      graphiteReporter.start(60, TimeUnit.SECONDS);


        geolocationWriteRequestCount = metricRegistry.counter("geolocationWriteRequestCount");
        metricRegistry.register("geolocationLastWriteTime", new Gauge<Long>() {
            @Override
            public Long getValue() {
                return geolocationLastWriteTime;
            }
        });

        metricRegistry.registerAll(new MetricSet() {
            @Override
            public Map<String, Metric> getMetrics() {

                Map<String, Metric> metrics = new HashMap<>();
                metrics.put("geolocationMemoryUsage", new MemoryUsageGaugeSet());
                metrics.put("geolocationClassLoading", new ClassLoadingGaugeSet());
                metrics.put("geolocationGarbageCollector", new GarbageCollectorMetricSet());
                return metrics;
            }
        });
    }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号