use of io.opencensus.trace.config.TraceParams 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);
}
use of io.opencensus.trace.config.TraceParams in project instrumentation-java by census-instrumentation.
the class RecordEventsSpanImplTest method droppingAnnotations.
@Test
public void droppingAnnotations() {
final int maxNumberOfAnnotations = 8;
TraceParams traceParams = TraceParams.DEFAULT.toBuilder().setMaxNumberOfAnnotations(maxNumberOfAnnotations).build();
RecordEventsSpanImpl span = RecordEventsSpanImpl.startSpan(spanContext, SPAN_NAME, null, parentSpanId, false, traceParams, startEndHandler, timestampConverter, testClock);
Annotation annotation = Annotation.fromDescription(ANNOTATION_DESCRIPTION);
for (int i = 0; i < 2 * maxNumberOfAnnotations; i++) {
span.addAnnotation(annotation);
testClock.advanceTime(Duration.create(0, 100));
}
SpanData spanData = span.toSpanData();
assertThat(spanData.getAnnotations().getDroppedEventsCount()).isEqualTo(maxNumberOfAnnotations);
assertThat(spanData.getAnnotations().getEvents().size()).isEqualTo(maxNumberOfAnnotations);
for (int i = 0; i < maxNumberOfAnnotations; i++) {
assertThat(spanData.getAnnotations().getEvents().get(i).getTimestamp()).isEqualTo(timestamp.addNanos(100L * (maxNumberOfAnnotations + i)));
assertThat(spanData.getAnnotations().getEvents().get(i).getEvent()).isEqualTo(annotation);
}
span.end();
spanData = span.toSpanData();
assertThat(spanData.getAnnotations().getDroppedEventsCount()).isEqualTo(maxNumberOfAnnotations);
assertThat(spanData.getAnnotations().getEvents().size()).isEqualTo(maxNumberOfAnnotations);
for (int i = 0; i < maxNumberOfAnnotations; i++) {
assertThat(spanData.getAnnotations().getEvents().get(i).getTimestamp()).isEqualTo(timestamp.addNanos(100L * (maxNumberOfAnnotations + i)));
assertThat(spanData.getAnnotations().getEvents().get(i).getEvent()).isEqualTo(annotation);
}
}
Aggregations