com.codahale.metrics.Gauge Java Examples

The following examples show how to use com.codahale.metrics.Gauge. 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: CloudWatchReporterTest.java    From codahale-aggregated-metrics-cloudwatch-reporter with MIT License 6 votes vote down vote up
@Test
public void reportMetersCountersGaugesWithZeroValuesOnlyWhenConfigured() throws Exception {
    metricRegistry.register(ARBITRARY_GAUGE_NAME, (Gauge<Long>) () -> 0L);
    metricRegistry.meter(ARBITRARY_METER_NAME).mark(0);
    metricRegistry.counter(ARBITRARY_COUNTER_NAME).inc(0);
    metricRegistry.timer(ARBITRARY_TIMER_NAME).update(-1L, TimeUnit.NANOSECONDS);

    buildReportWithSleep(reporterBuilder
            .withArithmeticMean()
            .withOneMinuteMeanRate()
            .withFiveMinuteMeanRate()
            .withFifteenMinuteMeanRate()
            .withZeroValuesSubmission()
            .withMeanRate());

    verify(mockAmazonCloudWatchAsyncClient, times(1)).putMetricData(metricDataRequestCaptor.capture());

    final PutMetricDataRequest putMetricDataRequest = metricDataRequestCaptor.getValue();
    final List<MetricDatum> metricData = putMetricDataRequest.metricData();
    for (final MetricDatum metricDatum : metricData) {
        assertThat(metricDatum.value()).isEqualTo(0.0);
    }
}
 
Example #2
Source File: TestMetricRuleEvaluator.java    From datacollector with Apache License 2.0 6 votes vote down vote up
@Test
public void testCounterDisabled() {
  //create timer with id "testMetricAlerts" and register with metric registry, bump up value to 4.
  Counter c = MetricsConfigurator.createCounter(metrics, "testCounterDisabled", PIPELINE_NAME, REVISION);
  c.inc(100);

  MetricsRuleDefinition metricsRuleDefinition = new MetricsRuleDefinition("testCounterDisabled",
    "testCounterDisabled", "testCounterDisabled", MetricType.COUNTER,
    MetricElement.COUNTER_COUNT, "${value()>98}", false, false, System.currentTimeMillis());
  MetricRuleEvaluator metricRuleEvaluator = new MetricRuleEvaluator(metricsRuleDefinition, metrics,
    new AlertManager(PIPELINE_NAME, PIPELINE_TITLE, REVISION, null, metrics, runtimeInfo, new EventListenerManager()),
      new RuleDefinitionsConfigBean(), 0);
  metricRuleEvaluator.checkForAlerts();

  //get alert gauge
  Gauge<Object> gauge = MetricsConfigurator.getGauge(metrics,
    AlertsUtil.getAlertGaugeName(metricsRuleDefinition.getId()));
  Assert.assertNull(gauge);
}
 
Example #3
Source File: RaftBasicTests.java    From incubator-ratis with Apache License 2.0 6 votes vote down vote up
private static Gauge getStatemachineGaugeWithName(RaftServerImpl server,
    String gaugeName) {

  MetricRegistryInfo info = new MetricRegistryInfo(server.getMemberId().toString(),
      RATIS_APPLICATION_NAME_METRICS,
      RATIS_STATEMACHINE_METRICS, RATIS_STATEMACHINE_METRICS_DESC);

  Optional<RatisMetricRegistry> metricRegistry = MetricRegistries.global().get(info);
  Assert.assertTrue(metricRegistry.isPresent());
  RatisMetricRegistry ratisStateMachineMetricRegistry = metricRegistry.get();

  SortedMap<String, Gauge> gaugeMap =
      ratisStateMachineMetricRegistry.getGauges((s, metric) ->
          s.contains(gaugeName));

  return gaugeMap.get(gaugeMap.firstKey());
}
 
Example #4
Source File: ClientAppRegisterInstanceController.java    From radar with Apache License 2.0 6 votes vote down vote up
private void initMetric() {
	MetricSingleton.getMetricRegistry().register(MetricRegistry.name("data.registerInstanceCount"),
			new Gauge<Long>() {
				@Override
				public Long getValue() {
					return registCounter.get();
				}
			});
	MetricSingleton.getMetricRegistry().register(MetricRegistry.name("data.registerInstanceTime"),
			new Gauge<Long>() {
				@Override
				public Long getValue() {
					return registTime;
				}
			});
}
 
