@Override public void snapshot(MetricsRecordBuilder rb, boolean all) { try { Object ret = method.invoke(obj, (Object[]) null); rb.tag(info, (String) ret); } catch (Exception ex) { LOG.error("Error invoking method "+ method.getName(), ex); } } };
@Override public void getMetrics(MetricsCollector collector, boolean b) { MetricsRecordBuilder rb = collector.addRecord(SchedulerMetrics) .setContext("scheduler") .tag(ProcessName, "DAGAppMaster") .tag(SessionId, sessionId); if (dagId != null) { rb.tag(MsInfo.Context, dagId); } getTaskSchedulerStats(rb); }
@Override public void getMetrics(MetricsCollector collector, boolean all) { // We could also have one metricssource for all the pools and add all the pools to the collector // in its getMetrics call (as separate records). Not clear if that's supported. // Also, we'd have to initialize the metrics ourselves instead of using @Metric annotation. MetricsRecordBuilder rb = collector.addRecord("WmPoolMetrics." + poolName) .setContext("HS2").tag(MsInfo.SessionId, poolName); if (allMetrics == null) { initAfterRegister(); // This happens if register calls getMetrics. } for (MutableMetric metric : allMetrics.values()) { metric.snapshot(rb, all); } }
@Override public void getMetrics(MetricsCollector metricsCollector, boolean all) { MetricsRecordBuilder record = metricsCollector.addRecord(metricsRegistry.info()); if (wrapper != null) { // Summarize the tables Map<String,Entry<Long,Long>> tableUsages = wrapper.getTableSpaceUtilization(); String tableSummary = "[]"; if (tableUsages != null && !tableUsages.isEmpty()) { tableSummary = generateJsonQuotaSummary(tableUsages.entrySet(), "table"); } record.tag(Interns.info(TABLE_QUOTA_USAGE_NAME, TABLE_QUOTA_USAGE_DESC), tableSummary); // Summarize the namespaces String nsSummary = "[]"; Map<String,Entry<Long,Long>> namespaceUsages = wrapper.getNamespaceSpaceUtilization(); if (namespaceUsages != null && !namespaceUsages.isEmpty()) { nsSummary = generateJsonQuotaSummary(namespaceUsages.entrySet(), "namespace"); } record.tag(Interns.info(NS_QUOTA_USAGE_NAME, NS_QUOTA_USAGE_DESC), nsSummary); } metricsRegistry.snapshot(record, all); }
.addGauge(Interns.info(OFFLINE_REGION_COUNT_NAME, OFFLINE_REGION_COUNT_DESC), regionNumberPair.getSecond()) .tag(Interns.info(LIVE_REGION_SERVERS_NAME, LIVE_REGION_SERVERS_DESC), masterWrapper.getRegionServers()) .addGauge(Interns.info(NUM_REGION_SERVERS_NAME, NUMBER_OF_REGION_SERVERS_DESC), masterWrapper.getNumRegionServers()) .tag(Interns.info(DEAD_REGION_SERVERS_NAME, DEAD_REGION_SERVERS_DESC), masterWrapper.getDeadRegionServers()) .addGauge(Interns.info(NUM_DEAD_REGION_SERVERS_NAME, NUMBER_OF_DEAD_REGION_SERVERS_DESC), masterWrapper.getNumDeadRegionServers()) .tag(Interns.info(ZOOKEEPER_QUORUM_NAME, ZOOKEEPER_QUORUM_DESC), masterWrapper.getZookeeperQuorum()) .tag(Interns.info(SERVER_NAME_NAME, SERVER_NAME_DESC), masterWrapper.getServerName()) .tag(Interns.info(CLUSTER_ID_NAME, CLUSTER_ID_DESC), masterWrapper.getClusterId()) .tag(Interns.info(IS_ACTIVE_MASTER_NAME, IS_ACTIVE_MASTER_DESC), String.valueOf(masterWrapper.getIsActiveMaster()));
private void snapshotAllMetrics(MetricRegistry metricRegistry, MetricsCollector collector) { MetricRegistryInfo hbaseMetricRegistryInfo = metricRegistry.getMetricRegistryInfo(); MetricsInfo hadoopMetricsInfo = Interns.info(hbaseMetricRegistryInfo.getMetricsName(), hbaseMetricRegistryInfo.getMetricsDescription()); MetricsRecordBuilder builder = collector.addRecord(hadoopMetricsInfo); builder.setContext(hbaseMetricRegistryInfo.getMetricsContext()); builder.tag(hadoopMetricsInfo, metricTag); this.snapshotAllMetrics(metricRegistry, builder); }
.addCounter(Interns.info(BLOCKED_REQUESTS_COUNT, BLOCKED_REQUESTS_COUNT_DESC), rsWrap.getBlockedRequestsCount()) .tag(Interns.info(ZOOKEEPER_QUORUM_NAME, ZOOKEEPER_QUORUM_DESC), rsWrap.getZookeeperQuorum()) .tag(Interns.info(SERVER_NAME_NAME, SERVER_NAME_DESC), rsWrap.getServerName()) .tag(Interns.info(CLUSTER_ID_NAME, CLUSTER_ID_DESC), rsWrap.getClusterId());
@Override public void snapshot(MetricsRecordBuilder rb, boolean all) { try { Object ret = method.invoke(obj, (Object[]) null); rb.tag(info, (String) ret); } catch (Exception ex) { LOG.error("Error invoking method "+ method.getName(), ex); } } };
@Override public void snapshot(MetricsRecordBuilder rb, boolean all) { try { Object ret = method.invoke(obj, (Object[]) null); rb.tag(info, (String) ret); } catch (Exception ex) { LOG.error("Error invoking method "+ method.getName(), ex); } } };
public static String getStringMetric(String name, MetricsRecordBuilder rb) { ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class); verify(rb, atLeast(0)).tag(eqName(info(name, "")), captor.capture()); checkCaptured(captor, name); return captor.getValue(); }