Package io.sentry
Class Span
- java.lang.Object
-
- io.sentry.Span
-
-
Constructor Summary
Constructors Constructor Description Span(@NotNull TransactionContext context, @NotNull SentryTracer sentryTracer, @NotNull IHub hub, @Nullable java.util.Date startTimestamp)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
finish()
Sets span timestamp marking this span as finished.void
finish(@Nullable SpanStatus status)
Sets span timestamp marking this span as finished.@NotNull java.util.Map<java.lang.String,java.lang.Object>
getData()
@Nullable java.lang.Object
getData(@NotNull java.lang.String key)
Returns extra data from span or transaction.@Nullable java.lang.String
getDescription()
Returns the span description.@Nullable java.lang.Double
getHighPrecisionTimestamp()
@NotNull java.lang.String
getOperation()
Returns the span operation.@Nullable SpanId
getParentSpanId()
@Nullable TracesSamplingDecision
getSamplingDecision()
@NotNull SpanContext
getSpanContext()
Gets the span context.@NotNull SpanId
getSpanId()
@NotNull java.util.Date
getStartTimestamp()
@Nullable SpanStatus
getStatus()
Returns the span status@Nullable java.lang.String
getTag(@NotNull java.lang.String key)
java.util.Map<java.lang.String,java.lang.String>
getTags()
@Nullable java.lang.Throwable
getThrowable()
Gets the throwable that was thrown during the execution of the span.@Nullable java.lang.Double
getTimestamp()
@NotNull SentryId
getTraceId()
boolean
isFinished()
Returns if span has finished.@Nullable java.lang.Boolean
isProfileSampled()
@Nullable java.lang.Boolean
isSampled()
void
setData(@NotNull java.lang.String key, @NotNull java.lang.Object value)
Sets extra data on span or transaction.void
setDescription(@Nullable java.lang.String description)
Sets span description.void
setMeasurement(@NotNull java.lang.String name, @NotNull java.lang.Number value)
Set a measurement without unit.void
setMeasurement(@NotNull java.lang.String name, @NotNull java.lang.Number value, @NotNull MeasurementUnit unit)
Set a measurement with specific unit.void
setOperation(@NotNull java.lang.String operation)
Sets span operation.void
setStatus(@Nullable SpanStatus status)
Sets span status.void
setTag(@NotNull java.lang.String key, @NotNull java.lang.String value)
Sets the tag on span or transaction.void
setThrowable(@Nullable java.lang.Throwable throwable)
Sets the throwable that was thrown during the execution of the span.@NotNull ISpan
startChild(@NotNull java.lang.String operation)
Starts a child Span.@NotNull ISpan
startChild(@NotNull java.lang.String operation, @Nullable java.lang.String description)
Starts a child Span.@NotNull ISpan
startChild(@NotNull java.lang.String operation, @Nullable java.lang.String description, @Nullable java.util.Date timestamp)
@Nullable BaggageHeader
toBaggageHeader(@Nullable java.util.List<java.lang.String> thirdPartyBaggageHeaders)
Returns the baggage that can be sent as "baggage" header.@NotNull SentryTraceHeader
toSentryTrace()
Returns the trace information that could be sent as a sentry-trace header.@Nullable TraceContext
traceContext()
Returns the trace context.
-
-
-
Constructor Detail
-
Span
@VisibleForTesting public Span(@NotNull @NotNull TransactionContext context, @NotNull @NotNull SentryTracer sentryTracer, @NotNull @NotNull IHub hub, @Nullable @Nullable java.util.Date startTimestamp)
-
-
Method Detail
-
getStartTimestamp
@NotNull public @NotNull java.util.Date getStartTimestamp()
-
getTimestamp
@Nullable public @Nullable java.lang.Double getTimestamp()
-
startChild
@NotNull public @NotNull ISpan startChild(@NotNull @NotNull java.lang.String operation)
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 java.lang.String operation, @Nullable @Nullable java.lang.String description, @Nullable @Nullable java.util.Date timestamp)
- Specified by:
startChild
in interfaceISpan
-
startChild
@NotNull public @NotNull ISpan startChild(@NotNull @NotNull java.lang.String operation, @Nullable @Nullable java.lang.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
-
toSentryTrace
@NotNull public @NotNull SentryTraceHeader 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
@Nullable public @Nullable TraceContext 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 java.util.List<java.lang.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
public void finish(@Nullable @Nullable SpanStatus status)
Description copied from interface:ISpan
Sets span timestamp marking this span as finished.
-
setOperation
public void setOperation(@NotNull @NotNull java.lang.String operation)
Description copied from interface:ISpan
Sets span operation.- Specified by:
setOperation
in interfaceISpan
- Parameters:
operation
- - the operation
-
getOperation
@NotNull public @NotNull java.lang.String getOperation()
Description copied from interface:ISpan
Returns the span operation.- Specified by:
getOperation
in interfaceISpan
- Returns:
- the operation
-
setDescription
public void setDescription(@Nullable @Nullable java.lang.String description)
Description copied from interface:ISpan
Sets span description.- Specified by:
setDescription
in interfaceISpan
- Parameters:
description
- - the description.
-
getDescription
@Nullable public @Nullable java.lang.String getDescription()
Description copied from interface:ISpan
Returns the span description.- Specified by:
getDescription
in interfaceISpan
- Returns:
- the description
-
setStatus
public void setStatus(@Nullable @Nullable SpanStatus status)
Description copied from interface:ISpan
Sets span status.
-
getStatus
@Nullable public @Nullable SpanStatus getStatus()
Description copied from interface:ISpan
Returns the span status
-
getSpanContext
@NotNull public @NotNull SpanContext getSpanContext()
Description copied from interface:ISpan
Gets the span context.- Specified by:
getSpanContext
in interfaceISpan
- Returns:
- the span context
-
setTag
public void setTag(@NotNull @NotNull java.lang.String key, @NotNull @NotNull java.lang.String value)
Description copied from interface:ISpan
Sets the tag on span or transaction.
-
getTag
@Nullable public @Nullable java.lang.String getTag(@NotNull @NotNull java.lang.String key)
-
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
@NotNull public @NotNull java.util.Map<java.lang.String,java.lang.Object> getData()
-
isSampled
@Nullable public @Nullable java.lang.Boolean isSampled()
-
isProfileSampled
@Nullable public @Nullable java.lang.Boolean isProfileSampled()
-
getSamplingDecision
@Nullable public @Nullable TracesSamplingDecision getSamplingDecision()
-
setThrowable
public void setThrowable(@Nullable @Nullable java.lang.Throwable throwable)
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
@Nullable public @Nullable java.lang.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
@NotNull public @NotNull SentryId getTraceId()
-
getSpanId
@NotNull public @NotNull SpanId getSpanId()
-
getParentSpanId
@Nullable public @Nullable SpanId getParentSpanId()
-
getTags
public java.util.Map<java.lang.String,java.lang.String> getTags()
-
setData
public void setData(@NotNull @NotNull java.lang.String key, @NotNull @NotNull java.lang.Object value)
Description copied from interface:ISpan
Sets extra data on span or transaction.
-
getData
@Nullable public @Nullable java.lang.Object getData(@NotNull @NotNull java.lang.String key)
Description copied from interface:ISpan
Returns extra data from span or transaction.
-
setMeasurement
public void setMeasurement(@NotNull @NotNull java.lang.String name, @NotNull @NotNull java.lang.Number value)
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 java.lang.String name, @NotNull @NotNull java.lang.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
-
getHighPrecisionTimestamp
@Nullable public @Nullable java.lang.Double getHighPrecisionTimestamp()
-
-