Package io.sentry
Class Span
java.lang.Object
io.sentry.Span
- All Implemented Interfaces:
ISpan
-
Constructor Summary
ConstructorDescriptionSpan
(@NotNull TransactionContext context, @NotNull SentryTracer sentryTracer, @NotNull IHub hub, @Nullable SentryDate startTimestamp, @NotNull SpanOptions options) -
Method Summary
Modifier and TypeMethodDescriptionvoid
finish()
Sets span timestamp marking this span as finished.void
finish
(@Nullable SpanStatus status) Sets span timestamp marking this span as finished.void
finish
(@Nullable SpanStatus status, @Nullable SentryDate timestamp) Used to finish unfinished spans bySentryTracer
.getData()
@Nullable Object
Returns extra data from span or transaction.@Nullable String
Returns the span description.@Nullable SentryDate
Returns the end date of this span or transaction.@NotNull LocalMetricsAggregator
Returns the metrics aggregator for this span.@NotNull Map<String,
MeasurementValue> @NotNull String
Returns the span operation.@Nullable SpanId
@Nullable TracesSamplingDecision
@NotNull SpanContext
Gets the span context.@NotNull SpanId
@NotNull SentryDate
Returns the start date of this span or transaction.@Nullable SpanStatus
Returns the span status@Nullable String
getTags()
@Nullable Throwable
Gets the throwable that was thrown during the execution of the span.@NotNull SentryId
boolean
Returns if span has finished.boolean
isNoOp()
Whether this span instance is a NOOP that doesn't collect information@Nullable Boolean
@Nullable Boolean
void
Sets extra data on span or transaction.void
setDescription
(@Nullable String description) Sets span description.void
setMeasurement
(@NotNull String name, @NotNull Number value) Set a measurement without unit.void
setMeasurement
(@NotNull String name, @NotNull Number value, @NotNull MeasurementUnit unit) Set a measurement with specific unit.void
setOperation
(@NotNull String operation) Sets span operation.void
setStatus
(@Nullable SpanStatus status) Sets span status.void
Sets the tag on span or transaction.void
setThrowable
(@Nullable Throwable throwable) Sets the throwable that was thrown during the execution of the span.@NotNull ISpan
startChild
(@NotNull String operation) Starts a child Span.@NotNull ISpan
startChild
(@NotNull String operation, @Nullable String description) Starts a child Span.@NotNull ISpan
startChild
(@NotNull String operation, @Nullable String description, @NotNull SpanOptions spanOptions) @NotNull ISpan
startChild
(@NotNull String operation, @Nullable String description, @Nullable SentryDate timestamp, @NotNull Instrumenter instrumenter) @NotNull ISpan
startChild
(@NotNull String operation, @Nullable String description, @Nullable SentryDate timestamp, @NotNull Instrumenter instrumenter, @NotNull SpanOptions spanOptions) @Nullable BaggageHeader
toBaggageHeader
(@Nullable List<String> thirdPartyBaggageHeaders) Returns the baggage that can be sent as "baggage" header.@NotNull SentryTraceHeader
Returns the trace information that could be sent as a sentry-trace header.@Nullable TraceContext
Returns the trace context.boolean
updateEndDate
(@NotNull SentryDate date) Updates the end date of the span.
-
Constructor Details
-
Span
public Span(@NotNull @NotNull TransactionContext context, @NotNull @NotNull SentryTracer sentryTracer, @NotNull @NotNull IHub hub, @Nullable @Nullable SentryDate startTimestamp, @NotNull @NotNull SpanOptions options)
-
-
Method Details
-
getStartDate
Description copied from interface:ISpan
Returns the start date of this span or transaction.- Specified by:
getStartDate
in interfaceISpan
- Returns:
- the start date
-
getFinishDate
Description copied from interface:ISpan
Returns the end date of this span or transaction.- Specified by:
getFinishDate
in interfaceISpan
- Returns:
- the end date
-
startChild
Description copied from interface:ISpan
Starts a child Span.- Specified by:
startChild
in interfaceISpan
- Parameters:
operation
- - new span operation name- Returns:
- a new transaction span
-
startChild
@NotNull public @NotNull ISpan startChild(@NotNull @NotNull String operation, @Nullable @Nullable String description, @Nullable @Nullable SentryDate timestamp, @NotNull @NotNull Instrumenter instrumenter, @NotNull @NotNull SpanOptions spanOptions) - Specified by:
startChild
in interfaceISpan
-
startChild
@NotNull public @NotNull ISpan startChild(@NotNull @NotNull String operation, @Nullable @Nullable String description) Description copied from interface:ISpan
Starts a child Span.- Specified by:
startChild
in interfaceISpan
- Parameters:
operation
- - new span operation namedescription
- - new span description name- Returns:
- a new transaction span
-
startChild
@NotNull public @NotNull ISpan startChild(@NotNull @NotNull String operation, @Nullable @Nullable String description, @NotNull @NotNull SpanOptions spanOptions) - Specified by:
startChild
in interfaceISpan
-
startChild
@NotNull public @NotNull ISpan startChild(@NotNull @NotNull String operation, @Nullable @Nullable String description, @Nullable @Nullable SentryDate timestamp, @NotNull @NotNull Instrumenter instrumenter) - Specified by:
startChild
in interfaceISpan
-
toSentryTrace
Description copied from interface:ISpan
Returns the trace information that could be sent as a sentry-trace header.- Specified by:
toSentryTrace
in interfaceISpan
- Returns:
- SentryTraceHeader.
-
traceContext
Description copied from interface:ISpan
Returns the trace context.- Specified by:
traceContext
in interfaceISpan
- Returns:
- a trace context or
null
ifSentryOptions.isTraceSampling()
is disabled.
-
toBaggageHeader
@Nullable public @Nullable BaggageHeader toBaggageHeader(@Nullable @Nullable List<String> thirdPartyBaggageHeaders) Description copied from interface:ISpan
Returns the baggage that can be sent as "baggage" header.- Specified by:
toBaggageHeader
in interfaceISpan
- Returns:
- BaggageHeader or
null
ifSentryOptions.isTraceSampling()
is disabled.
-
finish
public void finish()Description copied from interface:ISpan
Sets span timestamp marking this span as finished. -
finish
Description copied from interface:ISpan
Sets span timestamp marking this span as finished. -
finish
Used to finish unfinished spans bySentryTracer
. -
setOperation
Description copied from interface:ISpan
Sets span operation.- Specified by:
setOperation
in interfaceISpan
- Parameters:
operation
- - the operation
-
getOperation
Description copied from interface:ISpan
Returns the span operation.- Specified by:
getOperation
in interfaceISpan
- Returns:
- the operation
-
setDescription
Description copied from interface:ISpan
Sets span description.- Specified by:
setDescription
in interfaceISpan
- Parameters:
description
- - the description.
-
getDescription
Description copied from interface:ISpan
Returns the span description.- Specified by:
getDescription
in interfaceISpan
- Returns:
- the description
-
setStatus
Description copied from interface:ISpan
Sets span status. -
getStatus
Description copied from interface:ISpan
Returns the span status -
getSpanContext
Description copied from interface:ISpan
Gets the span context.- Specified by:
getSpanContext
in interfaceISpan
- Returns:
- the span context
-
setTag
Description copied from interface:ISpan
Sets the tag on span or transaction. -
getTag
-
isFinished
public boolean isFinished()Description copied from interface:ISpan
Returns if span has finished.- Specified by:
isFinished
in interfaceISpan
- Returns:
- if span has finished.
-
getData
-
isSampled
-
isProfileSampled
-
getSamplingDecision
-
setThrowable
Description copied from interface:ISpan
Sets the throwable that was thrown during the execution of the span.- Specified by:
setThrowable
in interfaceISpan
- Parameters:
throwable
- - the throwable.
-
getThrowable
Description copied from interface:ISpan
Gets the throwable that was thrown during the execution of the span.- Specified by:
getThrowable
in interfaceISpan
- Returns:
- throwable or
null
if none
-
getTraceId
-
getSpanId
-
getParentSpanId
-
getTags
-
setData
Description copied from interface:ISpan
Sets extra data on span or transaction. -
getData
Description copied from interface:ISpan
Returns extra data from span or transaction. -
setMeasurement
Description copied from interface:ISpan
Set a measurement without unit. When setting the measurement without the unit, no formatting will be applied to the measurement value in the Sentry product, and the value will be shown as is.NOTE: Setting a measurement with the same name on the same transaction multiple times only keeps the last value.
- Specified by:
setMeasurement
in interfaceISpan
- Parameters:
name
- the name of the measurementvalue
- the value of the measurement
-
setMeasurement
public void setMeasurement(@NotNull @NotNull String name, @NotNull @NotNull Number value, @NotNull @NotNull MeasurementUnit unit) Description copied from interface:ISpan
Set a measurement with specific unit.NOTE: Setting a measurement with the same name on the same transaction multiple times only keeps the last value.
- Specified by:
setMeasurement
in interfaceISpan
- Parameters:
name
- the name of the measurementvalue
- the value of the measurementunit
- the unit the value is measured in
-
getMeasurements
-
updateEndDate
Description copied from interface:ISpan
Updates the end date of the span. Note: This will only update the end date if the span is already finished.- Specified by:
updateEndDate
in interfaceISpan
- Parameters:
date
- the end date to set- Returns:
- true if the end date was updated, false otherwise
-
isNoOp
public boolean isNoOp()Description copied from interface:ISpan
Whether this span instance is a NOOP that doesn't collect information -
getLocalMetricsAggregator
Description copied from interface:ISpan
Returns the metrics aggregator for this span.- Specified by:
getLocalMetricsAggregator
in interfaceISpan
- Returns:
- the metrics aggregator
-