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);
}
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);
}
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();
}
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();
}
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());
}
Aggregations