Search in sources :

Example 1 with MetricId

use of io.mantisrx.common.metrics.spectator.MetricId in project mantis by Netflix.

the class SchedulingService method setupSchedulingServiceWatcherMetric.

private void setupSchedulingServiceWatcherMetric() {
    logger.info("Setting up SchedulingServiceWatcher metrics");
    lastSchedulingResultCallback.set(System.currentTimeMillis());
    final String metricGroup = "SchedulingServiceWatcher";
    final GaugeCallback timeSinceLastSchedulingRunGauge = new GaugeCallback(new MetricId(metricGroup, "timeSinceLastSchedulingRunMs"), () -> (double) (System.currentTimeMillis() - lastSchedulingResultCallback.get()), SpectatorRegistryFactory.getRegistry());
    final Metrics schedulingServiceWatcherMetrics = new Metrics.Builder().id(metricGroup).addGauge(timeSinceLastSchedulingRunGauge).build();
    MetricsRegistry.getInstance().registerAndGet(schedulingServiceWatcherMetrics);
}
Also used : GaugeCallback(io.mantisrx.common.metrics.spectator.GaugeCallback) MetricId(io.mantisrx.common.metrics.spectator.MetricId) Metrics(io.mantisrx.common.metrics.Metrics)

Example 2 with MetricId

use of io.mantisrx.common.metrics.spectator.MetricId in project mantis by Netflix.

the class HttpRequestMetrics method incrementEndpointMetrics.

public void incrementEndpointMetrics(String endpoint, final Tag... tags) {
    Preconditions.checkArgument(Endpoints.endpointSet.contains(endpoint), String.format("endpoint %s is not valid", endpoint));
    MetricId id = new MetricId(METRIC_GROUP_ID, endpoint, tags);
    registry.counter(id.getSpectatorId(registry)).increment();
}
Also used : MetricId(io.mantisrx.common.metrics.spectator.MetricId)

Aggregations

MetricId (io.mantisrx.common.metrics.spectator.MetricId)2 Metrics (io.mantisrx.common.metrics.Metrics)1 GaugeCallback (io.mantisrx.common.metrics.spectator.GaugeCallback)1