Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Span

Package version

Interface for Span An interface that represents a span. A span represents a single operation within a trace. Examples of span might include remote procedure calls or a in-process function calls to sub-components. A Trace has a single, top-level "root" Span that in turn may have zero or more child Spans, which in turn may have children.

Hierarchy

  • Span

Index

Properties

activeTraceParams

activeTraceParams: TraceParams

Trace Parameters

annotations

annotations: Annotation[]

A text annotation with a set of attributes.

attributes

attributes: Attributes

A set of attributes, each in the format [KEY]:[VALUE]

droppedAnnotationsCount

droppedAnnotationsCount: number

The number of dropped annotations.

droppedAttributesCount

droppedAttributesCount: number

The number of dropped attributes.

droppedLinksCount

droppedLinksCount: number

The number of dropped links.

droppedMessageEventsCount

droppedMessageEventsCount: number

The number of dropped message events.

duration

duration: number

Gives a timestap that indicates the span's duration in RFC3339 UTC "Zulu" format.

endTime

endTime: Date

Gives a timestap that indicates the span's end time in RFC3339 UTC "Zulu" format.

ended

ended: boolean

Indicates if span was ended.

id

id: string

The Span ID of this span

kind

kind: SpanKind

Kind of span.

links

links: Link[]

Pointers from the current span to another span

logger

logger: Logger

An object to log information to

messageEvents

messageEvents: MessageEvent[]

An event describing a message sent/received between Spans.

name

name: string

The resource name of the span

numberOfChildren

numberOfChildren: number

The number of direct children

parentSpanId

parentSpanId: string

The span ID of this span's parent. If it's a root span, must be empty

remoteParent

remoteParent: boolean

If the parent span is in another process.

spanContext

spanContext: SpanContext

Gives the TraceContext of the span.

spans

spans: Span[]

The list of immediate child spans.

startTime

startTime: Date

Gives a timestap that indicates the span's start time in RFC3339 UTC "Zulu" format.

started

started: boolean

Indicates if span was started.

status

status: Status

A final status for this span

traceId

traceId: string

Trace id asscoiated with span.

Optional traceState

traceState: TraceState

Trace state associated with span

Methods

addAnnotation

  • addAnnotation(description: string, attributes?: Attributes, timestamp?: undefined | number): void
  • Adds an annotation to the span.

    Parameters

    • description: string

      Describes the event.

    • Optional attributes: Attributes

      A set of attributes on the annotation.

    • Optional timestamp: undefined | number

      A timestamp for this event.

    Returns void

addAttribute

  • addAttribute(key: string, value: string | number | boolean | object): void
  • Adds an atribute to the span.

    Parameters

    • key: string

      Describes the value added.

    • value: string | number | boolean | object

      The result of an operation.

    Returns void

addEvent

  • addEvent(name: string, attributes?: Attributes): this
  • Adds an event to the Span.

    Parameters

    • name: string

      the name of the event.

    • Optional attributes: Attributes

    Returns this

addLink

  • addLink(traceId: string, spanId: string, type: LinkType, attributes?: Attributes): void
  • addLink(spanContext: SpanContext, attributes?: Attributes): this
  • Adds a link to the span.

    Parameters

    • traceId: string

      The trace ID for a trace within a project.

    • spanId: string

      The span ID for a span within a trace.

    • type: LinkType

      The relationship of the current span relative to the linked.

    • Optional attributes: Attributes

      A set of attributes on the link.

    Returns void

  • Adds a link to the Span.

    Parameters

    • spanContext: SpanContext

      the context of the linked span.

    • Optional attributes: Attributes

    Returns this

addMessageEvent

  • addMessageEvent(type: MessageEventType, id: number, timestamp?: undefined | number, uncompressedSize?: undefined | number, compressedSize?: undefined | number): void
  • Adds a message event to the span.

    Parameters

    • type: MessageEventType

      The type of message event.

    • id: number

      An identifier for the message event.

    • Optional timestamp: undefined | number

      A timestamp for this event.

    • Optional uncompressedSize: undefined | number

      The number of uncompressed bytes sent or received.

    • Optional compressedSize: undefined | number

      The number of compressed bytes sent or received. If zero or undefined, assumed to be the same size as uncompressed.

    Returns void

allDescendants

  • allDescendants(): Span[]
  • Recursively gets the descendant spans.

    Returns Span[]

context

  • context(): SpanContext
  • Returns the SpanContext object associated with this Span.

    Returns SpanContext

    the SpanContext object associated with this Span.

end

  • Ends a span and all of its children, recursively.

    Returns void

  • Marks the end of Span execution.

    Call to End of a Span MUST not have any effects on child spans. Those may still be running and can be ended later.

    Do not return this. The Span generally should not be used after it is ended so chaining is not desired in this context.

    Parameters

    Returns void

isRecordingEvents

  • isRecordingEvents(): boolean
  • Returns the flag whether this span will be recorded.

    Returns boolean

    true if this Span is active and recording information like events with the AddEvent operation and attributes using setAttributes.

setAttribute

  • setAttribute(key: string, value: unknown): this
  • Sets an attribute to the span.

    Parameters

    • key: string

      the key for this attribute.

    • value: unknown

      the value for this attribute.

    Returns this

setAttributes

  • setAttributes(attributes: Attributes): this
  • Sets attributes to the span.

    Parameters

    • attributes: Attributes

      the attributes that will be added.

    Returns this

setStatus

  • setStatus(code: CanonicalCode, message?: undefined | string): void
  • setStatus(status: Status): this
  • Sets a status to the span.

    Parameters

    • code: CanonicalCode

      The canonical status code.

    • Optional message: undefined | string

      optional A developer-facing error message.

    Returns void

  • Sets a status to the span. If used, this will override the default Span status. Default is CanonicalCode.OK.

    Parameters

    • status: Status

      the Status to set.

    Returns this

start

  • start(): void
  • Starts a span.

    Returns void

startChildSpan

  • Starts a new Span instance as a child of this instance

    Parameters

    Returns Span

truncate

  • truncate(): void
  • Forces to end a span.

    Returns void

updateName

  • updateName(name: string): this

Generated using TypeDoc