Package io.sentry.opentelemetry
Class OtelSpanWrapper
java.lang.Object
io.sentry.opentelemetry.OtelSpanWrapper
- All Implemented Interfaces:
ISpan
,IOtelSpanWrapper
NOTE: This wrapper is not used when using OpenTelemetry API, only when using Sentry API.
-
Constructor Summary
ConstructorDescriptionOtelSpanWrapper
(@NotNull io.opentelemetry.sdk.trace.ReadWriteSpan span, @NotNull IScopes scopes, @NotNull SentryDate startTimestamp, @Nullable TracesSamplingDecision samplingDecision, @Nullable IOtelSpanWrapper parentSpan, @Nullable SpanId parentSpanId, @Nullable Baggage baggage) -
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.@NotNull Contexts
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 Map<String,
MeasurementValue> @NotNull String
Returns the span operation.@Nullable TracesSamplingDecision
@NotNull IScopes
@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
getTags()
@Nullable Throwable
Gets the throwable that was thrown during the execution of the span.@NotNull SentryId
@Nullable String
@Nullable TransactionNameSource
boolean
Returns if span has finished.boolean
isNoOp()
Whether this span instance is a NOOP that doesn't collect information@Nullable Boolean
@Nullable Boolean
@NotNull ISentryLifecycleToken
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
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.void
setTransactionName
(@NotNull String name) void
setTransactionName
(@NotNull String name, @NotNull TransactionNameSource nameSource) @NotNull ISpan
startChild
(@NotNull SpanContext spanContext, @NotNull SpanOptions spanOptions) @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) @NotNull io.opentelemetry.context.Context
storeInContext
(io.opentelemetry.context.Context context) @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
-
OtelSpanWrapper
public OtelSpanWrapper(@NotNull @NotNull io.opentelemetry.sdk.trace.ReadWriteSpan span, @NotNull @NotNull IScopes scopes, @NotNull @NotNull SentryDate startTimestamp, @Nullable @Nullable TracesSamplingDecision samplingDecision, @Nullable @Nullable IOtelSpanWrapper parentSpan, @Nullable @Nullable SpanId parentSpanId, @Nullable @Nullable Baggage baggage)
-
-
Method Details
-
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, @NotNull @NotNull SpanOptions spanOptions) - Specified by:
startChild
in interfaceISpan
-
startChild
@NotNull public @NotNull ISpan startChild(@NotNull @NotNull SpanContext spanContext, @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
-
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
-
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
Description copied from interface:ISpan
Sets span timestamp marking this span as finished. -
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
-
getTags
- Specified by:
getTags
in interfaceIOtelSpanWrapper
-
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. -
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
-
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
-
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
-
isNoOp
public boolean isNoOp()Description copied from interface:ISpan
Whether this span instance is a NOOP that doesn't collect information -
setContext
- Specified by:
setContext
in interfaceISpan
-
getContexts
- Specified by:
getContexts
in interfaceISpan
-
setTransactionName
- Specified by:
setTransactionName
in interfaceIOtelSpanWrapper
-
setTransactionName
public void setTransactionName(@NotNull @NotNull String name, @NotNull @NotNull TransactionNameSource nameSource) - Specified by:
setTransactionName
in interfaceIOtelSpanWrapper
-
getTransactionNameSource
- Specified by:
getTransactionNameSource
in interfaceIOtelSpanWrapper
-
getTransactionName
- Specified by:
getTransactionName
in interfaceIOtelSpanWrapper
-
getTraceId
- Specified by:
getTraceId
in interfaceIOtelSpanWrapper
-
getData
- Specified by:
getData
in interfaceIOtelSpanWrapper
-
getMeasurements
- Specified by:
getMeasurements
in interfaceIOtelSpanWrapper
-
isSampled
-
isProfileSampled
- Specified by:
isProfileSampled
in interfaceIOtelSpanWrapper
-
getSamplingDecision
- Specified by:
getSamplingDecision
in interfaceISpan
-
getScopes
- Specified by:
getScopes
in interfaceIOtelSpanWrapper
-
storeInContext
@NotNull public @NotNull io.opentelemetry.context.Context storeInContext(io.opentelemetry.context.Context context) - Specified by:
storeInContext
in interfaceIOtelSpanWrapper
-
makeCurrent
- Specified by:
makeCurrent
in interfaceISpan
-