• Public
  • Public/Protected
  • All

Module @opentelemetry/api


Type Aliases

AttributeValue: string | number | boolean | (null | undefined | string)[] | (null | undefined | number)[] | (null | undefined | boolean)[]

Attribute values may be any non-nullish primitive value except an object.

null or undefined attribute values are invalid and will result in undefined behavior.

BaggageEntryMetadata: { toString: any } & { __TYPE__: typeof baggageEntryMetadataSymbol }

Serializable Metadata defined by the W3C baggage specification. It currently has no special meaning defined by the OpenTelemetry or W3C.

BatchObservableCallback<AttributesTypes>: ((observableResult: BatchObservableResult<AttributesTypes>) => void | Promise<void>)

Type Parameters

Type declaration

    • The observable callback for a batch of Observable instruments.


      Returns void | Promise<void>

DiagLogFunction: ((message: string, ...args: unknown[]) => void)

Type declaration

    • (message: string, ...args: unknown[]): void
    • Parameters

      • message: string
      • Rest ...args: unknown[]

      Returns void

Defines Exception.

string or an object with one of (message or name or code) and optional stack

HrTime: [number, number]

Defines High-Resolution Time.

The first number, HrTime[0], is UNIX Epoch time in seconds since 00:00:00 UTC on 1 January 1970. The second number, HrTime[1], represents the partial second elapsed since Unix Epoch time represented by first number in nanoseconds. For example, 2021-01-01T12:30:10.150Z in UNIX Epoch time in milliseconds is represented as 1609504210150. The first number is calculated by converting and truncating the Epoch time in milliseconds to seconds: HrTime[0] = Math.trunc(1609504210150 / 1000) = 1609504210. The second number is calculated by converting the digits after the decimal point of the subtraction, (1609504210150 / 1000) - HrTime[0], to nanoseconds: HrTime[1] = Number((1609504210.150 - HrTime[0]).toFixed(9)) * 1e9 = 150000000. This is represented in HrTime format as [1609504210, 150000000].

MetricAttributeValue: AttributeValue

please use AttributeValue

MetricAttributes: Attributes

please use Attributes

ObservableCallback<AttributesTypes>: ((observableResult: ObservableResult<AttributesTypes>) => void | Promise<void>)

Type Parameters

Type declaration

    • The observable callback for Observable instruments.


      Returns void | Promise<void>

ObservableCounter<AttributesTypes>: Observable<AttributesTypes>

Type Parameters

ObservableGauge<AttributesTypes>: Observable<AttributesTypes>

Type Parameters

ObservableUpDownCounter<AttributesTypes>: Observable<AttributesTypes>

Type Parameters

SpanAttributeValue: AttributeValue

please use AttributeValue

SpanAttributes: Attributes

please use Attributes

TimeInput: HrTime | number | Date

Defines TimeInput.

hrtime, epoch milliseconds, performance.now() or Date


INVALID_SPANID: "0000000000000000" = '0000000000000000'
INVALID_TRACEID: "00000000000000000000000000000000" = '00000000000000000000000000000000'
ROOT_CONTEXT: Context = ...

The root context is used as the default parent context when there is no active context

context: ContextAPI = ...

Entrypoint for context API

default: { context: ContextAPI; diag: DiagAPI; metrics: MetricsAPI; propagation: PropagationAPI; trace: TraceAPI }

Type declaration

defaultTextMapGetter: TextMapGetter = ...
defaultTextMapSetter: TextMapSetter = ...
diag: DiagAPI = ...

Entrypoint for Diag API. Defines Diagnostic handler used for internal diagnostic logging operations. The default provides a Noop DiagLogger implementation which may be changed via the diag.setLogger(logger: DiagLogger) function.

metrics: MetricsAPI = ...

Entrypoint for metrics API

propagation: PropagationAPI = ...

Entrypoint for propagation API

trace: TraceAPI = ...

Entrypoint for trace API


  • Create a serializable BaggageEntryMetadata object from a string.


    • str: string

      string metadata. Format is currently not defined by the spec and has no special meaning.

    Returns BaggageEntryMetadata

  • createContextKey(description: string): symbol
  • createTraceState(rawTraceState?: string): TraceState
  • isValidSpanId(spanId: string): boolean
  • isValidTraceId(traceId: string): boolean

Generated using TypeDoc