public abstract class ScopedSpan extends Object
// Note span methods chain. Explicitly start the span when ready.
ScopedSpan span = tracer.startScopedSpan("encode");
try {
return encoder.encode();
} catch (RuntimeException | Error e) {
span.error(e); // Unless you handle exceptions, you might not know the operation failed!
throw e;
} finally {
span.finish(); // finish - start = the duration of the operation in microseconds
}
Usage notes: this type is intended for in-process synchronous code. Do not leak this type onto
another thread: it is not thread-safe. For advanced features or remote commands, use Span.
| Modifier and Type | Method | Description |
|---|---|---|
abstract ScopedSpan |
annotate(String value) |
Associates an event that explains latency with the current system time.
|
abstract TraceContext |
context() |
Returns the trace context associated with this span
|
abstract ScopedSpan |
error(Throwable throwable) |
Adds tags depending on the configured
error parser |
abstract void |
finish() |
Closes the
scope associated with this span,
then reports the span complete, assigning the most precise duration possible. |
abstract boolean |
isNoop() |
When true, no recording will take place, so no data is reported on finish.
|
abstract ScopedSpan |
tag(String key,
String value) |
Tags give your span context for search, viewing and analysis.
|
public abstract boolean isNoop()
finish() is called.public abstract TraceContext context()
public abstract ScopedSpan annotate(String value)
value - A short tag indicating the event, like "finagle.retry"public abstract ScopedSpan tag(String key, String value)
key - Name used to lookup spans, such as "your_app.version".value - String value, cannot be null.public abstract ScopedSpan error(Throwable throwable)
error parserpublic abstract void finish()
scope associated with this span,
then reports the span complete, assigning the most precise duration possible.Copyright © 2018 OpenZipkin. All rights reserved.