Search in sources :

Example 1 with Metrics

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

the class Configuration method getTracerBuilder.

public JaegerTracer.Builder getTracerBuilder() {
    if (reporterConfig == null) {
        reporterConfig = new ReporterConfiguration();
    }
    if (samplerConfig == null) {
        samplerConfig = new SamplerConfiguration();
    }
    if (codecConfig == null) {
        codecConfig = new CodecConfiguration();
    }
    if (metricsFactory == null) {
        metricsFactory = loadMetricsFactory();
    }
    Metrics metrics = new Metrics(metricsFactory);
    Reporter reporter = reporterConfig.getReporter(metrics);
    Sampler sampler = samplerConfig.createSampler(serviceName, metrics);
    JaegerTracer.Builder builder = createTracerBuilder(serviceName).withSampler(sampler).withReporter(reporter).withMetrics(metrics).withTags(tracerTags);
    if (useTraceId128Bit) {
        builder = builder.withTraceId128Bit();
    }
    codecConfig.apply(builder);
    return builder;
}
Also used : Metrics(io.jaegertracing.internal.metrics.Metrics) Reporter(io.jaegertracing.spi.Reporter) CompositeReporter(io.jaegertracing.internal.reporters.CompositeReporter) RemoteReporter(io.jaegertracing.internal.reporters.RemoteReporter) LoggingReporter(io.jaegertracing.internal.reporters.LoggingReporter) Sampler(io.jaegertracing.spi.Sampler) RateLimitingSampler(io.jaegertracing.internal.samplers.RateLimitingSampler) ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) ProbabilisticSampler(io.jaegertracing.internal.samplers.ProbabilisticSampler) RemoteControlledSampler(io.jaegertracing.internal.samplers.RemoteControlledSampler) JaegerTracer(io.jaegertracing.internal.JaegerTracer)

Example 2 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 3 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 4 with Metrics

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

the class JaegerSpanTest method setUp.

@Before
public void setUp() {
    metricsFactory = new InMemoryMetricsFactory();
    reporter = new InMemoryReporter();
    clock = mock(Clock.class);
    metrics = new Metrics(metricsFactory);
    final JaegerTracer.Builder tracerBuilder = new JaegerTracer.Builder("SamplerTest").withReporter(reporter).withSampler(new ConstSampler(true)).withMetrics(metrics).withClock(clock).withBaggageRestrictionManager(new DefaultBaggageRestrictionManager()).withExpandExceptionLogs();
    tracer = tracerBuilder.build();
    tracer128 = tracerBuilder.withTraceId128Bit().build();
    jaegerSpan = tracer.buildSpan("some-operation").start();
}
Also used : InMemoryReporter(io.jaegertracing.internal.reporters.InMemoryReporter) InMemoryMetricsFactory(io.jaegertracing.internal.metrics.InMemoryMetricsFactory) Metrics(io.jaegertracing.internal.metrics.Metrics) ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) Clock(io.jaegertracing.internal.clock.Clock) DefaultBaggageRestrictionManager(io.jaegertracing.internal.baggage.DefaultBaggageRestrictionManager) Before(org.junit.Before)

Example 5 with Metrics

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

the class RemoteBaggageRestrictionManagerTest method setUp.

@Before
public void setUp() throws Exception {
    metricsFactory = new InMemoryMetricsFactory();
    metrics = new Metrics(metricsFactory);
}
Also used : InMemoryMetricsFactory(io.jaegertracing.internal.metrics.InMemoryMetricsFactory) Metrics(io.jaegertracing.internal.metrics.Metrics) 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