Package io.sentry
Interface ISpan
- All Known Subinterfaces:
ITransaction
- All Known Implementing Classes:
NoOpSpan
,NoOpTransaction
,SentryTracer
,Span
public interface ISpan
Represents performance monitoring Span.
-
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) Sets span timestamp marking this span as finished.@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.@Nullable LocalMetricsAggregator
Returns the metrics aggregator for this span.@NotNull String
Returns the span operation.@NotNull SpanContext
Gets the span context.@NotNull SentryDate
Returns the start date of this span or transaction.@Nullable SpanStatus
Returns the span status@Nullable String
@Nullable Throwable
Gets the throwable that was thrown during the execution of the span.boolean
Returns if span has finished.boolean
isNoOp()
Whether this span instance is a NOOP that doesn't collect informationvoid
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.
-
Method Details
-
startChild
Starts a child Span.- Parameters:
operation
- - new span operation name- Returns:
- a new transaction span
-
startChild
@Internal @NotNull @NotNull ISpan startChild(@NotNull @NotNull String operation, @Nullable @Nullable String description, @NotNull @NotNull SpanOptions spanOptions) -
startChild
@Internal @NotNull @NotNull ISpan startChild(@NotNull @NotNull String operation, @Nullable @Nullable String description, @Nullable @Nullable SentryDate timestamp, @NotNull @NotNull Instrumenter instrumenter) -
startChild
@Internal @NotNull @NotNull ISpan startChild(@NotNull @NotNull String operation, @Nullable @Nullable String description, @Nullable @Nullable SentryDate timestamp, @NotNull @NotNull Instrumenter instrumenter, @NotNull @NotNull SpanOptions spanOptions) -
startChild
@NotNull @NotNull ISpan startChild(@NotNull @NotNull String operation, @Nullable @Nullable String description) Starts a child Span.- Parameters:
operation
- - new span operation namedescription
- - new span description name- Returns:
- a new transaction span
-
toSentryTrace
Returns the trace information that could be sent as a sentry-trace header.- Returns:
- SentryTraceHeader.
-
traceContext
Returns the trace context.- Returns:
- a trace context or
null
ifSentryOptions.isTraceSampling()
is disabled.
-
toBaggageHeader
@Nullable @Experimental @Nullable BaggageHeader toBaggageHeader(@Nullable @Nullable List<String> thirdPartyBaggageHeaders) Returns the baggage that can be sent as "baggage" header.- Returns:
- BaggageHeader or
null
ifSentryOptions.isTraceSampling()
is disabled.
-
finish
void finish()Sets span timestamp marking this span as finished. -
finish
Sets span timestamp marking this span as finished.- Parameters:
status
- - the status
-
finish
Sets span timestamp marking this span as finished.- Parameters:
status
- - the statustimestamp
- - the end timestamp
-
setOperation
Sets span operation.- Parameters:
operation
- - the operation
-
getOperation
Returns the span operation.- Returns:
- the operation
-
setDescription
Sets span description.- Parameters:
description
- - the description.
-
getDescription
Returns the span description.- Returns:
- the description
-
setStatus
Sets span status.- Parameters:
status
- - the status.
-
getStatus
Returns the span status- Returns:
- the status
-
setThrowable
Sets the throwable that was thrown during the execution of the span.- Parameters:
throwable
- - the throwable.
-
getThrowable
Gets the throwable that was thrown during the execution of the span.- Returns:
- throwable or
null
if none
-
getSpanContext
Gets the span context.- Returns:
- the span context
-
setTag
Sets the tag on span or transaction.- Parameters:
key
- the tag keyvalue
- the tag value
-
getTag
-
isFinished
boolean isFinished()Returns if span has finished.- Returns:
- if span has finished.
-
setData
Sets extra data on span or transaction.- Parameters:
key
- the data keyvalue
- the data value
-
getData
Returns extra data from span or transaction.- Returns:
- the data
-
setMeasurement
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.
- Parameters:
name
- the name of the measurementvalue
- the value of the measurement
-
setMeasurement
void setMeasurement(@NotNull @NotNull String name, @NotNull @NotNull Number value, @NotNull @NotNull MeasurementUnit unit) 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.
- Parameters:
name
- the name of the measurementvalue
- the value of the measurementunit
- the unit the value is measured in
-
updateEndDate
Updates the end date of the span. Note: This will only update the end date if the span is already finished.- Parameters:
date
- the end date to set- Returns:
- true if the end date was updated, false otherwise
-
getStartDate
Returns the start date of this span or transaction.- Returns:
- the start date
-
getFinishDate
Returns the end date of this span or transaction.- Returns:
- the end date
-
isNoOp
@Internal boolean isNoOp()Whether this span instance is a NOOP that doesn't collect information- Returns:
- true if NOOP
-
getLocalMetricsAggregator
Returns the metrics aggregator for this span.- Returns:
- the metrics aggregator
-