-
public interface DatadogSpanRepresents an interface for a Datadog span, which encapsulates information about a single span within a trace. This includes span metadata, error handling, timing, and tag/metric management.
-
-
Method Summary
Modifier and Type Method Description abstract DatadogSpanContextcontext()Retrieves the context associated with this Datadog span. abstract Unitfinish()Marks the end of this span and captures its duration. abstract Unitfinish(Long finishMicros)Marks the end of this span and sets its finish time. abstract Unitdrop()Marks the current span for removal, indicating it should no longer be processed or considered active. abstract UnitsetErrorMessage(String message)Sets the error message for the current span. abstract UnitaddThrowable(Throwable throwable)Associates a throwable with the current span, marking it as an error and capturing the provided throwable for additional context. abstract UnitsetTag(String tag, String value)Associates a tag with the specified value for the current span. abstract UnitsetTag(String tag, Boolean value)Associates a tag with a boolean value for the current span. abstract UnitsetTag(String tag, Number value)Associates a tag with a numerical value for the current span. abstract UnitsetTag(String tag, Object value)Associates a tag with a specified value for the current span. abstract ObjectgetTag(String tag)Retrieves the value associated with the specified tag for the current span. abstract UnitsetMetric(String key, Integer value)Sets a metric for the current span with the specified key and value. abstract UnitlogThrowable(Throwable throwable)Logs a throwable and associates it with the current DatadogSpan. abstract UnitlogErrorMessage(String message)Logs an error message and associates it with the current DatadogSpan. abstract UnitlogMessage(String message)Logs a message associated with the current DatadogSpan. abstract UnitlogAttributes(Map<String, Object> attributes)Logs a set of attributes and associates them with the current DatadogSpan. abstract BooleangetIsError()Indicates whether the current span is marked as an error. abstract UnitsetIsError(Boolean isError)Indicates whether the current span is marked as an error. abstract BooleangetIsRootSpan()Indicates whether the current span is the root span in a trace. abstract IntegergetSamplingPriority()Represents the sampling priority of the span, which determines if the span should be included or excluded from trace collection and analysis. abstract DatadogTraceIdgetTraceId()Represents the unique identifier for a trace in the Datadog tracing system. abstract LonggetParentSpanId()Represents the parent span's unique identifier in a trace. abstract StringgetResourceName()Represents the name of the resource associated with the span. abstract UnitsetResourceName(String resourceName)Represents the name of the resource associated with the span. abstract StringgetServiceName()Defines the name of the service associated with this span. abstract UnitsetServiceName(String serviceName)Defines the name of the service associated with this span. abstract StringgetOperationName()The name of the operation represented by the span. abstract UnitsetOperationName(String operationName)The name of the operation represented by the span. abstract LonggetDurationNano()Represents the duration of a span in nanoseconds. abstract LonggetStartTimeNanos()Represents the start time of the span in nanoseconds. abstract DatadogSpangetLocalRootSpan()Refers to the local root span within a trace hierarchy. -
-
Method Detail
-
context
abstract DatadogSpanContext context()
Retrieves the context associated with this Datadog span.
-
finish
abstract Unit finish()
Marks the end of this span and captures its duration. This method should be called once the operation represented by the span is completed to ensure proper timing and resource tracking.
-
finish
abstract Unit finish(Long finishMicros)
Marks the end of this span and sets its finish time. This method should be used when the operation represented by the span is completed, and the exact finish timestamp in microseconds needs to be explicitly provided.
- Parameters:
finishMicros- The finish time of the span, provided in microseconds since the epoch.
-
drop
abstract Unit drop()
Marks the current span for removal, indicating it should no longer be processed or considered active. This method can be used to discard spans that are no longer relevant or should not be reported.
-
setErrorMessage
abstract Unit setErrorMessage(String message)
Sets the error message for the current span. This message provides a description of the error that occurred during the span's operation.
- Parameters:
message- The error message to be associated with the span.
-
addThrowable
abstract Unit addThrowable(Throwable throwable)
Associates a throwable with the current span, marking it as an error and capturing the provided throwable for additional context.
- Parameters:
throwable- The throwable to associate with the current span.
-
setTag
abstract Unit setTag(String tag, String value)
Associates a tag with the specified value for the current span.
- Parameters:
tag- The name of the tag to associate with the span.value- The value to associate with the specified tag.
-
setTag
abstract Unit setTag(String tag, Boolean value)
Associates a tag with a boolean value for the current span.
- Parameters:
tag- The name of the tag to associate with the span.value- The boolean value to associate with the specified tag.
-
setTag
abstract Unit setTag(String tag, Number value)
Associates a tag with a numerical value for the current span.
- Parameters:
tag- The name of the tag to associate with the span.value- The numerical value to associate with the specified tag.
-
setTag
abstract Unit setTag(String tag, Object value)
Associates a tag with a specified value for the current span.
- Parameters:
tag- The name of the tag to associate with the span.value- The value to associate with the specified tag.
-
getTag
abstract Object getTag(String tag)
Retrieves the value associated with the specified tag for the current span.
- Parameters:
tag- The name of the tag whose value is to be retrieved.
-
setMetric
abstract Unit setMetric(String key, Integer value)
Sets a metric for the current span with the specified key and value.
- Parameters:
key- The name of the metric to be associated with the span.value- The value of the metric to be set for the specified key.
-
logThrowable
abstract Unit logThrowable(Throwable throwable)
Logs a throwable and associates it with the current DatadogSpan.
- Parameters:
throwable- The throwable containing error details to be logged with the span.
-
logErrorMessage
abstract Unit logErrorMessage(String message)
Logs an error message and associates it with the current DatadogSpan.
- Parameters:
message- The error message to log.
-
logMessage
abstract Unit logMessage(String message)
Logs a message associated with the current DatadogSpan.
- Parameters:
message- The log message to be associated with the span.
-
logAttributes
abstract Unit logAttributes(Map<String, Object> attributes)
Logs a set of attributes and associates them with the current DatadogSpan.
- Parameters:
attributes- A map containing key-value pairs of attributes to be logged.
-
getIsError
abstract Boolean getIsError()
Indicates whether the current span is marked as an error.
-
setIsError
abstract Unit setIsError(Boolean isError)
Indicates whether the current span is marked as an error.
-
getIsRootSpan
abstract Boolean getIsRootSpan()
Indicates whether the current span is the root span in a trace.
-
getSamplingPriority
abstract Integer getSamplingPriority()
Represents the sampling priority of the span, which determines if the span should be included or excluded from trace collection and analysis.
-
getTraceId
abstract DatadogTraceId getTraceId()
Represents the unique identifier for a trace in the Datadog tracing system.
-
getParentSpanId
abstract Long getParentSpanId()
Represents the parent span's unique identifier in a trace.
-
getResourceName
abstract String getResourceName()
Represents the name of the resource associated with the span.
-
setResourceName
abstract Unit setResourceName(String resourceName)
Represents the name of the resource associated with the span.
-
getServiceName
abstract String getServiceName()
Defines the name of the service associated with this span.
-
setServiceName
abstract Unit setServiceName(String serviceName)
Defines the name of the service associated with this span.
-
getOperationName
abstract String getOperationName()
The name of the operation represented by the span.
-
setOperationName
abstract Unit setOperationName(String operationName)
The name of the operation represented by the span.
-
getDurationNano
abstract Long getDurationNano()
Represents the duration of a span in nanoseconds.
-
getStartTimeNanos
abstract Long getStartTimeNanos()
Represents the start time of the span in nanoseconds.
-
getLocalRootSpan
abstract DatadogSpan getLocalRootSpan()
Refers to the local root span within a trace hierarchy.
-
-
-
-