Package-level declarations

Types

Link copied to clipboard
data class SpanAndScope(val span: Span, val scope: Scope)
Link copied to clipboard
data class Tag<T>(val name: String, val value: T)

A Tag is a name-value pair which will be added to a Span. Only primitive types are supported like Booleans, Numbers, and Strings.

Functions

Link copied to clipboard
fun Span.setBaggageItems(baggage: Map<String, Any>)

Conveniently sets baggage items all at once. Baggage values come from Any.toString.

Link copied to clipboard
fun Span.setTag(tag: Tag<*>)
Link copied to clipboard
fun Span.setTags(tags: Collection<Tag<*>>)

Conveniently set tags all at once.

Link copied to clipboard
fun <T> Tracer.trace(spanName: String, tags: Map<String, String> = mapOf(), f: () -> T): T

Traces a function f, using a span called spanName, which is automatically finished when the function completes execution.

Link copied to clipboard
fun <T> Tracer.traceWithNewRootSpan(spanName: String, tags: Map<String, String> = mapOf(), retainBaggage: Boolean = false, f: (Span) -> T): T

Like traceWithSpan, but always starts a new independent (root) span. If you'd like to continue propagating baggage that was set on the previous active span, set retainBaggage to true.

Link copied to clipboard
fun <T> Tracer.traceWithSpan(spanName: String, tags: Map<String, String> = mapOf(), f: (Span) -> T): T

Like trace, but exposes the new active Span to f.

Link copied to clipboard
inline fun <T> Tracer.withNewScope(span: Span, crossinline f: () -> T): T

Instruments a function f with a new scope. This is helpful if you need to create a new Scope for an existing Span, for example, if you are switching threads (since Scopes are not thread-safe).