/** * Create a mutable metric with stats * @param name of the metric * @param desc metric description * @param sampleName of the metric (e.g., "Ops") * @param valueName of the metric (e.g., "Time" or "Latency") * @return a new mutable metric object */ public MutableStat newStat(String name, String desc, String sampleName, String valueName) { return newStat(name, desc, sampleName, valueName, false); }
return registry.newStat(info.name(), info.description(), annotation.sampleName(), annotation.valueName(), annotation.always());
Metrics2TabletServerScanMetrics(MetricsSystem system) { this.system = system; this.registry = new MetricsRegistry(Interns.info(NAME, DESCRIPTION)); this.registry.tag(MsInfo.ProcessName, MetricsSystemHelper.getProcessName()); scans = registry.newStat(SCAN, "Scans", "Ops", "Count", true); resultsPerScan = registry.newStat(RESULT_SIZE, "Results per scan", "Ops", "Count", true); yields = registry.newStat(YIELD, "Yields", "Ops", "Count", true); }
Metrics2TabletServerMinCMetrics(MetricsSystem system) { this.system = system; this.registry = new MetricsRegistry(Interns.info(NAME, DESCRIPTION)); this.registry.tag(MsInfo.ProcessName, MetricsSystemHelper.getProcessName()); activeMinc = registry.newStat(MINC, "Minor compactions", "Ops", "Count", true); queuedMinc = registry.newStat(QUEUE, "Queued minor compactions", "Ops", "Count", true); }
Metrics2TabletServerUpdateMetrics(MetricsSystem system) { this.system = system; this.registry = new MetricsRegistry(Interns.info(NAME, DESCRIPTION)); this.registry.tag(MsInfo.ProcessName, MetricsSystemHelper.getProcessName()); permissionErrorsCounter = registry .newCounter(Interns.info(PERMISSION_ERRORS, "Permission Errors"), 0L); unknownTabletErrorsCounter = registry .newCounter(Interns.info(UNKNOWN_TABLET_ERRORS, "Unknown Tablet Errors"), 0L); constraintViolationsCounter = registry .newCounter(Interns.info(CONSTRAINT_VIOLATIONS, "Table Constraint Violations"), 0L); commitPrepStat = registry.newStat(COMMIT_PREP, "preparing to commit mutations", "Ops", "Time", true); walogWriteTimeStat = registry.newStat(WALOG_WRITE_TIME, "writing mutations to WAL", "Ops", "Time", true); commitTimeStat = registry.newStat(COMMIT_TIME, "committing mutations", "Ops", "Time", true); mutationArraySizeStat = registry.newStat(MUTATION_ARRAY_SIZE, "mutation array", "ops", "Size", true); }
Metrics2ReplicationMetrics(Master master, MetricsSystem system) { this.master = master; this.system = system; pathModTimes = new HashMap<>(); this.registry = new MetricsRegistry(Interns.info(NAME, DESCRIPTION)); this.registry.tag(MsInfo.ProcessName, MetricsSystemHelper.getProcessName()); replicationUtil = new ReplicationUtil(master.getContext()); replicationQueueTimeQuantiles = registry.newQuantiles(REPLICATION_QUEUE_TIME_QUANTILES, "Replication queue time quantiles in milliseconds", "ops", "latency", 600); replicationQueueTimeStat = registry.newStat(REPLICATION_QUEUE_TIME, "Replication queue time statistics in milliseconds", "ops", "latency", true); }
/** * Create a mutable metric with stats * @param name of the metric * @param desc metric description * @param sampleName of the metric (e.g., "Ops") * @param valueName of the metric (e.g., "Time" or "Latency") * @return a new mutable metric object */ public MutableStat newStat(String name, String desc, String sampleName, String valueName) { return newStat(name, desc, sampleName, valueName, false); }
/** * Create a mutable metric with stats * @param name of the metric * @param desc metric description * @param sampleName of the metric (e.g., "Ops") * @param valueName of the metric (e.g., "Time" or "Latency") * @return a new mutable metric object */ public MutableStat newStat(String name, String desc, String sampleName, String valueName) { return newStat(name, desc, sampleName, valueName, false); }
/** * Create a mutable metric with stats * @param name of the metric * @param desc metric description * @param sampleName of the metric (e.g., "Ops") * @param valueName of the metric (e.g., "Time" or "Latency") * @return a new mutable metric object */ public MutableStat newStat(String name, String desc, String sampleName, String valueName) { return newStat(name, desc, sampleName, valueName, false); }
/** * Create a mutable metric with stats * @param name of the metric * @param desc metric description * @param sampleName of the metric (e.g., "Ops") * @param valueName of the metric (e.g., "Time" or "Latency") * @return a new mutable metric object */ public MutableStat newStat(String name, String desc, String sampleName, String valueName) { return newStat(name, desc, sampleName, valueName, false); }
Metrics2TabletServerScanMetrics(MetricsSystem system) { this.system = system; this.registry = new MetricsRegistry(Interns.info(NAME, DESCRIPTION)); this.registry.tag(MsInfo.ProcessName, MetricsSystemHelper.getProcessName()); scans = registry.newStat(SCAN, "Scans", "Ops", "Count", true); resultsPerScan = registry.newStat(RESULT_SIZE, "Results per scan", "Ops", "Count", true); yields = registry.newStat(YIELD, "Yields", "Ops", "Count", true); }
Metrics2TabletServerMinCMetrics(MetricsSystem system) { this.system = system; this.registry = new MetricsRegistry(Interns.info(NAME, DESCRIPTION)); this.registry.tag(MsInfo.ProcessName, MetricsSystemHelper.getProcessName()); activeMinc = registry.newStat(MINC, "Minor compactions", "Ops", "Count", true); queuedMinc = registry.newStat(QUEUE, "Queued minor compactions", "Ops", "Count", true); }
Metrics2TabletServerUpdateMetrics(MetricsSystem system) { this.system = system; this.registry = new MetricsRegistry(Interns.info(NAME, DESCRIPTION)); this.registry.tag(MsInfo.ProcessName, MetricsSystemHelper.getProcessName()); permissionErrorsCounter = registry .newCounter(Interns.info(PERMISSION_ERRORS, "Permission Errors"), 0l); unknownTabletErrorsCounter = registry .newCounter(Interns.info(UNKNOWN_TABLET_ERRORS, "Unknown Tablet Errors"), 0l); constraintViolationsCounter = registry .newCounter(Interns.info(CONSTRAINT_VIOLATIONS, "Table Constraint Violations"), 0l); commitPrepStat = registry.newStat(COMMIT_PREP, "preparing to commit mutations", "Ops", "Time", true); walogWriteTimeStat = registry.newStat(WALOG_WRITE_TIME, "writing mutations to WAL", "Ops", "Time", true); commitTimeStat = registry.newStat(COMMIT_TIME, "committing mutations", "Ops", "Time", true); mutationArraySizeStat = registry.newStat(MUTATION_ARRAY_SIZE, "mutation array", "ops", "Size", true); }
ContainerMetrics( MetricsSystem ms, ContainerId containerId, long flushPeriodMs, long delayMs) { this.recordInfo = info(sourceName(containerId), RECORD_INFO.description()); this.registry = new MetricsRegistry(recordInfo); this.metricsSystem = ms; this.containerId = containerId; this.flushPeriodMs = flushPeriodMs; this.unregisterDelayMs = delayMs < 0 ? 0 : delayMs; scheduleTimerTaskIfRequired(); this.pMemMBsStat = registry.newStat( PMEM_USAGE_METRIC_NAME, "Physical memory stats", "Usage", "MBs", true); this.cpuCoreUsagePercent = registry.newStat( PHY_CPU_USAGE_METRIC_NAME, "Physical Cpu core percent usage stats", "Usage", "Percents", true); this.milliVcoresUsed = registry.newStat( VCORE_USAGE_METRIC_NAME, "1000 times Vcore usage", "Usage", "MilliVcores", true); this.pMemLimitMbs = registry.newGauge( PMEM_LIMIT_METRIC_NAME, "Physical memory limit in MBs", 0); this.vMemLimitMbs = registry.newGauge( VMEM_LIMIT_METRIC_NAME, "Virtual memory limit in MBs", 0); this.cpuVcoreLimit = registry.newGauge( VCORE_LIMIT_METRIC_NAME, "CPU limit in number of vcores", 0); }
ContainerMetrics( MetricsSystem ms, ContainerId containerId, long flushPeriodMs, long delayMs) { this.recordInfo = info(sourceName(containerId), RECORD_INFO.description()); this.registry = new MetricsRegistry(recordInfo); this.metricsSystem = ms; this.containerId = containerId; this.flushPeriodMs = flushPeriodMs; this.unregisterDelayMs = delayMs < 0 ? 0 : delayMs; scheduleTimerTaskIfRequired(); this.pMemMBsStat = registry.newStat( PMEM_USAGE_METRIC_NAME, "Physical memory stats", "Usage", "MBs", true); this.cpuCoreUsagePercent = registry.newStat( PHY_CPU_USAGE_METRIC_NAME, "Physical Cpu core percent usage stats", "Usage", "Percents", true); this.milliVcoresUsed = registry.newStat( VCORE_USAGE_METRIC_NAME, "1000 times Vcore usage", "Usage", "MilliVcores", true); this.pMemLimitMbs = registry.newGauge( PMEM_LIMIT_METRIC_NAME, "Physical memory limit in MBs", 0); this.vMemLimitMbs = registry.newGauge( VMEM_LIMIT_METRIC_NAME, "Virtual memory limit in MBs", 0); this.cpuVcoreLimit = registry.newGauge( VCORE_LIMIT_METRIC_NAME, "CPU limit in number of vcores", 0); }
Metrics2ReplicationMetrics(Master master, MetricsSystem system) { this.master = master; this.system = system; pathModTimes = new HashMap<>(); this.registry = new MetricsRegistry(Interns.info(NAME, DESCRIPTION)); this.registry.tag(MsInfo.ProcessName, MetricsSystemHelper.getProcessName()); replicationUtil = new ReplicationUtil(master); replicationQueueTimeQuantiles = registry.newQuantiles(REPLICATION_QUEUE_TIME_QUANTILES, "Replication queue time quantiles in milliseconds", "ops", "latency", 600); replicationQueueTimeStat = registry.newStat(REPLICATION_QUEUE_TIME, "Replication queue time statistics in milliseconds", "ops", "latency", true); }
scheduleTimerTaskIfRequired(); this.pMemMBsStat = registry.newStat( PMEM_USAGE_METRIC_NAME, "Physical memory stats", "Usage", "MBs", true); this.cpuCoreUsagePercent = registry.newStat( PHY_CPU_USAGE_METRIC_NAME, "Physical Cpu core percent usage stats", "Usage", "Percents", true); this.milliVcoresUsed = registry.newStat( VCORE_USAGE_METRIC_NAME, "1000 times Vcore usage", "Usage", "MilliVcores", true);
/** * Tests that when using {@link MutableStat#add(long, long)}, even with a high * sample count, the mean does not lose accuracy. */ @Test public void testMutableStatWithBulkAdd() { MetricsRecordBuilder rb = mockMetricsRecordBuilder(); MetricsRegistry registry = new MetricsRegistry("test"); MutableStat stat = registry.newStat("Test", "Test", "Ops", "Val", false); stat.add(1000, 1000); stat.add(1000, 2000); registry.snapshot(rb, false); assertCounter("TestNumOps", 2000L, rb); assertGauge("TestAvgVal", 1.5, rb); }
/** * Test various factory methods */ @Test public void testNewMetrics() { final MetricsRegistry r = new MetricsRegistry("test"); r.newCounter("c1", "c1 desc", 1); r.newCounter("c2", "c2 desc", 2L); r.newGauge("g1", "g1 desc", 3); r.newGauge("g2", "g2 desc", 4L); r.newStat("s1", "s1 desc", "ops", "time"); assertEquals("num metrics in registry", 5, r.metrics().size()); assertTrue("c1 found", r.get("c1") instanceof MutableCounterInt); assertTrue("c2 found", r.get("c2") instanceof MutableCounterLong); assertTrue("g1 found", r.get("g1") instanceof MutableGaugeInt); assertTrue("g2 found", r.get("g2") instanceof MutableGaugeLong); assertTrue("s1 found", r.get("s1") instanceof MutableStat); expectMetricsException("Metric name c1 already exists", new Runnable() { @Override public void run() { r.newCounter("c1", "test dup", 0); } }); }
/** * Test various factory methods */ @Test public void testNewMetrics() { final MetricsRegistry r = new MetricsRegistry("test"); r.newCounter("c1", "c1 desc", 1); r.newCounter("c2", "c2 desc", 2L); r.newGauge("g1", "g1 desc", 3); r.newGauge("g2", "g2 desc", 4L); r.newStat("s1", "s1 desc", "ops", "time"); assertEquals("num metrics in registry", 5, r.metrics().size()); assertTrue("c1 found", r.get("c1") instanceof MutableCounterInt); assertTrue("c2 found", r.get("c2") instanceof MutableCounterLong); assertTrue("g1 found", r.get("g1") instanceof MutableGaugeInt); assertTrue("g2 found", r.get("g2") instanceof MutableGaugeLong); assertTrue("s1 found", r.get("s1") instanceof MutableStat); expectMetricsException("Metric name c1 already exists", new Runnable() { @Override public void run() { r.newCounter("c1", "test dup", 0); } }); }