AutoCloseable
SendingSpan
, TracerSpan
public class Span extends Object implements AutoCloseable
Modifier | Constructor | Description |
---|---|---|
protected |
Span() |
Constructor that initialises this Span with "noop" data and sets the noop flag to true.
|
|
Span(String spanName,
String serviceName,
String spanId,
PropagationContext context,
Map<String,?> fields,
io.honeycomb.libhoney.transport.batch.ClockProvider clock) |
Constructor that initialises the base Span data.
|
Modifier and Type | Method | Description |
---|---|---|
Span |
addField(String key,
Object value) |
Add a field to the Span.
|
Span |
addFields(Map<String,?> fieldsToAdd) |
Add a fields to the Span.
|
Span |
addTraceField(String key,
Object value) |
Add a trace field to the Span.
|
Span |
addTraceFields(Map<String,?> traceFieldsToAdd) |
Add trace fields to the Span.
|
void |
close() |
Closes this span in order to submit it as an
Event to Honeycomb and perform any necessary clean up in
the process. |
protected void |
closeInternal() |
Subclasses should override this to implement the mechanism
|
double |
elapsedTimeMs() |
|
String |
getDataset() |
|
Map<String,Object> |
getFields() |
|
static Span |
getNoopInstance() |
|
String |
getParentSpanId() |
|
String |
getServiceName() |
|
String |
getSpanId() |
|
String |
getSpanName() |
|
long |
getStartTime() |
|
long |
getTimestamp() |
|
PropagationContext |
getTraceContext() |
|
Map<String,Object> |
getTraceFields() |
|
String |
getTraceId() |
|
boolean |
isNoop() |
|
Span |
markStart() |
Reset the Span's timer.
|
Span |
markStart(long timestamp,
long startTime) |
Sets the times with the specified values - useful when copying Spans.
|
String |
toString() |
public Span(String spanName, String serviceName, String spanId, PropagationContext context, Map<String,?> fields, io.honeycomb.libhoney.transport.batch.ClockProvider clock)
markStart()
immediately, which may be reset by client code by calling it any other point.spanName
- must not be empty.serviceName
- must not be empty.spanId
- must not be empty.context
- containing data about the trace - must not be null, and it must contain a traceId.fields
- may be null or empty.clock
- must not be null.protected Span()
noop
public static Span getNoopInstance()
public boolean isNoop()
public Span addField(String key, Object value)
key
- of the field.value
- of the field.public Span addFields(Map<String,?> fieldsToAdd)
fieldsToAdd
- to add.public Span addTraceField(String key, Object value)
key
- of the field.value
- of the field.public Span addTraceFields(Map<String,?> traceFieldsToAdd)
traceFieldsToAdd
- to add.public Span markStart()
The Span always starts the timer upon construction of the instance. However, if the operation covered by the Span starts later you can reset its timer with this (e.g. for async use cases).
public Span markStart(long timestamp, long startTime)
timestamp
- (millis since the epoch)startTime
- start time (monotonic JVM time)public String getParentSpanId()
public String getTraceId()
public String getDataset()
public String getSpanId()
public String getSpanName()
public String getServiceName()
public Map<String,Object> getFields()
fields
public Map<String,Object> getTraceFields()
traceFields
public PropagationContext getTraceContext()
public double elapsedTimeMs()
markStart()
public long getTimestamp()
markStart()
public long getStartTime()
markStart()
public void close()
Event
to Honeycomb and perform any necessary clean up in
the process. Overrides of closeInternal()
contain the logic to do this.
The Span's duration is measured upon calling this method (as per elapsedTimeMs()
).
In order to avoid clashes, because of multiple events with the same span_id
being submitted, this method
ensures that it is only called once and ignores multiple invocations. However, it does not use any
synchronization to ensure this and is therefore not thread safe.
This uses method allows Span
to be used with try-with-resources statements.
close
in interface AutoCloseable
protected void closeInternal()
Copyright © 2019–2020 Honeycomb. All rights reserved.