Package io.sentry

Class Span

java.lang.Object
io.sentry.Span
All Implemented Interfaces:
ISpan

@Internal public final class Span extends Object implements ISpan
  • Constructor Details

  • Method Details

    • getStartDate

      @NotNull public @NotNull SentryDate getStartDate()
      Description copied from interface: ISpan
      Returns the start date of this span or transaction.
      Specified by:
      getStartDate in interface ISpan
      Returns:
      the start date
    • getFinishDate

      @Nullable public @Nullable SentryDate getFinishDate()
      Description copied from interface: ISpan
      Returns the end date of this span or transaction.
      Specified by:
      getFinishDate in interface ISpan
      Returns:
      the end date
    • startChild

      @NotNull public @NotNull ISpan startChild(@NotNull @NotNull String operation)
      Description copied from interface: ISpan
      Starts a child Span.
      Specified by:
      startChild in interface ISpan
      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 interface ISpan
    • 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 interface ISpan
      Parameters:
      operation - - new span operation name
      description - - 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 interface ISpan
    • 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 interface ISpan
    • 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 interface ISpan
      Returns:
      SentryTraceHeader.
    • traceContext

      @Nullable public @Nullable TraceContext traceContext()
      Description copied from interface: ISpan
      Returns the trace context.
      Specified by:
      traceContext in interface ISpan
      Returns:
      a trace context or null if SentryOptions.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 interface ISpan
      Returns:
      BaggageHeader or null if SentryOptions.isTraceSampling() is disabled.
    • finish

      public void finish()
      Description copied from interface: ISpan
      Sets span timestamp marking this span as finished.
      Specified by:
      finish in interface ISpan
    • finish

      public void finish(@Nullable @Nullable SpanStatus status)
      Description copied from interface: ISpan
      Sets span timestamp marking this span as finished.
      Specified by:
      finish in interface ISpan
      Parameters:
      status - - the status
    • finish

      public void finish(@Nullable @Nullable SpanStatus status, @Nullable @Nullable SentryDate timestamp)
      Used to finish unfinished spans by SentryTracer.
      Specified by:
      finish in interface ISpan
      Parameters:
      status - - status to finish span with
      timestamp - - the root span timestamp.
    • setOperation

      public void setOperation(@NotNull @NotNull String operation)
      Description copied from interface: ISpan
      Sets span operation.
      Specified by:
      setOperation in interface ISpan
      Parameters:
      operation - - the operation
    • getOperation

      @NotNull public @NotNull String getOperation()
      Description copied from interface: ISpan
      Returns the span operation.
      Specified by:
      getOperation in interface ISpan
      Returns:
      the operation
    • setDescription

      public void setDescription(@Nullable @Nullable String description)
      Description copied from interface: ISpan
      Sets span description.
      Specified by:
      setDescription in interface ISpan
      Parameters:
      description - - the description.
    • getDescription

      @Nullable public @Nullable String getDescription()
      Description copied from interface: ISpan
      Returns the span description.
      Specified by:
      getDescription in interface ISpan
      Returns:
      the description
    • setStatus

      public void setStatus(@Nullable @Nullable SpanStatus status)
      Description copied from interface: ISpan
      Sets span status.
      Specified by:
      setStatus in interface ISpan
      Parameters:
      status - - the status.
    • getStatus

      @Nullable public @Nullable SpanStatus getStatus()
      Description copied from interface: ISpan
      Returns the span status
      Specified by:
      getStatus in interface ISpan
      Returns:
      the status
    • getSpanContext

      @NotNull public @NotNull SpanContext getSpanContext()
      Description copied from interface: ISpan
      Gets the span context.
      Specified by:
      getSpanContext in interface ISpan
      Returns:
      the span context
    • setTag

      public void setTag(@NotNull @NotNull String key, @NotNull @NotNull String value)
      Description copied from interface: ISpan
      Sets the tag on span or transaction.
      Specified by:
      setTag in interface ISpan
      Parameters:
      key - the tag key
      value - the tag value
    • getTag

      @Nullable public @Nullable String getTag(@NotNull @NotNull String key)
      Specified by:
      getTag in interface ISpan
    • isFinished

      public boolean isFinished()
      Description copied from interface: ISpan
      Returns if span has finished.
      Specified by:
      isFinished in interface ISpan
      Returns:
      if span has finished.
    • getData

      @NotNull public @NotNull Map<String,Object> getData()
    • isSampled

      @Nullable public @Nullable Boolean isSampled()
    • isProfileSampled

      @Nullable public @Nullable Boolean isProfileSampled()
    • getSamplingDecision

      @Nullable public @Nullable TracesSamplingDecision getSamplingDecision()
    • setThrowable

      public void setThrowable(@Nullable @Nullable Throwable throwable)
      Description copied from interface: ISpan
      Sets the throwable that was thrown during the execution of the span.
      Specified by:
      setThrowable in interface ISpan
      Parameters:
      throwable - - the throwable.
    • getThrowable

      @Nullable public @Nullable Throwable getThrowable()
      Description copied from interface: ISpan
      Gets the throwable that was thrown during the execution of the span.
      Specified by:
      getThrowable in interface ISpan
      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 Map<String,String> getTags()
    • setData

      public void setData(@NotNull @NotNull String key, @NotNull @NotNull Object value)
      Description copied from interface: ISpan
      Sets extra data on span or transaction.
      Specified by:
      setData in interface ISpan
      Parameters:
      key - the data key
      value - the data value
    • getData

      @Nullable public @Nullable Object getData(@NotNull @NotNull String key)
      Description copied from interface: ISpan
      Returns extra data from span or transaction.
      Specified by:
      getData in interface ISpan
      Returns:
      the data
    • setMeasurement

      public void setMeasurement(@NotNull @NotNull String name, @NotNull @NotNull 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 interface ISpan
      Parameters:
      name - the name of the measurement
      value - 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 interface ISpan
      Parameters:
      name - the name of the measurement
      value - the value of the measurement
      unit - the unit the value is measured in
    • getMeasurements

      @NotNull public @NotNull Map<String,MeasurementValue> getMeasurements()
    • updateEndDate

      public boolean updateEndDate(@NotNull @NotNull SentryDate date)
      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 interface ISpan
      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
      Specified by:
      isNoOp in interface ISpan
      Returns:
      true if NOOP
    • getLocalMetricsAggregator

      @NotNull public @NotNull LocalMetricsAggregator getLocalMetricsAggregator()
      Description copied from interface: ISpan
      Returns the metrics aggregator for this span.
      Specified by:
      getLocalMetricsAggregator in interface ISpan
      Returns:
      the metrics aggregator