Top Description Inners Fields Methods
io.micrometer.tracing

public Interface Span

extends SpanCustomizer
Imports
io.micrometer.tracing.propagation.Propagator, java.util.concurrent.TimeUnit

This API was heavily influenced by Brave. Parts of its documentation were taken directly from Brave.

Span is a single unit of work that needs to be started and stopped. Contains timing information and events and tags.

Authors
OpenZipkin Brave Authors, Marcin Grzejszczak
Since
1.0.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
Span.Builder

In some cases (e.g. when dealing with Propagator#extract(Object, Propagator.Getter)'s we want to create a span that has not yet been started, yet it's heavily configurable (some options are not possible to be set when a span has already been started).

public static enum
Span.Kind

Type of span.

Field Summary

Modifier and TypeField and Description
public static final Span
NOOP

Hides io.micrometer.tracing.SpanCustomizer.NOOP.

A noop implementation.

Method Summary

Modifier and TypeMethod and Description
public void
abandon()

Ends the span.

public TraceContext

Returns:

TraceContext corresponding to this span.
context
()

public void
end()

Ends the span.

public void
end(long
timestamp
time
,
TimeUnit
time unit of the timestamp
timeUnit
)

Ends the span.

public Span

Returns:

this span
error
(Throwable
to record
throwable
)

Records an exception for this span.

public Span

Returns:

this span
event
(String
event name to set on the span
value
)

Redeclares io.micrometer.tracing.SpanCustomizer.event.

Sets an event on this span.
public Span

Returns:

this span
event
(String
event name to set on the span
value
,
long
timestamp of the event
time
,
TimeUnit
timestamp's time unit
timeUnit
)

Sets an event on this span.

public boolean

Returns:

true when no recording is done and nothing is reported to an external system. However, this span should still be injected into outgoing requests. Use this flag to avoid performing expensive computation.
isNoop
()

public Span

Returns:

this span
name
(String
name to set on the span
name
)

Redeclares io.micrometer.tracing.SpanCustomizer.name.

Sets a name on this span.
public Span

Returns:

this span
remoteIpAndPort
(String
remote ip
ip
,
int
remote port
port
)

Sets the remote url on the span.

public Span

Returns:

this span
remoteServiceName
(String
remote service name
remoteServiceName
)

Sets the remote service name for the span.

public Span

Returns:

this span
start
()

Starts this span.

public Span

Returns:

this span
tag
(String
tag key
key
,
String
tag value
value
)

Redeclares io.micrometer.tracing.SpanCustomizer.tag.

Sets a tag on this span.
public default Span

Returns:

this span
tag
(String
tag key
key
,
long
tag value
value
)

Overrides default io.micrometer.tracing.SpanCustomizer.tag.

Sets a tag on this span.
public default Span

Returns:

this span
tag
(String
tag key
key
,
double
tag value
value
)

Overrides default io.micrometer.tracing.SpanCustomizer.tag.

Sets a tag on this span.
public default Span

Returns:

this span
tag
(String
tag key
key
,
boolean
tag value
value
)

Overrides default io.micrometer.tracing.SpanCustomizer.tag.

Sets a tag on this span.

Field Detail

NOOPback to summary
public static final Span NOOP

Hides io.micrometer.tracing.SpanCustomizer.NOOP.

A noop implementation.

Method Detail

abandonback to summary
public void abandon()

Ends the span. The span gets stopped but does not get recorded.

contextback to summary
public TraceContext context()
Returns:TraceContext

TraceContext corresponding to this span.

endback to summary
public void end()

Ends the span. The span gets stopped and recorded if not noop.

endback to summary
public void end(long time, TimeUnit timeUnit)

Ends the span. The span gets stopped and recorded if not noop.

Parameters
time:long

timestamp

timeUnit:TimeUnit

time unit of the timestamp

errorback to summary
public Span error(Throwable throwable)

Records an exception for this span.

Parameters
throwable:Throwable

to record

Returns:Span

this span

eventback to summary
public Span event(String value)

Redeclares io.micrometer.tracing.SpanCustomizer.event.

Sets an event on this span.

Parameters
value:String

event name to set on the span

Returns:Span

this span

eventback to summary
public Span event(String value, long time, TimeUnit timeUnit)

Sets an event on this span.

Parameters
value:String

event name to set on the span

time:long

timestamp of the event

timeUnit:TimeUnit

timestamp's time unit

Returns:Span

this span

isNoopback to summary
public boolean isNoop()
Returns:boolean

true when no recording is done and nothing is reported to an external system. However, this span should still be injected into outgoing requests. Use this flag to avoid performing expensive computation.

nameback to summary
public Span name(String name)

Redeclares io.micrometer.tracing.SpanCustomizer.name.

Sets a name on this span.

Parameters
name:String

name to set on the span

Returns:Span

this span

remoteIpAndPortback to summary
public Span remoteIpAndPort(String ip, int port)

Sets the remote url on the span.

Parameters
ip:String

remote ip

port:int

remote port

Returns:Span

this span

Since
1.0.0
remoteServiceNameback to summary
public Span remoteServiceName(String remoteServiceName)

Sets the remote service name for the span.

Parameters
remoteServiceName:String

remote service name

Returns:Span

this span

startback to summary
public Span start()

Starts this span.

Returns:Span

this span

tagback to summary
public Span tag(String key, String value)

Redeclares io.micrometer.tracing.SpanCustomizer.tag.

Sets a tag on this span.

Parameters
key:String

tag key

value:String

tag value

Returns:Span

this span

tagback to summary
public default Span tag(String key, long value)

Overrides default io.micrometer.tracing.SpanCustomizer.tag.

Sets a tag on this span.

Parameters
key:String

tag key

value:long

tag value

Returns:Span

this span

tagback to summary
public default Span tag(String key, double value)

Overrides default io.micrometer.tracing.SpanCustomizer.tag.

Sets a tag on this span.

Parameters
key:String

tag key

value:double

tag value

Returns:Span

this span

tagback to summary
public default Span tag(String key, boolean value)

Overrides default io.micrometer.tracing.SpanCustomizer.tag.

Sets a tag on this span.

Parameters
key:String

tag key

value:boolean

tag value

Returns:Span

this span

io.micrometer.tracing back to summary

public Interface Span.Builder


In some cases (e.g. when dealing with Propagator#extract(Object, Propagator.Getter)'s we want to create a span that has not yet been started, yet it's heavily configurable (some options are not possible to be set when a span has already been started). We can achieve that by using a builder.

Inspired by OpenZipkin Brave and OpenTelemetry API.

Field Summary

Modifier and TypeField and Description
public static final Span.Builder
NOOP

A noop implementation.

Method Summary

Modifier and TypeMethod and Description
public Span.Builder

Returns:

this
error
(Throwable
error to set
throwable
)

Sets an error on the span.

public Span.Builder

Returns:

this
event
(String
event value
value
)

Sets an event on the span.

public Span.Builder

Returns:

this
kind
(Span.Kind
kind of the span
spanKind
)

Sets the kind on the span.

public Span.Builder

Returns:

this
name
(String
span name
name
)

Sets the name of the span.

public Span.Builder

Returns:

this
remoteIpAndPort
(String
remote service ip
ip
,
int
remote service port
port
)

Sets the remote URL for the span.

public Span.Builder

Returns:

this
remoteServiceName
(String
remote service name
remoteServiceName
)

Sets the remote service name for the span.

public Span.Builder

Returns:

this
setNoParent
()

Sets no parent of the built span.

public Span.Builder

Returns:

this
setParent
(TraceContext
parent's context
context
)

Sets the parent of the built span.

public Span

Returns:

started span
start
()

Builds and starts the span.

public Span.Builder

Returns:

this
startTimestamp
(long
start timestamp
startTimestamp
,
TimeUnit
start time unit
unit
)

Sets start timestamp.

public Span.Builder

Returns:

this
tag
(String
tag key
key
,
String
tag value
value
)

Sets a tag on the span.

public default Span.Builder

Returns:

this
tag
(String
tag key
key
,
long
tag value
value
)

Sets a tag on the span.

public default Span.Builder

Returns:

this
tag
(String
tag key
key
,
double
tag value
value
)

Sets a tag on the span.

public default Span.Builder

Returns:

this
tag
(String
tag key
key
,
boolean
tag value
value
)

Sets a tag on the span.

Field Detail

NOOPback to summary
public static final Span.Builder NOOP

A noop implementation.

Method Detail

errorback to summary
public Span.Builder error(Throwable throwable)

Sets an error on the span.

Parameters
throwable:Throwable

error to set

Returns:Span.Builder

this

eventback to summary
public Span.Builder event(String value)

Sets an event on the span.

Parameters
value:String

event value

Returns:Span.Builder

this

kindback to summary
public Span.Builder kind(Span.Kind spanKind)

Sets the kind on the span.

Parameters
spanKind:Span.Kind

kind of the span

Returns:Span.Builder

this

nameback to summary
public Span.Builder name(String name)

Sets the name of the span.

Parameters
name:String

span name

Returns:Span.Builder

this

remoteIpAndPortback to summary
public Span.Builder remoteIpAndPort(String ip, int port)

Sets the remote URL for the span.

Parameters
ip:String

remote service ip

port:int

remote service port

Returns:Span.Builder

this

remoteServiceNameback to summary
public Span.Builder remoteServiceName(String remoteServiceName)

Sets the remote service name for the span.

Parameters
remoteServiceName:String

remote service name

Returns:Span.Builder

this

setNoParentback to summary
public Span.Builder setNoParent()

Sets no parent of the built span.

Returns:Span.Builder

this

setParentback to summary
public Span.Builder setParent(TraceContext context)

Sets the parent of the built span.

Parameters
context:TraceContext

parent's context

Returns:Span.Builder

this

startback to summary
public Span start()

Builds and starts the span.

Returns:Span

started span

startTimestampback to summary
public Span.Builder startTimestamp(long startTimestamp, TimeUnit unit)

Sets start timestamp.

Parameters
startTimestamp:long

start timestamp

unit:TimeUnit

start time unit

Returns:Span.Builder

this

tagback to summary
public Span.Builder tag(String key, String value)

Sets a tag on the span.

Parameters
key:String

tag key

value:String

tag value

Returns:Span.Builder

this

tagback to summary
public default Span.Builder tag(String key, long value)

Sets a tag on the span.

Parameters
key:String

tag key

value:long

tag value

Returns:Span.Builder

this

tagback to summary
public default Span.Builder tag(String key, double value)

Sets a tag on the span.

Parameters
key:String

tag key

value:double

tag value

Returns:Span.Builder

this

tagback to summary
public default Span.Builder tag(String key, boolean value)

Sets a tag on the span.

Parameters
key:String

tag key

value:boolean

tag value

Returns:Span.Builder

this

io.micrometer.tracing back to summary

public final Enum Span.Kind

extends Enum<Span.Kind>
Class Inheritance

Type of span. Can be used to specify additional relationships between spans in addition to a parent/child relationship.

Documentation of the enum taken from OpenTelemetry.

Field Summary

Modifier and TypeField and Description
public static final Span.Kind
CLIENT

Indicates that the span covers the client-side wrapper around an RPC or other remote request.

public static final Span.Kind
CONSUMER

Indicates that the span describes consumer receiving a message from a broker.

public static final Span.Kind
PRODUCER

Indicates that the span describes producer sending a message to a broker.

public static final Span.Kind
SERVER

Indicates that the span covers server-side handling of an RPC or other remote request.

Constructor Summary

AccessConstructor and Description
private
Kind()

Method Summary

Modifier and TypeMethod and Description
public static Span.Kind
public static Span.Kind[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CLIENTback to summary
public static final Span.Kind CLIENT

Indicates that the span covers the client-side wrapper around an RPC or other remote request.

CONSUMERback to summary
public static final Span.Kind CONSUMER

Indicates that the span describes consumer receiving a message from a broker. Unlike client and server, there is no direct critical path latency relationship between producer and consumer spans.

PRODUCERback to summary
public static final Span.Kind PRODUCER

Indicates that the span describes producer sending a message to a broker. Unlike client and server, there is no direct critical path latency relationship between producer and consumer spans.

SERVERback to summary
public static final Span.Kind SERVER

Indicates that the span covers server-side handling of an RPC or other remote request.

Constructor Detail

Kindback to summary
private Kind()

Method Detail

valueOfback to summary
public static Span.Kind valueOf(String name)
valuesback to summary
public static Span.Kind[] values()