Search in sources :

Example 11 with Metrics

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

the class JaegerTracerTest method testWithBaggageRestrictionManager.

@Test
public void testWithBaggageRestrictionManager() {
    tracer = new JaegerTracer.Builder("TracerTestService").withReporter(new InMemoryReporter()).withSampler(new ConstSampler(true)).withMetrics(new Metrics(metricsFactory)).build();
    JaegerSpan span = tracer.buildSpan("some-operation").start();
    final String key = "key";
    tracer.setBaggage(span, key, "value");
    assertEquals(1, metricsFactory.getCounter("jaeger_tracer_baggage_updates", "result=ok"));
}
Also used : InMemoryReporter(io.jaegertracing.internal.reporters.InMemoryReporter) Metrics(io.jaegertracing.internal.metrics.Metrics) Builder(io.jaegertracing.internal.JaegerTracer.Builder) ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) Test(org.junit.Test)

Example 12 with Metrics

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

the class JaegerTracerTest method testRegisterInjector.

@Test
public void testRegisterInjector() {
    @SuppressWarnings("unchecked") Injector<TextMap> injector = mock(Injector.class);
    JaegerTracer tracer = new JaegerTracer.Builder("TracerTestService").withReporter(new InMemoryReporter()).withSampler(new ConstSampler(true)).withMetrics(new Metrics(new InMemoryMetricsFactory())).registerInjector(Format.Builtin.TEXT_MAP, injector).build();
    JaegerSpan span = tracer.buildSpan("leela").start();
    TextMap carrier = mock(TextMap.class);
    tracer.inject(span.context(), Format.Builtin.TEXT_MAP, carrier);
    verify(injector).inject(any(JaegerSpanContext.class), any(TextMap.class));
}
Also used : InMemoryReporter(io.jaegertracing.internal.reporters.InMemoryReporter) Metrics(io.jaegertracing.internal.metrics.Metrics) InMemoryMetricsFactory(io.jaegertracing.internal.metrics.InMemoryMetricsFactory) Builder(io.jaegertracing.internal.JaegerTracer.Builder) ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) TextMap(io.opentracing.propagation.TextMap) Test(org.junit.Test)

Example 13 with Metrics

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

the class BaggageSetterTest method setUp.

@Before
public void setUp() {
    metricsFactory = new InMemoryMetricsFactory();
    reporter = new InMemoryReporter();
    metrics = new Metrics(metricsFactory);
    mgr = mock(DefaultBaggageRestrictionManager.class);
    setter = new BaggageSetter(mgr, metrics);
    tracer = new JaegerTracer.Builder(SERVICE).withReporter(reporter).withSampler(new ConstSampler(true)).withMetrics(metrics).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) JaegerTracer(io.jaegertracing.internal.JaegerTracer) Before(org.junit.Before)

Example 14 with Metrics

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

the class RemoteReporterTest method setUp.

@Before
public void setUp() {
    metricsFactory = new InMemoryMetricsFactory();
    metrics = new Metrics(metricsFactory);
    sender = new InMemorySender();
    reporter = new RemoteReporter.Builder().withSender(sender).withFlushInterval(flushInterval).withMaxQueueSize(maxQueueSize).withMetrics(metrics).build();
    tracer = new JaegerTracer.Builder("test-remote-reporter").withReporter(reporter).withSampler(new ConstSampler(true)).withMetrics(metrics).build();
}
Also used : InMemoryMetricsFactory(io.jaegertracing.internal.metrics.InMemoryMetricsFactory) Metrics(io.jaegertracing.internal.metrics.Metrics) Builder(io.jaegertracing.internal.reporters.RemoteReporter.Builder) InMemorySender(io.jaegertracing.internal.senders.InMemorySender) ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) JaegerTracer(io.jaegertracing.internal.JaegerTracer) Before(org.junit.Before)

Example 15 with Metrics

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

the class RemoteControlledSamplerTest method testUpdateFailureKeepsTimerRunning.

@Test
public void testUpdateFailureKeepsTimerRunning() throws InterruptedException {
    undertest.close();
    CountDownLatch latch = new CountDownLatch(3);
    SamplingManager failingManager = serviceName -> {
        latch.countDown();
        throw new RuntimeException("test update failure");
    };
    undertest = new RemoteControlledSampler.Builder(SERVICE_NAME).withSamplingManager(failingManager).withInitialSampler(initialSampler).withMetrics(metrics).withPollingInterval(1).build();
    assertTrue(latch.await(1, TimeUnit.SECONDS));
}
Also used : SamplingStrategyErrorException(io.jaegertracing.internal.exceptions.SamplingStrategyErrorException) Metrics(io.jaegertracing.internal.metrics.Metrics) Mock(org.mockito.Mock) OperationSamplingParameters(io.jaegertracing.internal.samplers.http.OperationSamplingParameters) RunWith(org.junit.runner.RunWith) RateLimitingSamplingStrategy(io.jaegertracing.internal.samplers.http.RateLimitingSamplingStrategy) ArrayList(java.util.ArrayList) InMemoryMetricsFactory(io.jaegertracing.internal.metrics.InMemoryMetricsFactory) After(org.junit.After) Sampler(io.jaegertracing.spi.Sampler) PerOperationSamplingParameters(io.jaegertracing.internal.samplers.http.PerOperationSamplingParameters) Before(org.junit.Before) Assert.assertTrue(org.junit.Assert.assertTrue) Mockito.times(org.mockito.Mockito.times) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) SamplingManager(io.jaegertracing.spi.SamplingManager) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) SamplingStrategyResponse(io.jaegertracing.internal.samplers.http.SamplingStrategyResponse) Mockito.verify(org.mockito.Mockito.verify) TimeUnit(java.util.concurrent.TimeUnit) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) ProbabilisticSamplingStrategy(io.jaegertracing.internal.samplers.http.ProbabilisticSamplingStrategy) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Assert.assertEquals(org.junit.Assert.assertEquals) Mockito.mock(org.mockito.Mockito.mock) SamplingManager(io.jaegertracing.spi.SamplingManager) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

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