Example #5
Source File: GaugeConverterTest.java    From cf-java-logging-support with Apache License 2.0 6 votes vote down vote up
@Test
public void testGaugeMetric() {
    SortedMap<String, Gauge> gauges = new TreeMap<>();
    Gauge<Number> gauge = new Gauge<Number>() {

        @Override
        public Number getValue() {
            return new Double(METRIC_VALUE);
        }

    };
    gauges.put(GAUGE_METRIC, gauge);
    List<Metric> metrics = new GaugeConverter().convert(gauges, currentTimeMillis);
    ConverterTestUtil util =
        new ConverterTestUtil(metrics, GAUGE_METRIC, MetricType.GAUGE.getMetricTypeName(), currentTimeMillis);
    util.checkMetric(SUFFIX_VALUE, METRIC_VALUE);
    assertEquals(1, metrics.size());
}
 
Example #6
Source File: Heart.java    From cassandra-reaper with Apache License 2.0 6 votes vote down vote up
private void registerGauges() throws IllegalArgumentException {
  if (!GAUGES_REGISTERED.getAndSet(true)) {

    context.metricRegistry.register(
        MetricRegistry.name(Heart.class, "runningThreadCount"),
        (Gauge<Integer>) () -> forkJoinPool.getRunningThreadCount());

    context.metricRegistry.register(
        MetricRegistry.name(Heart.class, "activeThreadCount"),
        (Gauge<Integer>) () -> forkJoinPool.getActiveThreadCount());

    context.metricRegistry.register(
        MetricRegistry.name(Heart.class, "queuedTaskCount"),
        (Gauge<Long>) () -> forkJoinPool.getQueuedTaskCount());

    context.metricRegistry.register(
        MetricRegistry.name(Heart.class, "queuedSubmissionCount"),
        (Gauge<Integer>) () -> forkJoinPool.getQueuedSubmissionCount());
  }
}
 
Example #7
Source File: RaftBasicTests.java    From incubator-ratis with Apache License 2.0 6 votes vote down vote up
private static void checkFollowerCommitLagsLeader(MiniRaftCluster cluster) {
  List<RaftServerImpl> followers = cluster.getFollowers();
  RaftServerImpl leader = cluster.getLeader();

  Gauge leaderCommitGauge = RaftServerMetrics
      .getPeerCommitIndexGauge(leader, leader);

  for (RaftServerImpl follower : followers) {
    Gauge followerCommitGauge = RaftServerMetrics
        .getPeerCommitIndexGauge(leader, follower);
    Assert.assertTrue((Long)leaderCommitGauge.getValue() >=
        (Long)followerCommitGauge.getValue());
    Gauge followerMetric = RaftServerMetrics
        .getPeerCommitIndexGauge(follower, follower);
    System.out.println(followerCommitGauge.getValue());
    System.out.println(followerMetric.getValue());
    Assert.assertTrue((Long)followerCommitGauge.getValue()  <= (Long)followerMetric.getValue());
  }
}
 
Example #8
Source File: PlatformDriverExecutorRegistry.java    From arcusplatform with Apache License 2.0 6 votes vote down vote up
@Inject
public PlatformDriverExecutorRegistry(
      DriverConfig config,
      DriverRegistry registry, 
      DeviceDAO deviceDao, 
      Scheduler scheduler, 
      PlacePopulationCacheManager populationCacheMgr
) {
   this.driverQueueBacklog = config.getDriverBacklogSize();
   this.tombstonedDriverTimeoutMs = config.getDriverTombstoneTimeout(TimeUnit.MILLISECONDS);
   this.registry = registry;
   this.deviceDao = deviceDao;
   this.scheduler = scheduler;
   this.populationCacheMgr = populationCacheMgr;
   IrisMetricSet drivers = IrisMetrics.metrics("drivers");
   drivers.monitor("cache.executor", executorCache);
   drivers.monitor("cache.protocol", protocolToDriverCache);
   drivers.gauge("backlog", (Gauge<Map<String, Object>>) () -> queueBacklog());
}
 
