Search in sources :

Example 6 with Metrics

use of io.jaegertracing.internal.metrics.Metrics in project jaeger-client-java by jaegertracing.

the class MicrometerTest method testExposedMetrics.

@Test
public void testExposedMetrics() {
    Configuration configuration = new Configuration("exposedmetrics");
    final JaegerTracer tracer = configuration.getTracerBuilder().withMetrics(metrics).build();
    // This is a gauge, so it needs to be non-zero to come back from prometheus
    metrics.reporterQueueLength.update(1);
    List<Meter> meters = new ArrayList<>(prometheusRegistry.getMeters());
    Map<String, Long> metricCounts = meters.stream().collect(groupingBy(m -> m.getId().getName(), counting()));
    assertEquals("Wrong number of metrics collected", expectedMetricCounts.size(), metricCounts.keySet().size());
    for (String name : metricCounts.keySet()) {
        assertTrue("Unexpected metric " + name, expectedMetricCounts.containsKey(name));
    }
    for (String metricName : expectedMetricCounts.keySet()) {
        assertTrue("Did not find metric " + metricName, metricCounts.containsKey(metricName));
        assertEquals("Wrong count for " + metricName, expectedMetricCounts.get(metricName), metricCounts.get(metricName));
    }
    tracer.close();
}
Also used : Metrics(io.jaegertracing.internal.metrics.Metrics) MethodSorters(org.junit.runners.MethodSorters) BeforeClass(org.junit.BeforeClass) Collectors.counting(java.util.stream.Collectors.counting) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) HashMap(java.util.HashMap) JaegerSpan(io.jaegertracing.internal.JaegerSpan) ArrayList(java.util.ArrayList) Assert.assertThat(org.junit.Assert.assertThat) Map(java.util.Map) After(org.junit.After) Sampler(io.jaegertracing.spi.Sampler) IsEqual(org.hamcrest.core.IsEqual) Timer(io.jaegertracing.internal.metrics.Timer) Before(org.junit.Before) ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) Assert.assertTrue(org.junit.Assert.assertTrue) Meter(io.micrometer.core.instrument.Meter) Test(org.junit.Test) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) PrometheusMeterRegistry(io.micrometer.prometheus.PrometheusMeterRegistry) Configuration(io.jaegertracing.Configuration) FixMethodOrder(org.junit.FixMethodOrder) JaegerTracer(io.jaegertracing.internal.JaegerTracer) Assert.assertEquals(org.junit.Assert.assertEquals) PrometheusConfig(io.micrometer.prometheus.PrometheusConfig) Configuration(io.jaegertracing.Configuration) Meter(io.micrometer.core.instrument.Meter) ArrayList(java.util.ArrayList) JaegerTracer(io.jaegertracing.internal.JaegerTracer) Test(org.junit.Test)

Example 7 with Metrics

use of io.jaegertracing.internal.metrics.Metrics in project jaeger-client-java by jaegertracing.

the class MicrometerTest method setUp.

@Before
public void setUp() {
    registry = io.micrometer.core.instrument.Metrics.globalRegistry;
    prometheusRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
    io.micrometer.core.instrument.Metrics.addRegistry(prometheusRegistry);
    metrics = new Metrics(new MicrometerMetricsFactory());
}
Also used : PrometheusMeterRegistry(io.micrometer.prometheus.PrometheusMeterRegistry) Metrics(io.jaegertracing.internal.metrics.Metrics) Before(org.junit.Before)

Example 8 with Metrics

use of io.jaegertracing.internal.metrics.Metrics in project jaeger-client-java by jaegertracing.

the class ConfigurationTest method testProbabilisticSampler.

