use of io.opencensus.trace.Span in project instrumentation-java by census-instrumentation.
the class BasicOperationsBenchmark method createSpanWithExplicitParent.
/**
* Create a child span.
*/
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public Span createSpanWithExplicitParent(Data data) {
Span span = data.tracer.spanBuilderWithExplicitParent("ChildSpan", data.span).setRecordEvents(data.recorded).setSampler(data.sampled ? Samplers.alwaysSample() : Samplers.neverSample()).startSpan();
span.end();
return span;
}
use of io.opencensus.trace.Span in project instrumentation-java by census-instrumentation.
the class BasicOperationsBenchmark method createSpanWithRemoteParent.
/**
* Create a child span with a remote parent.
*/
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public Span createSpanWithRemoteParent(Data data) {
Span span = data.tracer.spanBuilderWithRemoteParent("ChildSpanFromRemoteParent", data.span.getContext()).setRecordEvents(data.recorded).setSampler(data.sampled ? Samplers.alwaysSample() : Samplers.neverSample()).startSpan();
span.end();
return span;
}
use of io.opencensus.trace.Span in project instrumentation-java by census-instrumentation.
the class BasicOperationsBenchmark method createRootSpan.
/**
* Create a root span.
*/
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public Span createRootSpan(Data data) {
Span span = data.tracer.spanBuilderWithExplicitParent("RootSpan", null).setRecordEvents(data.recorded).setSampler(data.sampled ? Samplers.alwaysSample() : Samplers.neverSample()).startSpan();
span.end();
return span;
}
use of io.opencensus.trace.Span in project instrumentation-java by census-instrumentation.
the class ContextUtilsTest method testGetCurrentSpan_DefaultContext.
@Test
public void testGetCurrentSpan_DefaultContext() {
Span span = ContextHandleUtils.getValue(ContextHandleUtils.currentContext());
assertThat(span).isEqualTo(BlankSpan.INSTANCE);
}
use of io.opencensus.trace.Span in project instrumentation-java by census-instrumentation.
the class MultiSpansContextTracing method doSomeMoreWork.
private static void doSomeMoreWork() {
// Create a child Span of the current Span.
Span span = tracer.spanBuilder("MyChildSpan").startSpan();
try (Scope ws = tracer.withSpan(span)) {
doSomeOtherWork();
}
span.end();
}
Aggregations