Search in sources :

Example 36 with MetricName

use of com.palantir.tritium.metrics.registry.MetricName in project conjure-java-runtime by palantir.

the class OkHttpClientsTest method verifyGlobalMetricsAreRegistered.

@Test
public /**
 * See {@link DispatcherMetricSet}.
 */
void verifyGlobalMetricsAreRegistered() {
    TaggedMetricRegistry registry = DefaultTaggedMetricRegistry.getDefault();
    ClientConfiguration clientConfiguration = ClientConfiguration.builder().from(createTestConfig(url)).taggedMetricRegistry(registry).build();
    OkHttpClients.create(clientConfiguration, AGENT, hostEventsSink, OkHttpClientsTest.class);
    assertThat(Collections2.transform(registry.getMetrics().keySet(), MetricName::safeName)).contains("com.palantir.conjure.java.connection-pool.connections.idle", "com.palantir.conjure.java.connection-pool.connections.total", "com.palantir.conjure.java.dispatcher.calls.queued", "com.palantir.conjure.java.dispatcher.calls.running");
}
Also used : MetricName(com.palantir.tritium.metrics.registry.MetricName) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry) TaggedMetricRegistry(com.palantir.tritium.metrics.registry.TaggedMetricRegistry) ClientConfiguration(com.palantir.conjure.java.client.config.ClientConfiguration) Test(org.junit.Test)

Example 37 with MetricName

use of com.palantir.tritium.metrics.registry.MetricName in project conjure-java-runtime by palantir.

the class InstrumentedInterceptorTest method testResponseMetricRegistered.

@Test
public void testResponseMetricRegistered() throws IOException {
    MetricName name = MetricName.builder().safeName("client.response").putSafeTags("service-name", "client").putSafeTags("libraryName", "conjure-java-runtime").putSafeTags("libraryVersion", "unknown").build();
    Timer timer = registry.timer(name);
    assertThat(timer.getCount()).isZero();
    successfulRequest(REQUEST_A);
    interceptor.intercept(chain);
    assertThat(timer.getCount()).isEqualTo(1);
}
Also used : MetricName(com.palantir.tritium.metrics.registry.MetricName) Timer(com.codahale.metrics.Timer) Test(org.junit.Test)

Aggregations

MetricName (com.palantir.tritium.metrics.registry.MetricName)37 TaggedMetricRegistry (com.palantir.tritium.metrics.registry.TaggedMetricRegistry)11 Test (org.junit.jupiter.api.Test)10 Metric (com.codahale.metrics.Metric)9 DefaultTaggedMetricRegistry (com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry)9 Timer (com.codahale.metrics.Timer)7 Counter (com.codahale.metrics.Counter)6 Histogram (com.codahale.metrics.Histogram)6 Meter (com.codahale.metrics.Meter)6 Test (org.junit.Test)6 Gauge (com.codahale.metrics.Gauge)5 Closeable (java.io.Closeable)5 ImmutableList (com.google.common.collect.ImmutableList)4 List (java.util.List)4 ConsoleReporter (com.codahale.metrics.ConsoleReporter)3 MetricSet (com.codahale.metrics.MetricSet)3 OkHttpClient (okhttp3.OkHttpClient)3 Request (okhttp3.Request)3 Response (okhttp3.Response)3 ExponentiallyDecayingReservoir (com.codahale.metrics.ExponentiallyDecayingReservoir)2