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 Details

    • startChild

      @NotNull @NotNull ISpan startChild(@NotNull @NotNull String operation)
      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 name
      description - - new span description name
      Returns:
      a new transaction span
    • toSentryTrace

      @NotNull @NotNull SentryTraceHeader toSentryTrace()
      Returns the trace information that could be sent as a sentry-trace header.
      Returns:
      SentryTraceHeader.
    • traceContext

      @Nullable @Experimental @Nullable TraceContext traceContext()
      Returns the trace context.
      Returns:
      a trace context or null if SentryOptions.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 if SentryOptions.isTraceSampling() is disabled.
    • finish

      void finish()
      Sets span timestamp marking this span as finished.
    • finish

      void finish(@Nullable @Nullable SpanStatus status)
      Sets span timestamp marking this span as finished.
      Parameters:
      status - - the status
    • finish

      void finish(@Nullable @Nullable SpanStatus status, @Nullable @Nullable SentryDate timestamp)
      Sets span timestamp marking this span as finished.
      Parameters:
      status - - the status
      timestamp - - the end timestamp
    • setOperation

      void setOperation(@NotNull @NotNull String operation)
      Sets span operation.
      Parameters:
      operation - - the operation
    • getOperation

      @NotNull @NotNull String getOperation()
      Returns the span operation.
      Returns:
      the operation
    • setDescription

      void setDescription(@Nullable @Nullable String description)
      Sets span description.
      Parameters:
      description - - the description.
    • getDescription

      @Nullable @Nullable String getDescription()
      Returns the span description.
      Returns:
      the description
    • setStatus

      void setStatus(@Nullable @Nullable SpanStatus status)
      Sets span status.
      Parameters:
      status - - the status.
    • getStatus

      @Nullable @Nullable SpanStatus getStatus()
      Returns the span status
      Returns:
      the status
    • setThrowable

      void setThrowable(@Nullable @Nullable Throwable throwable)
      Sets the throwable that was thrown during the execution of the span.
      Parameters:
      throwable - - the throwable.
    • getThrowable

      @Nullable @Nullable Throwable getThrowable()
      Gets the throwable that was thrown during the execution of the span.
      Returns:
      throwable or null if none
    • getSpanContext

      @NotNull @NotNull SpanContext getSpanContext()
      Gets the span context.
      Returns:
      the span context
    • setTag

      void setTag(@NotNull @NotNull String key, @NotNull @NotNull String value)
      Sets the tag on span or transaction.
      Parameters:
      key - the tag key
      value - the tag value
    • getTag

      @Nullable @Nullable String getTag(@NotNull @NotNull String key)
    • isFinished

      boolean isFinished()
      Returns if span has finished.
      Returns:
      if span has finished.
    • setData

      void setData(@NotNull @NotNull String key, @NotNull @NotNull Object value)
      Sets extra data on span or transaction.
      Parameters:
      key - the data key
      value - the data value
    • getData

      @Nullable @Nullable Object getData(@NotNull @NotNull String key)
      Returns extra data from span or transaction.
      Returns:
      the data
    • setMeasurement

      void setMeasurement(@NotNull @NotNull String name, @NotNull @NotNull Number value)
      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 measurement
      value - 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 measurement
      value - the value of the measurement
      unit - the unit the value is measured in
    • updateEndDate

      @Internal boolean updateEndDate(@NotNull @NotNull SentryDate date)
      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

      @Internal @NotNull @NotNull SentryDate getStartDate()
      Returns the start date of this span or transaction.
      Returns:
      the start date
    • getFinishDate

      @Internal @Nullable @Nullable SentryDate 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

      @Nullable @Nullable LocalMetricsAggregator getLocalMetricsAggregator()
      Returns the metrics aggregator for this span.
      Returns:
      the metrics aggregator