@Test public void getMetricNameTest() { assertEquals("Cluster.counter", MetricsSystem.getMetricName("Cluster.counter")); assertEquals("Master.timer", MetricsSystem.getMetricName("Master.timer")); String workerGaugeName = "Worker.gauge"; assertNotEquals(workerGaugeName, MetricsSystem.getMetricName(workerGaugeName)); assertTrue(MetricsSystem.getMetricName(workerGaugeName).startsWith(workerGaugeName)); String clientCounterName = "Client.counter"; assertNotEquals(clientCounterName, MetricsSystem.getMetricName(clientCounterName)); assertTrue(MetricsSystem.getMetricName(clientCounterName).startsWith(clientCounterName)); }
public static String getMetricName(String name) { if (name.startsWith(CLUSTER)) { return name; } switch (CommonUtils.PROCESS_TYPE.get()) { case CLIENT: return getClientMetricName(name); case MASTER: return getMasterMetricName(name); case PROXY: return getProxyMetricName(name); case WORKER: return getWorkerMetricName(name); case JOB_MASTER: return getJobMasterMetricName(name); case JOB_WORKER: return getJobWorkerMetricName(name); default: throw new IllegalStateException("Unknown process type"); } }
MetricsSystem { public static String getMetricName(String name) { if (name.startsWith(CLUSTER)) { return name; } switch (CommonUtils.PROCESS_TYPE.get()) { case CLIENT: return getClientMetricName(name); case MASTER: return getMasterMetricName(name); case PROXY: return getProxyMetricName(name); case WORKER: return getWorkerMetricName(name); case JOB_MASTER: return getJobMasterMetricName(name); case JOB_WORKER: return getJobWorkerMetricName(name); default: throw new IllegalStateException("Unknown process type"); } } }
MetricsSystem { public static String getMetricName(String name) { if (name.startsWith(CLUSTER)) { return name; } switch (CommonUtils.PROCESS_TYPE.get()) { case CLIENT: return getClientMetricName(name); case MASTER: return getMasterMetricName(name); case PROXY: return getProxyMetricName(name); case WORKER: return getWorkerMetricName(name); case JOB_MASTER: return getJobMasterMetricName(name); case JOB_WORKER: return getJobWorkerMetricName(name); default: throw new IllegalStateException("Unknown process type"); } } private  MetricsSystem(); }
MetricsSystem { public static String getMetricName(String name) { if (name.startsWith(CLUSTER)) { return name; } switch (CommonUtils.PROCESS_TYPE.get()) { case CLIENT: return getClientMetricName(name); case MASTER: return getMasterMetricName(name); case PROXY: return getProxyMetricName(name); case WORKER: return getWorkerMetricName(name); case JOB_MASTER: return getJobMasterMetricName(name); case JOB_WORKER: return getJobWorkerMetricName(name); default: throw new IllegalStateException("Unknown process type"); } } private  MetricsSystem(); static void startSinks(String metricsConfFile); static synchronized void startSinksFromConfig(MetricsConfig config); static synchronized void stopSinks(); static synchronized int getNumSinks(); static String getMetricName(String name); static String getMasterMetricName(String name); static String getJobWorkerMetricName(String name); static void checkMinimalPollingPeriod(TimeUnit pollUnit, int pollPeriod); static String stripInstanceAndHost(String metricsName); static String escape(AlluxioURI uri); static String unescape(String uri); static Counter counter(String name); static Counter counterWithTags(String name, boolean shouldReport, String... tags); static Meter meter(String name); static Meter meterWithTags(String name, boolean shouldReport, String... tags); static Timer timer(String name); static synchronized void registerGaugeIfAbsent(String name, Gauge<T> metric); static List<alluxio.grpc.Metric> reportWorkerMetrics(); static List<alluxio.grpc.Metric> reportClientMetrics(); static Map<String, Set<Metric>> getMasterMetrics(Set<String> metricNames); @Nullable static Metric getMetricValue(String fullName); static Map<String, MetricValue> allMetrics(); @VisibleForTesting static void initShouldReportMetrics(InstanceType instanceType); static synchronized void resetAllMetrics(); @VisibleForTesting static void clearAllMetrics(); @VisibleForTesting static void resetCountersAndGauges(); }
MetricsSystem { public static String getMetricName(String name) { if (name.startsWith(CLUSTER)) { return name; } switch (CommonUtils.PROCESS_TYPE.get()) { case CLIENT: return getClientMetricName(name); case MASTER: return getMasterMetricName(name); case PROXY: return getProxyMetricName(name); case WORKER: return getWorkerMetricName(name); case JOB_MASTER: return getJobMasterMetricName(name); case JOB_WORKER: return getJobWorkerMetricName(name); default: throw new IllegalStateException("Unknown process type"); } } private  MetricsSystem(); static void startSinks(String metricsConfFile); static synchronized void startSinksFromConfig(MetricsConfig config); static synchronized void stopSinks(); static synchronized int getNumSinks(); static String getMetricName(String name); static String getMasterMetricName(String name); static String getJobWorkerMetricName(String name); static void checkMinimalPollingPeriod(TimeUnit pollUnit, int pollPeriod); static String stripInstanceAndHost(String metricsName); static String escape(AlluxioURI uri); static String unescape(String uri); static Counter counter(String name); static Counter counterWithTags(String name, boolean shouldReport, String... tags); static Meter meter(String name); static Meter meterWithTags(String name, boolean shouldReport, String... tags); static Timer timer(String name); static synchronized void registerGaugeIfAbsent(String name, Gauge<T> metric); static List<alluxio.grpc.Metric> reportWorkerMetrics(); static List<alluxio.grpc.Metric> reportClientMetrics(); static Map<String, Set<Metric>> getMasterMetrics(Set<String> metricNames); @Nullable static Metric getMetricValue(String fullName); static Map<String, MetricValue> allMetrics(); @VisibleForTesting static void initShouldReportMetrics(InstanceType instanceType); static synchronized void resetAllMetrics(); @VisibleForTesting static void clearAllMetrics(); @VisibleForTesting static void resetCountersAndGauges(); static final String CLUSTER; static final MetricRegistry METRIC_REGISTRY; static final String SINK_REGEX; }