Example #9
Source File: StatusQueueListener.java    From JuniperBot with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private static <T> T getMetricValue(Map<String, Metric> metricMap, String name, Function<Object, T> valueExtractor) {
    Metric metric = metricMap.get(name);
    T value = null;
    if (metric instanceof Gauge) {
        Gauge gauge = (Gauge) metric;
        value = (T) gauge.getValue();
    }
    if (metric instanceof Counter) {
        Counter counter = (Counter) metric;
        value = (T) (Long) counter.getCount();
    }
    if (value != null && valueExtractor != null) {
        value = valueExtractor.apply(value);
    }
    return value;
}
 
Example #10
Source File: TestDataDogReportingTask.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdateMetricsProcessor() throws InitializationException, IOException {
    MetricsService ms = new MetricsService();
    Map<String, Double> processorMetrics = ms.getProcessorMetrics(procStatus);
    Map<String, String> tagsMap = ImmutableMap.of("env", "test");
    DataDogReportingTask dataDogReportingTask = new TestableDataDogReportingTask();
    dataDogReportingTask.initialize(initContext);
    dataDogReportingTask.setup(configurationContext);
    dataDogReportingTask.updateMetrics(processorMetrics, Optional.of("sampleProcessor"), tagsMap);

    verify(metricRegistry).register(eq("nifi.sampleProcessor.FlowFilesReceivedLast5Minutes"), Mockito.<Gauge>any());
    verify(metricRegistry).register(eq("nifi.sampleProcessor.ActiveThreads"), Mockito.<Gauge>any());
    verify(metricRegistry).register(eq("nifi.sampleProcessor.BytesWrittenLast5Minutes"), Mockito.<Gauge>any());
    verify(metricRegistry).register(eq("nifi.sampleProcessor.BytesReadLast5Minutes"), Mockito.<Gauge>any());
    verify(metricRegistry).register(eq("nifi.sampleProcessor.FlowFilesSentLast5Minutes"), Mockito.<Gauge>any());
}
 
Example #11
Source File: ResourceSchedulerWrapper.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private void registerContainerAppNumMetrics() {
  metrics.register("variable.running.application",
    new Gauge<Integer>() {
      @Override
      public Integer getValue() {
        if (scheduler == null || scheduler.getRootQueueMetrics() == null) {
          return 0;
        } else {
          return scheduler.getRootQueueMetrics().getAppsRunning();
        }
      }
    }
  );
  metrics.register("variable.running.container",
    new Gauge<Integer>() {
      @Override
      public Integer getValue() {
        if(scheduler == null || scheduler.getRootQueueMetrics() == null) {
          return 0;
        } else {
          return scheduler.getRootQueueMetrics().getAllocatedContainers();
        }
      }
    }
  );
}
 
Example #12
Source File: SystemInfoHandlerTest.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
public void testMagickGetter() throws Exception {

    OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();

    // make one directly
    SimpleOrderedMap<Object> info = new SimpleOrderedMap<>();
    info.add( "name", os.getName() );
    info.add( "version", os.getVersion() );
    info.add( "arch", os.getArch() );

    // make another using MetricUtils.addMXBeanMetrics()
    SimpleOrderedMap<Object> info2 = new SimpleOrderedMap<>();
    MetricUtils.addMXBeanMetrics( os, OperatingSystemMXBean.class, null, (k, v) -> {
      info2.add(k, ((Gauge)v).getValue());
    } );

    // make sure they got the same thing
    for (String p : Arrays.asList("name", "version", "arch")) {
      assertEquals(info.get(p), info2.get(p));
    }
  }
 
Example #13
Source File: DashboardData.java    From styx with Apache License 2.0 5 votes vote down vote up
private ConnectionsPool() {
    String prefix = format("origins.%s.%s.connectionspool", origin.applicationId(), origin.id());

    SortedMap<String, Gauge> gauges = metrics.getGauges();

    availableGauge = gauges.get(prefix + ".available-connections");
    busyGauge = gauges.get(prefix + ".busy-connections");
    pendingGauge = gauges.get(prefix + ".pending-connections");
}
 
