Class Span
java.lang.Object
one.profiler.Span
Records latency spans into the async-profiler JFR recording.
A span is a [start, end] time interval on the current thread, labeled with a tag
(e.g. an operation or endpoint name). Spans are written into the same JFR file as the profiling
samples, so the profile can later be filtered by span duration or tag. When async-profiler is
not loaded or no JFR session is running, all methods are cheap no-ops.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidRecords a span with explicit start and end timestamps obtained fromRecording.timestamp()or converted from another clock usingRecording.clockFrequency().static voidemitIfProfiled(long startTime, long endTime, String tag) Likeemit(long, long, String), but records the span only if a profiling sample was taken on this thread within[startTime, endTime].static voidEnds a span opened withstart()and records it with the given tag.static voidendIfProfiled(long startTime, String tag) Likeend(long, String), but records the span only if at least one profiling sample was taken on this thread while it was open.static longstart()Marks the start of a span on the current thread.
-
Method Details
-
start
public static long start()Marks the start of a span on the current thread.- Returns:
- a start timestamp to pass to
end(long, String)/endIfProfiled(long, String), or0if async-profiler is not loaded
-
end
-
endIfProfiled
Likeend(long, String), but records the span only if at least one profiling sample was taken on this thread while it was open. Useful for very frequent spans: those enclosing no sample add nothing to the profile and are skipped without entering native code.- Parameters:
startTime- the value returned bystart()tag- an arbitrary label, ornull
-
emit
Records a span with explicit start and end timestamps obtained fromRecording.timestamp()or converted from another clock usingRecording.clockFrequency().- Parameters:
tag- an arbitrary label, ornull
-
emitIfProfiled
Likeemit(long, long, String), but records the span only if a profiling sample was taken on this thread within[startTime, endTime].- Parameters:
tag- an arbitrary label, ornull
-