Search in sources :

Example 1 with TestHandler

use of io.opencensus.testing.export.TestHandler in project instrumentation-java by census-instrumentation.

the class TraceWebAsyncClientAutoConfigurationTest method setup.

@Before
public void setup() {
    handler = new TestHandler();
    SpanExporter exporter = Tracing.getExportComponent().getSpanExporter();
    exporter.registerHandler("testing", handler);
    TraceParams params = Tracing.getTraceConfig().getActiveTraceParams().toBuilder().setSampler(Samplers.alwaysSample()).build();
    Tracing.getTraceConfig().updateActiveTraceParams(params);
}
Also used : SpanExporter(io.opencensus.trace.export.SpanExporter) TestHandler(io.opencensus.testing.export.TestHandler) TraceParams(io.opencensus.trace.config.TraceParams) Before(org.junit.Before)

Example 2 with TestHandler

use of io.opencensus.testing.export.TestHandler in project instrumentation-java by census-instrumentation.

the class HttpServletFilterIntegrationTests method setup.

@Before
@Override
public void setup() {
    super.setup();
    handler = new TestHandler();
    SpanExporter exporter = Tracing.getExportComponent().getSpanExporter();
    exporter.registerHandler("testing", handler);
    TraceParams params = Tracing.getTraceConfig().getActiveTraceParams().toBuilder().setSampler(Samplers.alwaysSample()).build();
    Tracing.getTraceConfig().updateActiveTraceParams(params);
}
Also used : SpanExporter(io.opencensus.trace.export.SpanExporter) TestHandler(io.opencensus.testing.export.TestHandler) TraceParams(io.opencensus.trace.config.TraceParams) Before(org.junit.Before)

Example 3 with TestHandler

use of io.opencensus.testing.export.TestHandler in project instrumentation-java by census-instrumentation.

the class SpanExporterImplTest method exportSpansToMultipleServices.

@Test
public void exportSpansToMultipleServices() {
    SpanExporterImpl spanExporter = SpanExporterImpl.create(4, Duration.create(1, 0));
    StartEndHandler startEndHandler = new StartEndHandlerImpl(spanExporter, runningSpanStore, sampledSpanStore, new SimpleEventQueue());
    spanExporter.registerHandler("test.service", serviceHandler);
    TestHandler serviceHandler2 = new TestHandler();
    spanExporter.registerHandler("test.service2", serviceHandler2);
    RecordEventsSpanImpl span1 = createSampledEndedSpan(startEndHandler, SPAN_NAME_1);
    RecordEventsSpanImpl span2 = createSampledEndedSpan(startEndHandler, SPAN_NAME_2);
    List<SpanData> exported1 = serviceHandler.waitForExport(2);
    List<SpanData> exported2 = serviceHandler2.waitForExport(2);
    assertThat(exported1).containsExactly(span1.toSpanData(), span2.toSpanData());
    assertThat(exported2).containsExactly(span1.toSpanData(), span2.toSpanData());
}
Also used : StartEndHandler(io.opencensus.implcore.trace.RecordEventsSpanImpl.StartEndHandler) SpanData(io.opencensus.trace.export.SpanData) TestHandler(io.opencensus.testing.export.TestHandler) StartEndHandlerImpl(io.opencensus.implcore.trace.StartEndHandlerImpl) SimpleEventQueue(io.opencensus.implcore.internal.SimpleEventQueue) RecordEventsSpanImpl(io.opencensus.implcore.trace.RecordEventsSpanImpl) Test(org.junit.Test)

Example 4 with TestHandler

use of io.opencensus.testing.export.TestHandler in project instrumentation-java by census-instrumentation.

the class CensusSpringAspectTest method setup.

@Before
public void setup() {
    handler = new TestHandler();
    SpanExporter exporter = Tracing.getExportComponent().getSpanExporter();
    exporter.registerHandler("testing", handler);
    TraceParams params = Tracing.getTraceConfig().getActiveTraceParams().toBuilder().setSampler(Samplers.alwaysSample()).build();
    Tracing.getTraceConfig().updateActiveTraceParams(params);
}
Also used : SpanExporter(io.opencensus.trace.export.SpanExporter) TestHandler(io.opencensus.testing.export.TestHandler) TraceParams(io.opencensus.trace.config.TraceParams) Before(org.junit.Before)

Aggregations

TestHandler (io.opencensus.testing.export.TestHandler)4 TraceParams (io.opencensus.trace.config.TraceParams)3 SpanExporter (io.opencensus.trace.export.SpanExporter)3 Before (org.junit.Before)3 SimpleEventQueue (io.opencensus.implcore.internal.SimpleEventQueue)1 RecordEventsSpanImpl (io.opencensus.implcore.trace.RecordEventsSpanImpl)1 StartEndHandler (io.opencensus.implcore.trace.RecordEventsSpanImpl.StartEndHandler)1 StartEndHandlerImpl (io.opencensus.implcore.trace.StartEndHandlerImpl)1 SpanData (io.opencensus.trace.export.SpanData)1 Test (org.junit.Test)1