AutoCloseable
public class TracerSpan extends Span
Tracer
.
It overrides all methods of Span, and then simply delegates method invocations to the Span instance that it wraps.
The only added functionality is in close()
, which is used to notify the Tracer of the TracerSpan being
closed prior to invoking close on the delegate Span. This ensures that the TracerSpan can detach itself from the
Tracer context and perform any necessary cleanup.
Tracer
's javadoc for details.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() |
|
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() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getNoopInstance
public Span addField(String key, Object value)
Span
public Span addFields(Map<String,?> fieldsToAdd)
Span
public Span addTraceField(String key, Object value)
Span
addTraceField
in class Span
key
- of the field.value
- of the field.public Span addTraceFields(Map<String,?> traceFieldsToAdd)
Span
addTraceFields
in class Span
traceFieldsToAdd
- to add.public Span markStart()
Span
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)
Span
public String getParentSpanId()
getParentSpanId
in class Span
public String getTraceId()
getTraceId
in class Span
public String getDataset()
getDataset
in class Span
public String getSpanName()
getSpanName
in class Span
public String getServiceName()
getServiceName
in class Span
public Map<String,Object> getFields()
getFields
in class Span
Span.fields
public Map<String,Object> getTraceFields()
getTraceFields
in class Span
Span.traceFields
public PropagationContext getTraceContext()
getTraceContext
in class Span
public double elapsedTimeMs()
elapsedTimeMs
in class Span
Span.markStart()
public long getTimestamp()
getTimestamp
in class Span
Span.markStart()
public long getStartTime()
getStartTime
in class Span
Span.markStart()
public void close()
Span
Event
to Honeycomb and perform any necessary clean up in
the process. Overrides of Span.closeInternal()
contain the logic to do this.
The Span's duration is measured upon calling this method (as per Span.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
close
in class Span
protected void closeInternal()
Span
closeInternal
in class Span
Copyright © 2019–2020 Honeycomb. All rights reserved.