@Override public void getMetrics(MetricsCollector metricsCollector, boolean all) { MetricsRecordBuilder metricsRecordBuilder = metricsCollector.addRecord(metricsName); if (stochasticCosts != null) { synchronized (stochasticCosts) { for (Map.Entry<String, Map<String, Double>> tableEntry : stochasticCosts.entrySet()) { for (Map.Entry<String, Double> costEntry : tableEntry.getValue().entrySet()) { String attrName = tableEntry.getKey() + TABLE_FUNCTION_SEP + costEntry.getKey(); Double cost = costEntry.getValue(); String functionDesc = costFunctionDescs.get(costEntry.getKey()); if (functionDesc == null) { functionDesc = costEntry.getKey(); } metricsRecordBuilder.addGauge(Interns.info(attrName, functionDesc), cost); } } } } metricsRegistry.snapshot(metricsRecordBuilder, all); } }
@Override public void getMetrics(MetricsCollector metricsCollector, boolean all) { metricsRegistry.snapshot(metricsCollector.addRecord(metricsRegistry.info()), all); }
@Override public void getMetrics(MetricsCollector builder, boolean all) { registry.snapshot(builder.addRecord(registry.info()), all); } };
@Override public synchronized void getMetrics(MetricsCollector builder, boolean all) { MetricsRecordBuilder rb = builder.addRecord(MS_NAME) .addGauge(MsInfo.NumActiveSources, sources.size()) .addGauge(MsInfo.NumAllSources, allSources.size()) .addGauge(MsInfo.NumActiveSinks, sinks.size()) .addGauge(MsInfo.NumAllSinks, allSinks.size()); for (MetricsSinkAdapter sa : sinks.values()) { sa.snapshot(rb, all); } registry.snapshot(rb, all); }
@Override public void getMetrics(MetricsCollector collector, boolean all) { MetricsRecordBuilder builder = collector.addRecord(recordName); if (null != context) { builder.setContext(context); } // Synchronizing here ensures that the dropwizard metrics collection side is excluded from executing // at the same time we are pulling elements from the queues. synchronized (this) { snapshotAllMetrics(builder); } metrics2Registry.snapshot(builder, all); }
@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); } }
/** * Yes this is a get function that doesn't return anything. Thanks Hadoop for breaking all * expectations of java programmers. Instead of returning anything Hadoop metrics expects * getMetrics to push the metrics into the collector. * * @param collector the collector * @param all get all the metrics regardless of when they last changed. */ @Override public void getMetrics(MetricsCollector collector, boolean all) { MetricsRecordBuilder mrb = collector.addRecord(metricsName); if (tableSources != null) { for (MetricsTableSource tableMetricSource : tableSources.values()) { if (tableMetricSource instanceof MetricsTableSourceImpl) { ((MetricsTableSourceImpl) tableMetricSource).snapshot(mrb, all); } } mrb.addGauge(Interns.info(NUM_TABLES, NUMBER_OF_TABLES_DESC), tableSources.size()); metricsRegistry.snapshot(mrb, all); } } }
@Override public void getMetrics(MetricsCollector collector, boolean b) { MetricsRecordBuilder rb = collector.addRecord(CacheMetrics) .setContext("cache") .tag(ProcessName, MetricsUtils.METRICS_PROCESS_NAME) .tag(SessionId, sessionId); getCacheStats(rb); }
@Override public void getMetrics(MetricsCollector collector, boolean b) { MetricsRecordBuilder rb = collector.addRecord(ExecutorMetrics) .setContext("executors") .tag(ProcessName, MetricsUtils.METRICS_PROCESS_NAME) .tag(SessionId, sessionId); getExecutorStats(rb); }
@Override public void getMetrics(MetricsCollector collector, boolean all) { // Metrics2 interface to act as a Metric source try { MetricsRecordBuilder rb = collector.addRecord(getClass().getName()) .setContext(namespace); addDecayedCallVolume(rb); addUniqueIdentityCount(rb); addTopNCallerSummary(rb); addAvgResponseTimePerPriority(rb); addCallVolumePerPriority(rb); addRawCallVolume(rb); } catch (Exception e) { LOG.warn("Exception thrown while metric collection. Exception : " + e.getMessage()); } }
@Override public void getMetrics(MetricsCollector collector, boolean b) { MetricsRecordBuilder rb = collector.addRecord(IOMetrics) .setContext("io") .tag(ProcessName, MetricsUtils.METRICS_PROCESS_NAME) .tag(SessionId, sessionId); getIoStats(rb); }
/** * Yes this is a get function that doesn't return anything. Thanks Hadoop for breaking all * expectations of java programmers. Instead of returning anything Hadoop metrics expects * getMetrics to push the metrics into the collector. * * @param collector the collector * @param all get all the metrics regardless of when they last changed. */ @Override public void getMetrics(MetricsCollector collector, boolean all) { MetricsRecordBuilder mrb = collector.addRecord(metricsName); if (regionSources != null) { for (MetricsRegionSource regionMetricSource : regionSources) { if (regionMetricSource instanceof MetricsRegionSourceImpl) { ((MetricsRegionSourceImpl) regionMetricSource).snapshot(mrb, all); } } mrb.addGauge(Interns.info(NUM_REGIONS, NUMBER_OF_REGIONS_DESC), regionSources.size()); metricsRegistry.snapshot(mrb, all); } } }
@Override public void getMetrics(MetricsCollector metricsCollector, boolean all) { MetricsRecordBuilder metricsRecordBuilder = metricsCollector.addRecord(metricsName); // masterWrapper can be null because this function is called inside of init. if (masterWrapper != null) { metricsRecordBuilder .addGauge(Interns.info(NUM_MASTER_WALS_NAME, NUM_MASTER_WALS_DESC), masterWrapper.getNumWALFiles()); } metricsRegistry.snapshot(metricsRecordBuilder, all); }
@Override public void getMetrics(MetricsCollector metricsCollector, boolean all) { MetricsRecordBuilder mrb = metricsCollector.addRecord(metricsName); // wrapper can be null because this function is called inside of init. if (wrapper != null) { mrb.addCounter(Interns.info(CHECKSUM_FAILURES_KEY, CHECKSUM_FAILURES_DESC), wrapper.getChecksumFailures()); } metricsRegistry.snapshot(mrb, all); } }
@Override public void getMetrics(MetricsCollector collector, boolean b) { MetricsRecordBuilder rb = collector.addRecord(LlapDaemonJVMMetrics) .setContext("jvm") .tag(ProcessName, MetricsUtils.METRICS_PROCESS_NAME + "(PID: " + daemonPid + ")") .tag(SessionId, sessionId); getJvmMetrics(rb); }
@SuppressWarnings("rawtypes") @Test public void metrics2CycleIsNonDestructive() { metrics2Reporter.setDropwizardCounters(Collections.unmodifiableSortedMap(new TreeMap<String, Counter>())); metrics2Reporter.setDropwizardGauges(Collections.unmodifiableSortedMap(new TreeMap<String, Gauge>())); metrics2Reporter.setDropwizardHistograms(Collections.unmodifiableSortedMap(new TreeMap<String, Histogram>())); metrics2Reporter.setDropwizardMeters(Collections.unmodifiableSortedMap(new TreeMap<String, Meter>())); metrics2Reporter.setDropwizardTimers(Collections.unmodifiableSortedMap(new TreeMap<String, Timer>())); MetricsCollector collector = mock(MetricsCollector.class); MetricsRecordBuilder recordBuilder = mock(MetricsRecordBuilder.class); Mockito.when(collector.addRecord(recordName)).thenReturn(recordBuilder); metrics2Reporter.getMetrics(collector, true); }
@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) { MetricsRecordBuilder rb = collector.addRecord(JvmMetrics) .setContext("jvm").tag(ProcessName, processName) .tag(SessionId, sessionId); getMemoryUsage(rb); getGcUsage(rb); getThreadUsage(rb); getEventCounters(rb); }
/** * Iterates over the MetricRegistry and adds them to the {@code collector}. * * @param collector A metrics collector */ public void snapshotAllMetrics(MetricRegistry metricRegistry, MetricsCollector collector) { MetricRegistryInfo info = metricRegistry.getMetricRegistryInfo(); MetricsRecordBuilder builder = collector.addRecord(Interns.info(info.getMetricsName(), info.getMetricsDescription())); builder.setContext(info.getMetricsContext()); snapshotAllMetrics(metricRegistry, builder); }
@Override public void getMetrics(MetricsCollector collector, boolean all) { MetricsRecordBuilder rb = collector.addRecord(JvmMetrics) .setContext("jvm").tag(ProcessName, processName) .tag(SessionId, sessionId); getMemoryUsage(rb); getGcUsage(rb); getThreadUsage(rb); getEventCounters(rb); }