Span holding trace_id, span_id

interface Span {
    attributes: SpanAttributes;
    data: { [key: string]: any };
    description?: string;
    endTimestamp?: number;
    exclusiveTime?: number;
    instrumenter: Instrumenter;
    measurements?: Measurements;
    name: string;
    op?: string;
    origin?: SpanOrigin;
    parentSpanId?: string;
    sampled?: boolean;
    spanId: string;
    startTimestamp: number;
    status?: string;
    tags: { [key: string]: Primitive };
    traceId: string;
    transaction?: Transaction;
    end(endTimestamp?: SpanTimeInput): void;
    finish(endTimestamp?: number): void;
    getTraceContext(): TraceContext;
    isRecording(): boolean;
    isSuccess(): boolean;
    setAttribute(key: string, value: undefined | SpanAttributeValue): void;
    setAttributes(attributes: SpanAttributes): void;
    setData(key: string, value: any): this;
    setHttpStatus(httpStatus: number): this;
    setName(name: string): void;
    setStatus(status: string): this;
    setTag(key: string, value: Primitive): this;
    spanContext(): SpanContextData;
    startChild(
        spanContext?: Pick<
            SpanContext,
            | "instrumenter"
            | "name"
            | "status"
            | "op"
            | "origin"
            | "description"
            | "spanId"
            | "tags"
            | "data"
            | "attributes"
            | "startTimestamp"
            | "endTimestamp"
            | "exclusiveTime"
            | "measurements",
        >,
    ): Span;
    toContext(): SpanContext;
    toJSON(): SpanJSON;
    toTraceparent(): string;
    updateName(name: string): this;
    updateWithContext(spanContext: SpanContext): this;
}

Hierarchy

  • Omit<SpanContext, "op" | "status" | "origin">
    • Span

Properties

attributes: SpanAttributes

Attributes for the span.

Use spanToJSON(span).atttributes instead.

data: { [key: string]: any }

Data for the span.

Use spanToJSON(span).atttributes instead.

description?: string

Description of the Span.

Use name instead.

endTimestamp?: number

Timestamp in seconds (epoch time) indicating when the span ended.

Use spanToJSON() instead.

exclusiveTime?: number

Exclusive time in milliseconds.

instrumenter: Instrumenter

The instrumenter that created this span.

this field will be removed.

measurements?: Measurements

Measurements of the Span.

name: string

Human-readable identifier for the span. Identical to span.description.

Use spanToJSON(span).description instead.

op?: string

Operation of the Span.

Use startSpan() functions to set, span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'op') to update and spanToJSON().op` to read the op instead

origin?: SpanOrigin

The origin of the span, giving context about what created the span.

Use startSpan function to set and spanToJSON(span).origin to read the origin instead.

parentSpanId?: string

Parent Span ID

Use spanToJSON(span).parent_span_id instead.

sampled?: boolean

Was this span chosen to be sent as part of the sample?

Use isRecording() instead.

spanId: string

The ID of the span.

Use spanContext().spanId instead.

startTimestamp: number

Timestamp in seconds (epoch time) indicating when the span started.

Use spanToJSON() instead.

status?: string

Completion status of the Span.

See: {@sentry/tracing SpanStatus} for possible values

Use .setStatus to set or update and spanToJSON() to read the status.

tags: { [key: string]: Primitive }

Tags for the span.

Use spanToJSON(span).atttributes instead.

traceId: string

The ID of the trace.

Use spanContext().traceId instead.

transaction?: Transaction

The transaction containing this span

Use top level Sentry.getRootSpan() instead

Methods

  • End the current span.

    Parameters

    • OptionalendTimestamp: SpanTimeInput

    Returns void

  • Sets the finish timestamp on the current span.

    Parameters

    • OptionalendTimestamp: number

      Takes an endTimestamp if the end should not be the time when you call this function.

    Returns void

    Use .end() instead.

  • Convert the object to JSON for w. spans array info only.

    Returns TraceContext

    Use spanToTraceContext() util function instead.

  • If this is span is actually recording data. This will return false if tracing is disabled, this span was not sampled or if the span is already finished.

    Returns boolean

  • Determines whether span was successful (HTTP200)

    Returns boolean

    Use spanToJSON(span).status === 'ok' instead.

  • Set a single attribute on the span. Set it to undefined to remove the attribute.

    Parameters

    • key: string
    • value: undefined | SpanAttributeValue

    Returns void

  • Set multiple attributes on the span. Any attribute set to undefined will be removed.

    Parameters

    • attributes: SpanAttributes

    Returns void

  • Sets the data attribute on the current span

    Parameters

    • key: string

      Data key

    • value: any

      Data value

    Returns this

    Use setAttribute() instead.

  • Sets the status attribute on the current span based on the http code

    Parameters

    • httpStatus: number

      http code used to set the status

    Returns this

    Use top-level setHttpStatus() instead.

  • Set the name of the span.

    Parameters

    • name: string

    Returns void

    Use updateName() instead.

  • Sets the status attribute on the current span See: {@sentry/tracing SpanStatus} for possible values

    Parameters

    • status: string

      http code used to set the status

    Returns this

  • Sets the tag attribute on the current span.

    Can also be used to unset a tag, by passing undefined.

    Parameters

    • key: string

      Tag key

    • value: Primitive

      Tag value

    Returns this

    Use setAttribute() instead.

  • Get context data for this span. This includes the spanId & the traceId.

    Returns SpanContextData

  • Creates a new Span while setting the current Span.id as parentSpanId. Also the sampled decision will be inherited.

    Parameters

    • OptionalspanContext: Pick<
          SpanContext,
          | "instrumenter"
          | "name"
          | "status"
          | "op"
          | "origin"
          | "description"
          | "spanId"
          | "tags"
          | "data"
          | "attributes"
          | "startTimestamp"
          | "endTimestamp"
          | "exclusiveTime"
          | "measurements",
      >

    Returns Span

    Use startSpan(), startSpanManual() or startInactiveSpan() instead.

  • Returns the current span properties as a SpanContext.

    Returns SpanContext

    Use toJSON() or access the fields directly instead.

  • Convert the object to JSON.

    Returns SpanJSON

    Use spanToJSON(span) instead.

  • Return a traceparent compatible header string.

    Returns string

    Use spanToTraceHeader() instead.

  • Update the name of the span.

    Parameters

    • name: string

    Returns this

  • Updates the current span with a new SpanContext.

    Parameters

    • spanContext: SpanContext

    Returns this

    Update the fields directly instead.