Search in sources :

Example 6 with MetricName

use of com.palantir.tritium.metrics.registry.MetricName in project atlasdb by palantir.

the class AtlasDbMetricsTest method instrumentTaggedAsyncFunctionWithExtraTags.

@Test
public void instrumentTaggedAsyncFunctionWithExtraTags() {
    Map<String, String> extraTags = ImmutableMap.of("key", "value");
    AsyncTestService asyncTestService = AtlasDbMetrics.instrumentWithTaggedMetrics(taggedMetrics, AsyncTestService.class, this.asyncTestService, $ -> extraTags);
    List<ListenableFuture<String>> futures = fireOffTenAsyncPings(asyncTestService);
    Instant now = Instant.now();
    MetricName metricName = MetricName.builder().safeName(ASYNC_PING_METRIC_NAME).safeTags(extraTags).build();
    awaitMetricsToBeReported(futures, metricName);
    assertThat(Instant.now()).as("in the event of scheduling issues, and despite having 10 concurrent futures, we complete " + "everything with 2*ttl").isBefore(now.plus(ASYNC_DURATION_TTL.plus(ASYNC_DURATION_TTL)));
    assertAllAsyncPingMetricsAreAccuratelyRecorded(futures, metricName);
}
Also used : MetricName(com.palantir.tritium.metrics.registry.MetricName) Instant(java.time.Instant) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Test(org.junit.Test)

Example 7 with MetricName

use of com.palantir.tritium.metrics.registry.MetricName in project atlasdb by palantir.

the class TransactionOutcomeMetricsAssert method checkPresentAndCheckCount.

private void checkPresentAndCheckCount(TransactionOutcome outcome, long count) {
    MetricName metricName = actual.getMetricName(outcome, ImmutableMap.of());
    checkPresentAndCheckCount(metricName, count);
}
Also used : MetricName(com.palantir.tritium.metrics.registry.MetricName)

Example 8 with MetricName

use of com.palantir.tritium.metrics.registry.MetricName in project tritium by palantir.

the class InstrumentedSslContextTest method testServerInstrumentation.

@Test
void testServerInstrumentation() throws Exception {
    TaggedMetricRegistry metrics = new DefaultTaggedMetricRegistry();
    try (Closeable ignored = server(MetricRegistries.instrument(metrics, newServerContext(), "server-context"))) {
        HttpsURLConnection con = (HttpsURLConnection) new URL("https://localhost:" + PORT).openConnection();
        con.setSSLSocketFactory(newClientContext().getSocketFactory());
        assertThat(con.getResponseCode()).isEqualTo(200);
    }
    MetricName name = findName(metrics, MetricName.builder().safeName("tls.handshake").putSafeTags("context", "server-context").putSafeTags("cipher", ENABLED_CIPHER).putSafeTags("protocol", ENABLED_PROTOCOL).build());
    assertThat(metrics.getMetrics()).containsOnlyKeys(name);
    assertThat(metrics.meter(name).getCount()).isOne();
}
Also used : MetricName(com.palantir.tritium.metrics.registry.MetricName) Closeable(java.io.Closeable) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry) TaggedMetricRegistry(com.palantir.tritium.metrics.registry.TaggedMetricRegistry) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry) HttpsURLConnection(javax.net.ssl.HttpsURLConnection) URL(java.net.URL) Test(org.junit.jupiter.api.Test)

Example 9 with MetricName

use of com.palantir.tritium.metrics.registry.MetricName in project tritium by palantir.

the class InstrumentedSslContextTest method testClientInstrumentationHttpsUrlConnection.

@Test
void testClientInstrumentationHttpsUrlConnection() throws Exception {
    TaggedMetricRegistry metrics = new DefaultTaggedMetricRegistry();
    try (Closeable ignored = server(newServerContext())) {
        SSLContext context = MetricRegistries.instrument(metrics, newClientContext(), "client-context");
        HttpsURLConnection con = (HttpsURLConnection) new URL("https://localhost:" + PORT).openConnection();
        con.setSSLSocketFactory(context.getSocketFactory());
        assertThat(con.getResponseCode()).isEqualTo(200);
    }
    MetricName name = findName(metrics, MetricName.builder().safeName("tls.handshake").putSafeTags("context", "client-context").putSafeTags("cipher", ENABLED_CIPHER).putSafeTags("protocol", ENABLED_PROTOCOL).build());
    assertThat(metrics.getMetrics()).containsOnlyKeys(name);
    assertThat(metrics.meter(name).getCount()).isOne();
}
Also used : MetricName(com.palantir.tritium.metrics.registry.MetricName) Closeable(java.io.Closeable) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry) TaggedMetricRegistry(com.palantir.tritium.metrics.registry.TaggedMetricRegistry) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry) SSLContext(javax.net.ssl.SSLContext) HttpsURLConnection(javax.net.ssl.HttpsURLConnection) URL(java.net.URL) Test(org.junit.jupiter.api.Test)

Example 10 with MetricName

use of com.palantir.tritium.metrics.registry.MetricName in project tritium by palantir.

the class MetricRegistriesTest method testRegisterAll.

@Test
void testRegisterAll() {
    TaggedMetricRegistry registry = new DefaultTaggedMetricRegistry();
    Gauge<Long> gauge = () -> 1L;
    Meter meter = new Meter();
    Histogram histogram = new Histogram(new ExponentiallyDecayingReservoir());
    Counter counter = new Counter();
    Timer timer = new Timer();
    MetricSet metricSet = () -> ImmutableMap.<String, Metric>builder().put("gauge", gauge).put("meter", meter).put("histogram", histogram).put("counter", counter).put("timer", timer).put("set", (MetricSet) () -> ImmutableMap.of("gauge", gauge)).build();
    MetricRegistries.registerAll(registry, "tritium", metricSet);
    assertThat(registry.getMetrics()).containsExactlyInAnyOrderEntriesOf(ImmutableMap.<MetricName, Metric>builder().put(simpleName("tritium.gauge"), gauge).put(simpleName("tritium.meter"), meter).put(simpleName("tritium.histogram"), histogram).put(simpleName("tritium.counter"), counter).put(simpleName("tritium.timer"), timer).put(simpleName("tritium.set.gauge"), gauge).build());
}
Also used : MetricName(com.palantir.tritium.metrics.registry.MetricName) Histogram(com.codahale.metrics.Histogram) ExponentiallyDecayingReservoir(com.codahale.metrics.ExponentiallyDecayingReservoir) Counter(com.codahale.metrics.Counter) Timer(com.codahale.metrics.Timer) Meter(com.codahale.metrics.Meter) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry) TaggedMetricRegistry(com.palantir.tritium.metrics.registry.TaggedMetricRegistry) Metric(com.codahale.metrics.Metric) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry) MetricSet(com.codahale.metrics.MetricSet) Test(org.junit.jupiter.api.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