Package io.sentry
Class SentryTracer
java.lang.Object
io.sentry.SentryTracer
- All Implemented Interfaces:
ISpan
,ITransaction
-
Constructor Summary
ConstructorDescriptionSentryTracer
(@NotNull TransactionContext context, @NotNull IHub hub) SentryTracer
(@NotNull TransactionContext context, @NotNull IHub hub, @NotNull TransactionOptions transactionOptions) -
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 finishDate) Sets span timestamp marking this span as finished.void
finish
(@Nullable SpanStatus status, @Nullable SentryDate finishDate, boolean dropIfNoChildren, @Nullable Hint hint) void
forceFinish
(@NotNull SpanStatus status, boolean dropIfNoChildren, @Nullable Hint hint) Force finishes the transaction and it's child spans with the specified status.@NotNull Contexts
getData()
@Nullable Object
Returns extra data from span or transaction.@Nullable String
Returns the span description.@NotNull SentryId
Returns transaction's event id.@Nullable SentryDate
Returns the end date of this span or transaction.@Nullable Span
Returns the latest span that is not finished.@Nullable LocalMetricsAggregator
Returns the metrics aggregator for this span.@NotNull String
getName()
Returns transaction name.@NotNull String
Returns the span operation.@Nullable TracesSamplingDecision
@NotNull SpanContext
Gets the span context.getSpans()
@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.@NotNull TransactionNameSource
Returns the source of the transaction name.boolean
Returns if span has finished.boolean
isNoOp()
Whether this span instance is a NOOP that doesn't collect information@Nullable Boolean
Returns if the profile of a transaction is sampled.@Nullable Boolean
Returns if transaction is sampled.void
Schedules when transaction should be automatically finished.void
setContext
(@NotNull String key, @NotNull Object context) 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
setMeasurementFromChild
(@NotNull String name, @NotNull Number value) void
setMeasurementFromChild
(@NotNull String name, @NotNull Number value, @NotNull MeasurementUnit unit) void
Sets transaction name.void
setName
(@NotNull String name, @NotNull TransactionNameSource transactionNameSource) 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) Starts a child Span.@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
-
SentryTracer
-
SentryTracer
public SentryTracer(@NotNull @NotNull TransactionContext context, @NotNull @NotNull IHub hub, @NotNull @NotNull TransactionOptions transactionOptions)
-
-
Method Details
-
scheduleFinish
public void scheduleFinish()Description copied from interface:ITransaction
Schedules when transaction should be automatically finished.- Specified by:
scheduleFinish
in interfaceITransaction
-
forceFinish
@NotNull public void forceFinish(@NotNull @NotNull SpanStatus status, boolean dropIfNoChildren, @Nullable @Nullable Hint hint) Description copied from interface:ITransaction
Force finishes the transaction and it's child spans with the specified status. If the transaction is already finished this is a no-op.- Specified by:
forceFinish
in interfaceITransaction
- Parameters:
status
- The status to set the unfinished child spans / transaction to.dropIfNoChildren
- true, if the transaction should be dropped when it e.g. contains no child spans. Usually true, but can be set to falseS for situations were the transaction and profile provide crucial context (e.g. ANRs)hint
- An optional hint to pass down to the client/transport layer
-
finish
public void finish(@Nullable @Nullable SpanStatus status, @Nullable @Nullable SentryDate finishDate, boolean dropIfNoChildren, @Nullable @Nullable Hint hint) - Specified by:
finish
in interfaceITransaction
-
getChildren
-
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) - 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, @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) Description copied from interface:ITransaction
Starts a child Span.- Specified by:
startChild
in interfaceITransaction
- Parameters:
operation
- - new span operation namedescription
- - the span descriptiontimestamp
- - the start timestamp of the span- Returns:
- a new transaction span
-
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
-
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.
-
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
@Internal public void finish(@Nullable @Nullable SpanStatus status, @Nullable @Nullable SentryDate finishDate) Description copied from interface:ISpan
Sets span timestamp marking this span as finished. -
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.
-
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 -
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
-
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.
-
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. -
setMeasurementFromChild
-
setMeasurementFromChild
@Internal public void setMeasurementFromChild(@NotNull @NotNull String name, @NotNull @NotNull Number value, @NotNull @NotNull MeasurementUnit unit) -
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
-
getData
-
isSampled
Description copied from interface:ITransaction
Returns if transaction is sampled.- Specified by:
isSampled
in interfaceITransaction
- Returns:
- is sampled
-
isProfileSampled
Description copied from interface:ITransaction
Returns if the profile of a transaction is sampled.- Specified by:
isProfileSampled
in interfaceITransaction
- Returns:
- profile is sampled
-
getSamplingDecision
- Specified by:
getSamplingDecision
in interfaceITransaction
-
setName
Description copied from interface:ITransaction
Sets transaction name.- Specified by:
setName
in interfaceITransaction
- Parameters:
name
- - transaction name
-
setName
@Internal public void setName(@NotNull @NotNull String name, @NotNull @NotNull TransactionNameSource transactionNameSource) - Specified by:
setName
in interfaceITransaction
-
getName
Description copied from interface:ITransaction
Returns transaction name.- Specified by:
getName
in interfaceITransaction
- Returns:
- transaction name
-
getTransactionNameSource
Description copied from interface:ITransaction
Returns the source of the transaction name.- Specified by:
getTransactionNameSource
in interfaceITransaction
- Returns:
- transaction name source
-
getSpans
- Specified by:
getSpans
in interfaceITransaction
-
getLatestActiveSpan
Description copied from interface:ITransaction
Returns the latest span that is not finished.- Specified by:
getLatestActiveSpan
in interfaceITransaction
- Returns:
- span or null if not found.
-
getEventId
Description copied from interface:ITransaction
Returns transaction's event id.- Specified by:
getEventId
in interfaceITransaction
- Returns:
- the event id
-
setContext
- Specified by:
setContext
in interfaceITransaction
-
getContexts
- Specified by:
getContexts
in interfaceITransaction
-
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
-