Search in sources :

Example 1 with SemanticMetricRegistry

use of com.spotify.metrics.core.SemanticMetricRegistry in project apollo by spotify.

the class MetricsTest method testJvmMetricSets.

@Test
public void testJvmMetricSets() throws Exception {
    final Injector injector = Guice.createInjector(this, MetricsModule.create());
    final SemanticMetricRegistry metricRegistry = injector.getInstance(SemanticMetricRegistry.class);
    // a little dicey to have to know what tags the MetricSets created metrics with to assert that
    // the Set itself was registered but there is no other obvious way to test these
    assertFalse("Expected MemoryUsageGaugeSet metrics to be registered with registry", metricRegistry.getGauges(filterByTag("what", "jvm-memory-usage")).isEmpty());
    assertFalse("Expected GarbageCollectorMetricSet metrics to be registered with registry", metricRegistry.getGauges(filterByTag("what", "jvm-gc-collections")).isEmpty());
    assertFalse("Expected ThreadStatesMetricSet metrics to be registered with registry", metricRegistry.getGauges(filterByTag("what", "jvm-thread-state")).isEmpty());
    assertFalse("Expected CpuGaugeSet metrics to be registered with registry", metricRegistry.getGauges(filterByTag("what", "process-cpu-load-percentage")).isEmpty());
    assertFalse("Expected FileDescriptorRatioGaugeSet metrics to be registered with registry", metricRegistry.getGauges(filterByTag("what", "file-descriptor-ratio")).isEmpty());
}
Also used : Injector(com.google.inject.Injector) SemanticMetricRegistry(com.spotify.metrics.core.SemanticMetricRegistry) Test(org.junit.Test)

Example 2 with SemanticMetricRegistry

use of com.spotify.metrics.core.SemanticMetricRegistry in project apollo by spotify.

the class SemanticServiceMetricsTest method setupWith.

private void setupWith(Predicate<What> predicate, Set<Integer> precreateCodes) {
    metricRegistry = new SemanticMetricRegistry();
    SemanticServiceMetrics serviceMetrics = new SemanticServiceMetrics(metricRegistry, MetricId.EMPTY.tagged("service", "test-service"), precreateCodes, predicate);
    requestMetrics = serviceMetrics.metricsForEndpointCall("hm://foo/<bar>");
}
Also used : SemanticMetricRegistry(com.spotify.metrics.core.SemanticMetricRegistry)

Example 3 with SemanticMetricRegistry

use of com.spotify.metrics.core.SemanticMetricRegistry in project apollo by spotify.

the class MetricsModule method semanticMetricRegistry.

@Provides
@Singleton
public SemanticMetricRegistry semanticMetricRegistry() {
    final SemanticMetricRegistry metricRegistry = new SemanticMetricRegistry();
    LOG.info("Creating SemanticMetricRegistry");
    // register JVM metricSets, using an empty MetricId as the FastForwardReporter will prepend
    // the injected MetricId.
    metricRegistry.register(MetricId.EMPTY, new MemoryUsageGaugeSet());
    metricRegistry.register(MetricId.EMPTY, new GarbageCollectorMetricSet());
    metricRegistry.register(MetricId.EMPTY, new ThreadStatesMetricSet());
    metricRegistry.register(MetricId.EMPTY, CpuGaugeSet.create());
    metricRegistry.register(MetricId.EMPTY, new FileDescriptorGaugeSet());
    return metricRegistry;
}
Also used : MemoryUsageGaugeSet(com.spotify.metrics.jvm.MemoryUsageGaugeSet) ThreadStatesMetricSet(com.spotify.metrics.jvm.ThreadStatesMetricSet) FileDescriptorGaugeSet(com.spotify.metrics.jvm.FileDescriptorGaugeSet) SemanticMetricRegistry(com.spotify.metrics.core.SemanticMetricRegistry) GarbageCollectorMetricSet(com.spotify.metrics.jvm.GarbageCollectorMetricSet) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Aggregations

SemanticMetricRegistry (com.spotify.metrics.core.SemanticMetricRegistry)3 Injector (com.google.inject.Injector)1 Provides (com.google.inject.Provides)1 Singleton (com.google.inject.Singleton)1 FileDescriptorGaugeSet (com.spotify.metrics.jvm.FileDescriptorGaugeSet)1 GarbageCollectorMetricSet (com.spotify.metrics.jvm.GarbageCollectorMetricSet)1 MemoryUsageGaugeSet (com.spotify.metrics.jvm.MemoryUsageGaugeSet)1 ThreadStatesMetricSet (com.spotify.metrics.jvm.ThreadStatesMetricSet)1 Test (org.junit.Test)1