Example #14
Source File: RaftBasicTests.java    From incubator-ratis with Apache License 2.0 5 votes vote down vote up
public static void testStateMachineMetrics(boolean async,
    MiniRaftCluster cluster, Logger LOG) throws Exception {
  RaftServerImpl leader = waitForLeader(cluster);
  try (final RaftClient client = cluster.createClient()) {

    Assert.assertTrue(leader.isLeader());

    Gauge appliedIndexGauge = getStatemachineGaugeWithName(leader,
        STATEMACHINE_APPLIED_INDEX_GAUGE);
    Gauge smAppliedIndexGauge = getStatemachineGaugeWithName(leader,
        STATEMACHINE_APPLY_COMPLETED_GAUGE);

    long appliedIndexBefore = (Long) appliedIndexGauge.getValue();
    long smAppliedIndexBefore = (Long) smAppliedIndexGauge.getValue();
    checkFollowerCommitLagsLeader(cluster);

    if (async) {
      CompletableFuture<RaftClientReply> replyFuture = client.sendAsync(new SimpleMessage("abc"));
      replyFuture.get();
    } else {
      client.send(new SimpleMessage("abc"));
    }

    long appliedIndexAfter = (Long) appliedIndexGauge.getValue();
    long smAppliedIndexAfter = (Long) smAppliedIndexGauge.getValue();
    checkFollowerCommitLagsLeader(cluster);

    Assert.assertTrue("StateMachine Applied Index not incremented",
        appliedIndexAfter > appliedIndexBefore);
    Assert.assertTrue("StateMachine Apply completed Index not incremented",
        smAppliedIndexAfter > smAppliedIndexBefore);
  }
}
 
Example #15
Source File: CustomMetricsReporterTest.java    From cf-java-logging-support with Apache License 2.0 5 votes vote down vote up
@Test
public void testReportGaugeSuccessfully() {
    registry.register(METRIC_NAME, new Gauge<Integer>() {

        @Override
        public Integer getValue() {
            return 13;
        }
    });

    reporter.report();

    checkMetricsAreSent(1, "gauge", METRIC_NAME);
}
 
Example #16
Source File: WithMetricsSupport.java    From beam with Apache License 2.0 5 votes vote down vote up
private Function<Map.Entry<String, Metric>, Map<String, Gauge>> aggregatorMetricToGauges() {
  return entry -> {
    final NamedAggregators agg = ((AggregatorMetric) entry.getValue()).getNamedAggregators();
    final String parentName = entry.getKey();
    final Map<String, Gauge> gaugeMap = Maps.transformEntries(agg.renderAll(), toGauge());
    final Map<String, Gauge> fullNameGaugeMap = Maps.newLinkedHashMap();
    for (Map.Entry<String, Gauge> gaugeEntry : gaugeMap.entrySet()) {
      fullNameGaugeMap.put(parentName + "." + gaugeEntry.getKey(), gaugeEntry.getValue());
    }
    return Maps.filterValues(fullNameGaugeMap, Predicates.notNull());
  };
}
 
Example #17
Source File: MetricsStatsTest.java    From styx with Apache License 2.0 5 votes vote down vote up
@Test
@SuppressWarnings("unchecked")
public void shouldRegisterSubmissionRateLimitMetric() {
  Gauge<Double> gauge = mock(Gauge.class);
  stats.registerSubmissionRateLimitMetric(gauge);
  verify(registry).register(SUBMISSION_RATE_LIMIT, gauge);
}
 
Example #18
Source File: WithMetricsSupport.java    From beam with Apache License 2.0 5 votes vote down vote up
@Override
public SortedMap<String, Gauge> getGauges(final MetricFilter filter) {
  return new ImmutableSortedMap.Builder<String, Gauge>(
          Ordering.from(String.CASE_INSENSITIVE_ORDER))
      .putAll(internalMetricRegistry.getGauges(filter))
      .putAll(extractGauges(internalMetricRegistry, filter))
      .build();
}
 
Example #19
Source File: FastForwardHttpReporter.java    From semantic-metrics with Apache License 2.0 5 votes vote down vote up
private void reportGauge(
    final BatchBuilder builder, @SuppressWarnings("rawtypes") Gauge value
) {
    if (value == null) {
        return;
    }

    builder.buildPoint(null, convert(value.getValue()));
}
 
Example #20
Source File: OriginsInventory.java    From styx with Apache License 2.0 5 votes vote down vote up
private MonitoredOrigin addMonitoredEndpoint(Origin origin) {
    MonitoredOrigin monitoredOrigin = new MonitoredOrigin(origin);
    metricRegistry.register(monitoredOrigin.gaugeName, (Gauge<Integer>) () -> monitoredOrigin.state().gaugeValue);
    monitoredOrigin.startMonitoring();
    LOG.info("New origin added and activated. Origin={}:{}", appId, monitoredOrigin.origin.id());
    return monitoredOrigin;
}
 