@Test
public void testProbabilisticSampler() {
    SamplerConfiguration samplerConfiguration = new SamplerConfiguration().withType(ProbabilisticSampler.TYPE);
    Sampler sampler = samplerConfiguration.createSampler("name", new Metrics(new InMemoryMetricsFactory()));
    assertTrue(sampler instanceof ProbabilisticSampler);
}
Also used : Metrics(io.jaegertracing.internal.metrics.Metrics) InMemoryMetricsFactory(io.jaegertracing.internal.metrics.InMemoryMetricsFactory) Sampler(io.jaegertracing.spi.Sampler) RateLimitingSampler(io.jaegertracing.internal.samplers.RateLimitingSampler) ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) ProbabilisticSampler(io.jaegertracing.internal.samplers.ProbabilisticSampler) SamplerConfiguration(io.jaegertracing.Configuration.SamplerConfiguration) ProbabilisticSampler(io.jaegertracing.internal.samplers.ProbabilisticSampler) Test(org.junit.Test)

Example 9 with Metrics

use of io.jaegertracing.internal.metrics.Metrics in project jaeger-client-java by jaegertracing.

the class ConfigurationTest method testRateLimitingSampler.

@Test
public void testRateLimitingSampler() {
    SamplerConfiguration samplerConfiguration = new SamplerConfiguration().withType(RateLimitingSampler.TYPE);
    Sampler sampler = samplerConfiguration.createSampler("name", new Metrics(new InMemoryMetricsFactory()));
    assertTrue(sampler instanceof RateLimitingSampler);
}
Also used : RateLimitingSampler(io.jaegertracing.internal.samplers.RateLimitingSampler) Metrics(io.jaegertracing.internal.metrics.Metrics) InMemoryMetricsFactory(io.jaegertracing.internal.metrics.InMemoryMetricsFactory) Sampler(io.jaegertracing.spi.Sampler) RateLimitingSampler(io.jaegertracing.internal.samplers.RateLimitingSampler) ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) ProbabilisticSampler(io.jaegertracing.internal.samplers.ProbabilisticSampler) SamplerConfiguration(io.jaegertracing.Configuration.SamplerConfiguration) Test(org.junit.Test)

Example 10 with Metrics

use of io.jaegertracing.internal.metrics.Metrics in project jaeger-client-java by jaegertracing.

the class JaegerTracerTest method setUp.

@Before
public void setUp() {
    metricsFactory = new InMemoryMetricsFactory();
    tracer = new JaegerTracer.Builder("TracerTestService").withReporter(new InMemoryReporter()).withSampler(new ConstSampler(true)).withMetrics(new Metrics(metricsFactory)).build();
}
Also used : InMemoryReporter(io.jaegertracing.internal.reporters.InMemoryReporter) InMemoryMetricsFactory(io.jaegertracing.internal.metrics.InMemoryMetricsFactory) Metrics(io.jaegertracing.internal.metrics.Metrics) Builder(io.jaegertracing.internal.JaegerTracer.Builder) ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) Before(org.junit.Before)

Aggregations

Metrics (io.jaegertracing.internal.metrics.Metrics)15 InMemoryMetricsFactory (io.jaegertracing.internal.metrics.InMemoryMetricsFactory)11 ConstSampler (io.jaegertracing.internal.samplers.ConstSampler)11 Before (org.junit.Before)9 Test (org.junit.Test)7 Sampler (io.jaegertracing.spi.Sampler)6 InMemoryReporter (io.jaegertracing.internal.reporters.InMemoryReporter)5 JaegerTracer (io.jaegertracing.internal.JaegerTracer)4 ProbabilisticSampler (io.jaegertracing.internal.samplers.ProbabilisticSampler)4 RateLimitingSampler (io.jaegertracing.internal.samplers.RateLimitingSampler)4 SamplerConfiguration (io.jaegertracing.Configuration.SamplerConfiguration)3 Builder (io.jaegertracing.internal.JaegerTracer.Builder)3 PrometheusMeterRegistry (io.micrometer.prometheus.PrometheusMeterRegistry)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 TimeUnit (java.util.concurrent.TimeUnit)2 After (org.junit.After)2 Assert.assertEquals (org.junit.Assert.assertEquals)2 Assert.assertTrue (org.junit.Assert.assertTrue)2 Configuration (io.jaegertracing.Configuration)1