Search in sources :

Example 26 with Span

use of io.opencensus.trace.Span in project instrumentation-java by census-instrumentation.

the class SpanOperationsBenchmark method addAnnotationWithAnnotation.

/**
 * Add an annotation with an annotation.
 */
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public Span addAnnotationWithAnnotation(Data data) {
    Span span = data.annotationSpanAnnotation;
    Annotation annotation = Annotation.fromDescriptionAndAttributes(ANNOTATION_DESCRIPTION, data.attributeMap);
    span.addAnnotation(annotation);
    return span;
}
Also used : Span(io.opencensus.trace.Span) Annotation(io.opencensus.trace.Annotation) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Example 27 with Span

use of io.opencensus.trace.Span in project instrumentation-java by census-instrumentation.

the class SpanOperationsBenchmark method addAnnotationEmpty.

/**
 * Add an annotation as description only.
 */
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public Span addAnnotationEmpty(Data data) {
    Span span = data.annotationSpanEmpty;
    span.addAnnotation(ANNOTATION_DESCRIPTION);
    return span;
}
Also used : Span(io.opencensus.trace.Span) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Example 28 with Span

use of io.opencensus.trace.Span in project instrumentation-java by census-instrumentation.

the class SpanOperationsBenchmark method putAttributes.

/**
 * Add attributes as a map.
 */
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public Span putAttributes(Data data) {
    Span span = data.attributeSpan;
    span.putAttributes(data.attributeMap);
    return span;
}
Also used : Span(io.opencensus.trace.Span) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Example 29 with Span

use of io.opencensus.trace.Span in project instrumentation-java by census-instrumentation.

the class StartEndSpanBenchmark method startEndNonSampledRootSpan.

/**
 * This benchmark attempts to measure performance of start/end for a non-sampled root {@code
 * Span}.
 */
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public Span startEndNonSampledRootSpan(Data data) {
    Span span = data.tracer.spanBuilderWithExplicitParent(SPAN_NAME, null).setSampler(Samplers.neverSample()).startSpan();
    span.end();
    return span;
}
Also used : Span(io.opencensus.trace.Span) BlankSpan(io.opencensus.trace.BlankSpan) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Example 30 with Span

use of io.opencensus.trace.Span in project instrumentation-java by census-instrumentation.

the class StartEndSpanBenchmark method startEndRecordEventsRootSpan.

/**
 * This benchmark attempts to measure performance of start/end for a root {@code Span} with record
 * events option.
 */
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public Span startEndRecordEventsRootSpan(Data data) {
    Span span = data.tracer.spanBuilderWithExplicitParent(SPAN_NAME, null).setSampler(Samplers.neverSample()).setRecordEvents(true).startSpan();
    span.end();
    return span;
}
Also used : Span(io.opencensus.trace.Span) BlankSpan(io.opencensus.trace.BlankSpan) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Aggregations

Span (io.opencensus.trace.Span)47 Test (org.junit.Test)17 Benchmark (org.openjdk.jmh.annotations.Benchmark)14 BenchmarkMode (org.openjdk.jmh.annotations.BenchmarkMode)14 OutputTimeUnit (org.openjdk.jmh.annotations.OutputTimeUnit)14 Scope (io.opencensus.common.Scope)8 BlankSpan (io.opencensus.trace.BlankSpan)8 ArrayList (java.util.ArrayList)4 SpanBuilder (io.opencensus.trace.SpanBuilder)3 SpanContext (io.opencensus.trace.SpanContext)3 ApiException (com.google.api.gax.rpc.ApiException)2 ByteString (com.google.protobuf.ByteString)2 HttpRequestContext (io.opencensus.contrib.http.HttpRequestContext)2 Metric (io.opencensus.metrics.export.Metric)2 TagContext (io.opencensus.tags.TagContext)2 AttributeValue (io.opencensus.trace.AttributeValue)2 SpanId (io.opencensus.trace.SpanId)2 TraceId (io.opencensus.trace.TraceId)2 TraceConfig (io.opencensus.trace.config.TraceConfig)2 TraceParams (io.opencensus.trace.config.TraceParams)2