Example #21
Source File: AlertManagerHelper.java    From datacollector with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public static void updateAlertGauge(Gauge gauge, Object value, RuleDefinition ruleDefinition) {
  Map<String, Object> alertResponse = (Map<String, Object>) gauge.getValue();
  // we keep timestamp of first trigger
  // update current value
  alertResponse.put(EmailConstants.CURRENT_VALUE, value);
  // add new alert text
  List<String> alertTexts = (List<String>) alertResponse.get(EmailConstants.ALERT_TEXTS);
  alertTexts = new ArrayList<>(alertTexts);
  updateAlertText(ruleDefinition, alertTexts);
  alertResponse.put(EmailConstants.ALERT_TEXTS, alertTexts);
}
 
Example #22
Source File: RequestHandlersTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Test
public void testInitCount() {
  String registry = h.getCore().getCoreMetricManager().getRegistryName();
  SolrMetricManager manager = h.getCoreContainer().getMetricManager();
  @SuppressWarnings({"unchecked"})
  Gauge<Number> g = (Gauge<Number>)manager.registry(registry).getMetrics().get("QUERY./mock.initCount");
  assertEquals("Incorrect init count",
               1, g.getValue().intValue());
}
 
Example #23
Source File: ServerReporter.java    From hugegraph with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void report(SortedMap<String, Gauge> gauges,
                   SortedMap<String, Counter> counters,
                   SortedMap<String, Histogram> histograms,
                   SortedMap<String, Meter> meters,
                   SortedMap<String, Timer> timers) {
    this.gauges = (SortedMap) gauges;
    this.counters = counters;
    this.histograms = histograms;
    this.meters = meters;
    this.timers = timers;
}
 
Example #24
Source File: InfluxDbReporterTest.java    From dropwizard-metrics-influxdb with Apache License 2.0 5 votes vote down vote up
@Test
public void reportsIncludedMeters() throws Exception {

    InfluxDbReporter filteredReporter = InfluxDbReporter
        .forRegistry(registry)
        .convertRatesTo(TimeUnit.SECONDS)
        .convertDurationsTo(TimeUnit.MILLISECONDS)
        .filter(MetricFilter.ALL)
        .groupGauges(true)
        .includeMeterFields(Sets.newSet("m1_rate"))
        .build(influxDb);


    final Meter meter = mock(Meter.class);
    when(meter.getCount()).thenReturn(1L);
    when(meter.getOneMinuteRate()).thenReturn(2.0);
    when(meter.getFiveMinuteRate()).thenReturn(3.0);
    when(meter.getFifteenMinuteRate()).thenReturn(4.0);
    when(meter.getMeanRate()).thenReturn(5.0);

    filteredReporter.report(this.<Gauge>map(), this.<Counter>map(), this.<Histogram>map(), this.map("filteredMeter", meter), this.<Timer>map());

    final ArgumentCaptor<InfluxDbPoint> influxDbPointCaptor = ArgumentCaptor.forClass(InfluxDbPoint.class);
    verify(influxDb, atLeastOnce()).appendPoints(influxDbPointCaptor.capture());
    InfluxDbPoint point = influxDbPointCaptor.getValue();

    assertThat(point.getMeasurement()).isEqualTo("filteredMeter");
    assertThat(point.getFields()).isNotEmpty();
    assertThat(point.getFields()).hasSize(1);
    assertThat(point.getFields()).contains(entry("m1_rate", 2.0));
    assertThat(point.getTags()).containsEntry("metricName", "filteredMeter");
}
 
Example #25
Source File: MemoryUsageGaugeSetTest.java    From eagle with Apache License 2.0 5 votes vote down vote up
@Test
public void testJVMMetrics() throws InterruptedException {
    LOG.info("Starting testJVMMetrics");
    final MetricRegistry metrics = new MetricRegistry();
    ConsoleReporter reporter = ConsoleReporter.forRegistry(metrics)
        .convertRatesTo(TimeUnit.SECONDS)
        .convertDurationsTo(TimeUnit.MILLISECONDS)
        .build();
    metrics.registerAll(new MemoryUsageGaugeSet());
    metrics.register("sample", (Gauge<Double>) () -> 0.1234);
    reporter.start(1, TimeUnit.SECONDS);
    reporter.close();
}
 
