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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations