Search in sources :

Example 1 with Span

use of com.google.instrumentation.trace.Span in project instrumentation-java by census-instrumentation.

the class BasicContextTracing method main.

/** Main method. */
public static void main(String[] args) {
    Span span = tracer.spanBuilder("MyRootSpan").becomeRoot().startSpan();
    try (NonThrowingCloseable ws = tracer.withSpan(span)) {
        doWork();
    }
    span.end();
}
Also used : NonThrowingCloseable(com.google.instrumentation.common.NonThrowingCloseable) Span(com.google.instrumentation.trace.Span)

Example 2 with Span

use of com.google.instrumentation.trace.Span in project instrumentation-java by census-instrumentation.

the class BasicTracing method doWork.

private static void doWork() {
    Span span = tracer.spanBuilder(null, "MyRootSpan").startSpan();
    span.addAnnotation("This annotation is added directly to the span.");
    span.end();
}
Also used : Span(com.google.instrumentation.trace.Span)

Example 3 with Span

use of com.google.instrumentation.trace.Span in project instrumentation-java by census-instrumentation.

the class MultiSpansContextTracing method main.

/** Main method. */
public static void main(String[] args) {
    TraceExporter.LoggingServiceHandler.registerService(Tracing.getTraceExporter());
    Span span = tracer.spanBuilder("MyRootSpan").becomeRoot().startSpan();
    try (NonThrowingCloseable ws = tracer.withSpan(span)) {
        doWork();
    }
    span.end();
}
Also used : NonThrowingCloseable(com.google.instrumentation.common.NonThrowingCloseable) Span(com.google.instrumentation.trace.Span)

Example 4 with Span

use of com.google.instrumentation.trace.Span in project instrumentation-java by census-instrumentation.

the class MultiSpansTracing method doWork.

private static void doWork() {
    Span rootSpan = tracer.spanBuilder(null, "MyRootSpan").startSpan();
    rootSpan.addAnnotation("Annotation to the root Span before child is created.");
    Span childSpan = tracer.spanBuilder(rootSpan, "MyChildSpan").startSpan();
    childSpan.addAnnotation("Annotation to the child Span");
    childSpan.end();
    rootSpan.addAnnotation("Annotation to the root Span after child is ended.");
    rootSpan.end();
}
Also used : Span(com.google.instrumentation.trace.Span)

Example 5 with Span

use of com.google.instrumentation.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 (NonThrowingCloseable ws = tracer.withSpan(span)) {
        doSomeOtherWork();
    }
    span.end();
}
Also used : NonThrowingCloseable(com.google.instrumentation.common.NonThrowingCloseable) Span(com.google.instrumentation.trace.Span)

Aggregations

Span (com.google.instrumentation.trace.Span)5 NonThrowingCloseable (com.google.instrumentation.common.NonThrowingCloseable)3