Example #26
Source File: MetricsService.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
public static void registerExecutorServiceMetrics(IrisMetricSet metrics, String name, ExecutorService es) {
   if (es instanceof ThreadPoolExecutor) {
      ThreadPoolExecutor tp = (ThreadPoolExecutor)es;
      metrics.gauge(name + ".running", (Gauge<Integer>)() -> tp.getActiveCount());
      metrics.gauge(name + ".submitted", (Gauge<Long>)() -> tp.getTaskCount());
      metrics.gauge(name + ".completed", (Gauge<Long>)() -> tp.getCompletedTaskCount());
      metrics.gauge(name + ".queued", (Gauge<Integer>)() -> tp.getQueue().size());
   } else {
      log.warn("could not register metrics for executor: {}", es, new Exception());
   }
}
 
Example #27
Source File: ResourceSchedulerWrapper.java    From big-c with Apache License 2.0 5 votes vote down vote up
private void registerJvmMetrics() {
  // add JVM gauges
  metrics.register("variable.jvm.free.memory",
    new Gauge<Long>() {
      @Override
      public Long getValue() {
        return Runtime.getRuntime().freeMemory();
      }
    }
  );
  metrics.register("variable.jvm.max.memory",
    new Gauge<Long>() {
      @Override
      public Long getValue() {
        return Runtime.getRuntime().maxMemory();
      }
    }
  );
  metrics.register("variable.jvm.total.memory",
    new Gauge<Long>() {
      @Override
      public Long getValue() {
        return Runtime.getRuntime().totalMemory();
      }
    }
  );
}
 
Example #28
Source File: TestDataObserverRunner.java    From datacollector with Apache License 2.0 5 votes vote down vote up
@Test
public void testHandleObserverRequestAlert() {
  RulesConfigurationChangeRequest rulesConfigurationChangeRequest = createRulesConfigurationChangeRequest(true, false);
  dataObserverRunner.handleConfigurationChangeRequest(rulesConfigurationChangeRequest);
  dataObserverRunner.handleDataRulesEvaluationRequest(createProductionObserverRequest());
  Gauge<Object> gauge = MetricsConfigurator.getGauge(metrics, AlertsUtil.getAlertGaugeName("myId"));
  Assert.assertNotNull(gauge);
  Assert.assertEquals((long) 3, ((Map<String, Object>) gauge.getValue()).get("currentValue"));
  Assert.assertNotNull(((Map<String, Object>) gauge.getValue()).get("timestamp"));
}
 
Example #29
Source File: CustomMetricsReporter.java    From cf-java-logging-support with Apache License 2.0 5 votes vote down vote up
private List<Metric> convert(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters,
                             SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters,
                             SortedMap<String, Timer> timers) {
    long timestamp = System.currentTimeMillis();
    boolean metricQuantiles = customMetricsConfig.metricQuantiles();

    return Stream.of(new GaugeConverter().convert(gauges, timestamp), 
              new CounterConverter().convert(counters, timestamp),
              new HistogramConverter(metricQuantiles).convert(histograms, timestamp), 
              new MeterConverter(metricQuantiles).convert(meters, timestamp),
              new TimerConverter(metricQuantiles).convert(timers, timestamp))
    .flatMap(Collection::stream)
    .collect(Collectors.toList());
}
 
Example #30
Source File: MemoryUsageGaugeSet.java    From semantic-metrics with Apache License 2.0 5 votes vote down vote up
private void putGauges(
    final Map<MetricId, Metric> gauges, final MetricId nonHeap,
    final MemoryUsageSupplier memoryUsageSupplier
) {
    gauges.put(nonHeap.tagged("memory_category", "init"), new Gauge<Long>() {
        @Override
        public Long getValue() {
            return memoryUsageSupplier.get().getInit();
        }
    });

    gauges.put(nonHeap.tagged("memory_category", "used"), new Gauge<Long>() {
        @Override
        public Long getValue() {
            return memoryUsageSupplier.get().getUsed();
        }
    });

    gauges.put(nonHeap.tagged("memory_category", "max"), new Gauge<Long>() {
        @Override
        public Long getValue() {
            return memoryUsageSupplier.get().getMax();
        }
    });

    gauges.put(nonHeap.tagged("memory_category", "committed"), new Gauge<Long>() {
        @Override
        public Long getValue() {
            return memoryUsageSupplier.get().getCommitted();
        }
    });
}