com.alipay.lookout.api.composite.MixinMetric Java Examples
The following examples show how to use
com.alipay.lookout.api.composite.MixinMetric.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JvmInfoMetricsImporterTest.java From sofa-lookout with Apache License 2.0 | 6 votes |
@Test public void testFileSystemMetricsInfo() { Registry registry = new DefaultRegistry(); FileSystemSpaceMetricsImporter jvmGcMetricsImporter = new FileSystemSpaceMetricsImporter(); jvmGcMetricsImporter.register(registry); Iterator<Metric> iterator = registry.iterator(); String ids = ""; while (iterator.hasNext()) { Metric m = iterator.next(); if (m instanceof MixinMetric) { MixinMetric mm = (MixinMetric) m; for (Object x : mm.measure().measurements()) { ids += x.toString(); } } } Assert.assertTrue(ids.contains("usabe.space")); }
Example #2
Source File: JvmClassesMetricsImporter.java From sofa-lookout with Apache License 2.0 | 6 votes |
@Override public void register(Registry registry) { Id id = registry.createId("jvm.classes"); MixinMetric mixin = registry.mixinMetric(id); mixin.gauge("unloaded", new Gauge<Long>() { @Override public Long value() { return ManagementFactory.getClassLoadingMXBean().getUnloadedClassCount(); } }); mixin.gauge("total", new Gauge<Long>() { @Override public Long value() { return ManagementFactory.getClassLoadingMXBean().getTotalLoadedClassCount(); } }); mixin.gauge("loaded", new Gauge<Integer>() { @Override public Integer value() { return ManagementFactory.getClassLoadingMXBean().getLoadedClassCount(); } }); }
Example #3
Source File: MeasurableScheduler.java From sofa-lookout with Apache License 2.0 | 6 votes |
public MeasurableScheduler(final Registry registry, final String name, int poolSize) { super(poolSize, poolSize, 0, TimeUnit.NANOSECONDS, new DelayQueue(), newThreadFactory(name), new AbortPolicy()); this.registry = registry; Id mixinMetricId = registry.createId("lookout.scheduler." + name).withTag( LookoutConstants.TAG_PRIORITY_KEY, PRIORITY.LOW.name()); MixinMetric mixinMetric = registry.mixinMetric(mixinMetricId); mixinMetric.gauge("queueSize", new Gauge<Integer>() { @Override public Integer value() { return MeasurableScheduler.super.getQueue().size(); } }); activeCount = mixinMetric.counter("activeThreads"); taskExecutionTime = mixinMetric.timer("taskExecutionTime"); taskExecutionDelay = mixinMetric.timer("taskExecutionDelay"); skipped = mixinMetric.counter("skipped"); this.id = mixinMetricId; }
Example #4
Source File: JvmMemoryMetricsImporter.java From sofa-lookout with Apache License 2.0 | 6 votes |
private void heapImport(MixinMetric mixin) { mixin.gauge("heap.init", new Gauge<Long>() { @Override public Long value() { return ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getInit(); } }); mixin.gauge("heap.used", new Gauge<Long>() { @Override public Long value() { return ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed(); } }); mixin.gauge("heap.committed", new Gauge<Long>() { @Override public Long value() { return ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getCommitted(); } }); mixin.gauge("heap.max", new Gauge<Long>() { @Override public Long value() { return ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getMax(); } }); }
Example #5
Source File: JvmInfoMetricsImporterTest.java From sofa-lookout with Apache License 2.0 | 6 votes |
@Test public void testGcInfo() { Registry registry = new DefaultRegistry(); JvmGcMetricsImporter jvmGcMetricsImporter = new JvmGcMetricsImporter(); jvmGcMetricsImporter.register(registry); Id id = registry.createId("jvm.gc"); MixinMetric mixin = registry.mixinMetric(id); Gauge gauge = mixin.gauge("young.count", null); Assert.assertTrue(gauge.value().longValue() >= 0); gauge = mixin.gauge("young.time", null); Assert.assertTrue(gauge.value().longValue() >= 0); gauge = mixin.gauge("old.count", null); Assert.assertTrue(gauge.value().longValue() >= 0); gauge = mixin.gauge("old.time", null); Assert.assertTrue(gauge.value().longValue() >= 0); }
Example #6
Source File: JvmInfoMetricsImporterTest.java From sofa-lookout with Apache License 2.0 | 6 votes |
@Test public void testThreadsInfo() { Registry registry = new DefaultRegistry(); JvmThreadsMetricsImporter importer = new JvmThreadsMetricsImporter(); importer.register(registry); Id id = registry.createId("jvm.threads"); MixinMetric mixin = registry.mixinMetric(id); Gauge gauge = mixin.gauge("peak", null); Assert.assertTrue(gauge.value().longValue() >= 0); gauge = mixin.gauge("daemon", null); Assert.assertTrue(gauge.value().longValue() >= 0); gauge = mixin.gauge("totalStarted", null); Assert.assertTrue(gauge.value().longValue() >= 0); gauge = mixin.gauge("active", null); Assert.assertTrue(gauge.value().longValue() >= 0); }
Example #7
Source File: JvmInfoMetricsImporterTest.java From sofa-lookout with Apache License 2.0 | 6 votes |
@Test public void testBaseInfo() { Registry registry = new DefaultRegistry(); BasicMetricsImporter jvmGcMetricsImporter = new BasicMetricsImporter(); jvmGcMetricsImporter.register(registry); Id id = registry.createId("instance"); MixinMetric mixin = registry.mixinMetric(id); Gauge gauge = mixin.gauge("mem.total", null); Assert.assertTrue(gauge.value().longValue() >= 0); gauge = mixin.gauge("mem.free", null); Assert.assertTrue(gauge.value().longValue() >= 0); gauge = mixin.gauge("processors", null); Assert.assertTrue(gauge.value().longValue() >= 0); gauge = mixin.gauge("uptime", null); Assert.assertTrue(gauge.value().longValue() >= 0); gauge = mixin.gauge("systemload.average", null); Assert.assertTrue(gauge.value().longValue() >= 0); }
Example #8
Source File: JvmInfoMetricsImporterTest.java From sofa-lookout with Apache License 2.0 | 6 votes |
@Test public void testJvmClassInfo() { Registry registry = new DefaultRegistry(); JvmClassesMetricsImporter importer = new JvmClassesMetricsImporter(); importer.register(registry); Id id = registry.createId("jvm.classes"); MixinMetric mixin = registry.mixinMetric(id); Gauge gauge = mixin.gauge("unloaded", null); Assert.assertTrue(gauge.value().longValue() >= 0); gauge = mixin.gauge("total", null); Assert.assertTrue(gauge.value().longValue() >= 0); gauge = mixin.gauge("loaded", null); Assert.assertTrue(gauge.value().longValue() >= 0); }
Example #9
Source File: AbstractExporter.java From sofa-lookout with Apache License 2.0 | 6 votes |
public AbstractExporter(String name, Registry registry, DataType type) { this.name = name; this.registry = registry; Map<String, String> tags = new HashMap<>(); tags.put("exporter", name); // 转成小写, 跟之前保持一致 tags.put("type", type.name().toLowerCase()); Id id = registry.createId("exporter.stats", tags); MixinMetric mm = registry.mixinMetric(id); // 统计导出个数(导出的metric条数) count = mm.counter("count"); // 统计导出次数(每次会导出多条) batch = mm.counter("batch"); // 统计失败次数 fail = mm.counter("fail"); // 统计请求耗时 time = mm.timer("time"); }
Example #10
Source File: NetTrafficMetricsImporter.java From sofa-lookout with Apache License 2.0 | 6 votes |
@Override protected void doRegister(Registry registry) { for (final Map.Entry<String, Long[]> entry : statByFace.entrySet()) { final String face = entry.getKey(); Id id = registry.createId("os.net.stats").withTag("intfc", face); MixinMetric mixin = registry.mixinMetric(id); for (int i = 0; i < entry.getValue().length; i++) { final int index = i; mixin.gauge(FIELDS[index], new Gauge<Long>() { @Override public Long value() { loadIfNessesary(); return statByFace.get(face)[index]; } }); } } }
Example #11
Source File: Executors.java From sofa-lookout with Apache License 2.0 | 6 votes |
public static ThreadPoolExecutor newFixedThreadPoolExecutor(int size, int queueSize, String poolName, ThreadFactory tf, RejectedExecutionHandler rejectedExecutionHandler, Registry registry) { final ThreadPoolExecutor executor = new ThreadPoolExecutor(size, size, 0, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(queueSize), tf, rejectedExecutionHandler); // add metrics for thread pools Id id = registry.createId(METRIC_NAME) .withTag("priority", PRIORITY.HIGH.name()) .withTag("name", poolName); MixinMetric mixinMetric = registry.mixinMetric(id); watch(executor, mixinMetric); return executor; }
Example #12
Source File: Executors.java From sofa-lookout with Apache License 2.0 | 6 votes |
/** * 线程池 - 具有metrics统计* * * @param coreSize * @param maxSize * @param keepAliveMills * @param poolName * @param workQueue * @param registry * @return */ public static ThreadPoolExecutor newThreadPoolExecutor(int coreSize, int maxSize, long keepAliveMills, String poolName, RejectedExecutionHandler rejectedExecutionHandler, BlockingQueue<Runnable> workQueue, Registry registry) { Preconditions.checkNotNull(poolName, "No thread pool name!"); final ThreadPoolExecutor executor = new ThreadPoolExecutor(coreSize, maxSize, keepAliveMills <= 0 ? 0 : keepAliveMills, TimeUnit.MILLISECONDS, workQueue, getNamedThreadFactory(poolName), rejectedExecutionHandler); //add metrics for thread pools Id id = registry.createId(METRIC_NAME).withTag("priority", PRIORITY.HIGH.name()) .withTag("name", poolName); MixinMetric mixinMetric = registry.mixinMetric(id); watch(executor, mixinMetric); return executor; }
Example #13
Source File: RpcLookout.java From sofa-rpc with Apache License 2.0 | 6 votes |
/** * Record the number of calls and time consuming. * * @param mixinMetric MixinMetric * @param model information model */ private void recordCounterAndTimer(MixinMetric mixinMetric, RpcAbstractLookoutModel model) { Counter totalCounter = mixinMetric.counter("total_count"); Timer totalTimer = mixinMetric.timer("total_time"); Long elapsedTime = model.getElapsedTime(); totalCounter.inc(); if (elapsedTime != null) { totalTimer.record(elapsedTime, TimeUnit.MILLISECONDS); } if (!model.getSuccess()) { Counter failCounter = mixinMetric.counter("fail_count"); Timer failTimer = mixinMetric.timer("fail_time"); failCounter.inc(); if (elapsedTime != null) { failTimer.record(elapsedTime, TimeUnit.MILLISECONDS); } } }
Example #14
Source File: RpcLookout.java From sofa-rpc with Apache License 2.0 | 6 votes |
/** * Record request size and response size * * @param mixinMetric MixinMetric * @param model information model */ private void recordSize(MixinMetric mixinMetric, RpcClientLookoutModel model) { Long requestSize = model.getRequestSize(); Long responseSize = model.getResponseSize(); if (requestSize != null) { DistributionSummary requestSizeDS = mixinMetric.distributionSummary("request_size"); requestSizeDS.record(model.getRequestSize()); } if (responseSize != null) { DistributionSummary responseSizeDS = mixinMetric.distributionSummary("response_size"); responseSizeDS.record(model.getResponseSize()); } }
Example #15
Source File: AbstractWebfluxImporter.java From sofa-lookout with Apache License 2.0 | 5 votes |
@PostConstruct public void init() { Map<String, String> tags = new HashMap<>(); tags.put("importer", name); tags.put("type", "metric"); Id id = registry.createId("importer.stats", tags); MixinMetric mm = registry.mixinMetric(id); counter = mm.counter("count"); size = mm.distributionSummary("size"); }
Example #16
Source File: JvmMemoryMetricsImporter.java From sofa-lookout with Apache License 2.0 | 5 votes |
private void codeCacheImport(MixinMetric mixin) { final MemoryPoolMXBean codeCacheMXBean = getCodeCacheMXBean(); if (codeCacheMXBean == null) { LOGGER.info("can't get code cache MemoryPoolMXBean, won't report code cache usage."); return; } mixin.gauge("codecache.init", new Gauge<Long>() { @Override public Long value() { return codeCacheMXBean.getUsage().getInit(); } }); mixin.gauge("codecache.used", new Gauge<Long>() { @Override public Long value() { return codeCacheMXBean.getUsage().getUsed(); } }); mixin.gauge("codecache.committed", new Gauge<Long>() { @Override public Long value() { return codeCacheMXBean.getUsage().getCommitted(); } }); mixin.gauge("codecache.max", new Gauge<Long>() { @Override public Long value() { return codeCacheMXBean.getUsage().getMax(); } }); }
Example #17
Source File: Executors.java From sofa-lookout with Apache License 2.0 | 5 votes |
private static MixinMetric watch(ThreadPoolExecutor executor, MixinMetric mixinMetric) { mixinMetric.gauge("active.count", executor::getActiveCount); mixinMetric.gauge("queue.size", () -> executor.getQueue().size()); mixinMetric.gauge("pool.size", executor::getPoolSize); mixinMetric.gauge("max.pool.size", executor::getMaximumPoolSize); mixinMetric.gauge("largest.pool.size", executor::getLargestPoolSize); return mixinMetric; }
Example #18
Source File: JvmInfoMetricsImporterTest.java From sofa-lookout with Apache License 2.0 | 5 votes |
@Test public void testMemInfo() { Registry registry = new DefaultRegistry(); JvmMemoryMetricsImporter jvmMemoryMetricsImporter = new JvmMemoryMetricsImporter(); jvmMemoryMetricsImporter.register(registry); Id id = registry.createId("jvm.memory"); MixinMetric mixin = registry.mixinMetric(id); Gauge gauge = mixin.gauge("nonheap.init", null); Assert.assertTrue(gauge.value().longValue() >= 0); gauge = mixin.gauge("nonheap.used", null); Assert.assertTrue(gauge.value().longValue() >= 0); gauge = mixin.gauge("nonheap.committed", null); Assert.assertTrue(gauge.value().longValue() >= 0); gauge = mixin.gauge("nonheap.max", null); System.out.println(gauge.value().longValue()); Assert.assertTrue(gauge.value().longValue() >= -1); gauge = mixin.gauge("heap.init", null); Assert.assertTrue(gauge.value().longValue() >= 0); gauge = mixin.gauge("heap.used", null); Assert.assertTrue(gauge.value().longValue() >= 0); gauge = mixin.gauge("heap.committed", null); Assert.assertTrue(gauge.value().longValue() >= 0); gauge = mixin.gauge("heap.max", null); Assert.assertTrue(gauge.value().longValue() >= -1); gauge = mixin.gauge("codecache.init", null); Assert.assertTrue(gauge.value().longValue() >= 0); gauge = mixin.gauge("codecache.used", null); Assert.assertTrue(gauge.value().longValue() >= 0); gauge = mixin.gauge("codecache.committed", null); Assert.assertTrue(gauge.value().longValue() >= 0); gauge = mixin.gauge("codecache.max", null); Assert.assertTrue(gauge.value().longValue() >= -1); }
Example #19
Source File: RpcLookout.java From sofa-rpc with Apache License 2.0 | 5 votes |
/** * Collect the RPC client information. * * @param rpcClientMetricsModel client information model */ public void collectClient(RpcClientLookoutModel rpcClientMetricsModel) { try { Id methodConsumerId = createMethodConsumerId(rpcClientMetricsModel); MixinMetric methodConsumerMetric = Lookout.registry().mixinMetric(methodConsumerId); recordCounterAndTimer(methodConsumerMetric, rpcClientMetricsModel); recordSize(methodConsumerMetric, rpcClientMetricsModel); } catch (Throwable t) { LOGGER.error(LogCodes.getLog(LogCodes.ERROR_METRIC_REPORT_ERROR), t); } }
Example #20
Source File: BasicMetricsImporter.java From sofa-lookout with Apache License 2.0 | 5 votes |
@Override public void register(Registry registry) { MixinMetric mixin = registry.mixinMetric(registry.createId("instance")); mixin.gauge("mem.total", new Gauge<Long>() { @Override public Long value() { return Runtime.getRuntime().totalMemory(); } }); mixin.gauge("mem.free", new Gauge<Long>() { @Override public Long value() { return Runtime.getRuntime().freeMemory(); } }); mixin.gauge("processors", new Gauge<Integer>() { @Override public Integer value() { return Integer.valueOf(Runtime.getRuntime().availableProcessors()); } }); mixin.gauge("uptime", new Gauge<Long>() { @Override public Long value() { return Long.valueOf(System.currentTimeMillis() - timestamp); } }); mixin.gauge("systemload.average", new Gauge<Double>() { @Override public Double value() { return Double.valueOf(ManagementFactory.getOperatingSystemMXBean() .getSystemLoadAverage()); } }); }
Example #21
Source File: FileSystemSpaceMetricsImporter.java From sofa-lookout with Apache License 2.0 | 5 votes |
@Override public void register(Registry registry) { Id basicId = registry.createId("instance.file.system"); File[] roots = File.listRoots(); // For each filesystem root; //TODO dynamic File.listRoots() and for each; for (final File root : roots) { Id id = basicId.withTag("root", root.getAbsolutePath()).withTag( LookoutConstants.LOW_PRIORITY_TAG); MixinMetric mixin = registry.mixinMetric(id); mixin.gauge("total.space", new Gauge<Long>() { @Override public Long value() { return root.getTotalSpace(); } }); mixin.gauge("free.space", new Gauge<Long>() { @Override public Long value() { return root.getFreeSpace(); } }); mixin.gauge("usabe.space", new Gauge<Long>() { @Override public Long value() { return root.getUsableSpace(); } }); } }
Example #22
Source File: RpcLookout.java From sofa-rpc with Apache License 2.0 | 5 votes |
/** * Collect the RPC server information. * * @param rpcServerMetricsModel server information model */ public void collectServer(RpcServerLookoutModel rpcServerMetricsModel) { try { Id methodProviderId = createMethodProviderId(rpcServerMetricsModel); MixinMetric methodProviderMetric = Lookout.registry().mixinMetric(methodProviderId); recordCounterAndTimer(methodProviderMetric, rpcServerMetricsModel); } catch (Throwable t) { LOGGER.error(LogCodes.getLog(LogCodes.ERROR_METRIC_REPORT_ERROR), t); } }
Example #23
Source File: JvmMemoryMetricsImporter.java From sofa-lookout with Apache License 2.0 | 5 votes |
private void nonheapImport(MixinMetric mixin) { mixin.gauge("nonheap.init", new Gauge<Long>() { @Override public Long value() { return ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage().getInit(); } }); mixin.gauge("nonheap.used", new Gauge<Long>() { @Override public Long value() { return ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage().getUsed(); } }); mixin.gauge("nonheap.committed", new Gauge<Long>() { @Override public Long value() { return ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage().getCommitted(); } }); mixin.gauge("nonheap.max", new Gauge<Long>() { @Override public Long value() { return ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage().getMax(); } }); }
Example #24
Source File: LookoutMeasurement.java From sofa-lookout with Apache License 2.0 | 5 votes |
/** * @param metric 带解析的metric对象 * @param commonTagsAccessor 方便添加common tags,可以为null * @return */ public static LookoutMeasurement from(Metric metric, CommonTagsAccessor commonTagsAccessor) { Indicator indicator = metric.measure(); Id id = metric.id(); LookoutMeasurement measurement = new LookoutMeasurement(new Date(indicator.getTimestamp()), id); for (Object mObj : indicator.measurements()) { Measurement m = (Measurement) mObj; Assert.notNull(m.name(), String.format("empty measure name,metric: %s!", metric.id())); //printValue for info metric measurement.put(m.name(), MeasurementUtil.printValue(m.value())); } for (Tag tag : id.tags()) { measurement.addTag(tag.key(), tag.value()); } //add reserved tag if (metric instanceof Info) { measurement.addTag("_type_", "i"); } else if (metric instanceof Counter) { measurement.addTag("_type_", "c"); } else if (metric instanceof Timer) { measurement.addTag("_type_", "t"); } else if (metric instanceof Gauge) { measurement.addTag("_type_", "g"); } else if (metric instanceof DistributionSummary) { measurement.addTag("_type_", "d"); } else if (metric instanceof MixinMetric) { measurement.addTag("_type_", "m"); } // add common tags,If already assigned then ignore if (commonTagsAccessor != null) { Map<String, String> commonTags = (commonTagsAccessor).commonTags(); for (Map.Entry<String, String> tagEntry : commonTags.entrySet()) { if (!measurement.containsTag(tagEntry.getKey())) { measurement.addTag(tagEntry.getKey(), tagEntry.getValue()); } } } return measurement; }
Example #25
Source File: LookoutStarterTest.java From sofa-lookout with Apache License 2.0 | 5 votes |
@Test public void testDropwizardMetrics() { Id id = registry.createId("test_status").withTag("k1", "v1"); MixinMetric mixinMetric = registry.mixinMetric(id); mixinMetric.distributionSummary("dstest").record(100); mixinMetric.counter("counttest").inc(); mixinMetric.timer("timetest").record(2, TimeUnit.SECONDS); mixinMetric.gauge("guagetest", new Gauge<Integer>() { @Override public Integer value() { return 1; } }); Assert.assertTrue(registry instanceof CompositeRegistry); CompositeRegistry compositeRegistry = (CompositeRegistry) registry; DropWizardMetricsRegistry dwr = null; for (Registry r : compositeRegistry.getRegistries()) { if (r instanceof DropWizardMetricsRegistry) { dwr = (DropWizardMetricsRegistry) r; break; } } MixinMetric mixinMetric2 = dwr.mixinMetric(id); Assert.assertEquals(1, mixinMetric2.counter("counttest").count()); Assert.assertEquals(1, mixinMetric2.timer("timetest").count()); Assert.assertEquals(1, mixinMetric2.distributionSummary("dstest").count()); }
Example #26
Source File: SystemLoadMetricsImporter.java From sofa-lookout with Apache License 2.0 | 5 votes |
@Override protected void doRegister(Registry registry) { Id id = registry.createId("os.systemload.average"); MixinMetric mixin = registry.mixinMetric(id); mixin.gauge("1min", new Gauge<Float>() { @Override public Float value() { loadIfNessesary(); return loadAvg[LoadAvg.ONE_MIN.ordinal()]; } }); mixin.gauge("5min", new Gauge<Float>() { @Override public Float value() { loadIfNessesary(); return loadAvg[LoadAvg.FIVE_MIN.ordinal()]; } }); mixin.gauge("15min", new Gauge<Float>() { @Override public Float value() { loadIfNessesary(); return loadAvg[LoadAvg.FIFTEEN_MIN.ordinal()]; } }); }
Example #27
Source File: MemoryStatsMetricsImporter.java From sofa-lookout with Apache License 2.0 | 5 votes |
@Override protected void doRegister(Registry registry) { Id id = registry.createId("os.memory.stats"); MixinMetric mixin = registry.mixinMetric(id); mixin.gauge("total.bytes", new Gauge<Long>() { @Override public Long value() { loadIfNessesary(); return memstats.memTotal; } }); mixin.gauge("free.bytes", new Gauge<Long>() { @Override public Long value() { loadIfNessesary(); return memstats.memFree; } }); mixin.gauge("buffers.bytes", new Gauge<Long>() { @Override public Long value() { loadIfNessesary(); return memstats.buffers; } }); mixin.gauge("cached.bytes", new Gauge<Long>() { @Override public Long value() { loadIfNessesary(); return memstats.cached; } }); }
Example #28
Source File: NoopRegistryTest.java From sofa-lookout with Apache License 2.0 | 5 votes |
@Test public void testNoopMixinMetric() { MixinMetric mixinMetric = r.mixinMetric(r.createId("name")); Assert.assertEquals(NoopMixinMetric.INSTANCE, mixinMetric); Assert.assertEquals(NoopCounter.INSTANCE, mixinMetric.counter("c")); Assert.assertEquals(NoopTimer.INSTANCE, mixinMetric.timer("t")); Assert.assertEquals(NoopDistributionSummary.INSTANCE, mixinMetric.distributionSummary("t")); Assert.assertEquals(null, mixinMetric.gauge("t", new Gauge<Number>() { @Override public Number value() { return 1; } })); }
Example #29
Source File: JvmThreadsMetricsImporter.java From sofa-lookout with Apache License 2.0 | 5 votes |
@Override public void register(Registry registry) { Id id = registry.createId("jvm.threads"); MixinMetric mixin = registry.mixinMetric(id); mixin.gauge("peak", new Gauge<Integer>() { @Override public Integer value() { return ManagementFactory.getThreadMXBean().getPeakThreadCount(); } }); mixin.gauge("daemon", new Gauge<Integer>() { @Override public Integer value() { return ManagementFactory.getThreadMXBean().getDaemonThreadCount(); } }); mixin.gauge("totalStarted", new Gauge<Long>() { @Override public Long value() { return ManagementFactory.getThreadMXBean().getTotalStartedThreadCount(); } }); mixin.gauge("active", new Gauge<Integer>() { @Override public Integer value() { return ManagementFactory.getThreadMXBean().getThreadCount(); } }); }
Example #30
Source File: JvmMemoryMetricsImporter.java From sofa-lookout with Apache License 2.0 | 5 votes |
@Override public void register(Registry registry) { Id id = registry.createId("jvm.memory"); MixinMetric mixin = registry.mixinMetric(id); heapImport(mixin); nonheapImport(mixin); codeCacheImport(mixin); }