Options
All
  • Public
  • Public/Protected
  • All
Menu

OpenTelemetry API for JavaScript

Index

Enumerations

Classes

Interfaces

Type aliases

Variables

Functions

Object literals

Type aliases

BatchObserver

BatchObserver: Metric

Base interface for the Batch Observer metrics.

Exception

Defines Exception.

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

Get

Get<T>: (version: number) => T

Type parameters

  • T

Type declaration

    • (version: number): T
    • Parameters

      • version: number

      Returns T

GetterFunction

GetterFunction<Carrier>: (carrier: Carrier, key: string) => unknown

Type parameters

  • Carrier

Type declaration

    • (carrier: Carrier, key: string): unknown
    • Parameters

      • carrier: Carrier
      • key: string

      Returns unknown

HrTime

HrTime: [number, number]

Labels

Labels: {}

key-value pairs passed by the user.

Type declaration

  • [key: string]: string

LinkContext

LinkContext: Pick<SpanContext, "traceId" | "spanId">

A pointer to another span.

LogFunction

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

Type declaration

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

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

      Returns void

OtelGlobal

OtelGlobal: Partial<{ [GLOBAL_CONTEXT_MANAGER_API_KEY]: Get<ContextManager>; [GLOBAL_METRICS_API_KEY]: Get<MeterProvider>; [GLOBAL_PROPAGATION_API_KEY]: Get<TextMapPropagator>; [GLOBAL_TRACE_API_KEY]: Get<TracerProvider> }>

SetterFunction

SetterFunction<Carrier>: (carrier: Carrier, key: string, value: unknown) => void

Type parameters

  • Carrier

Type declaration

    • (carrier: Carrier, key: string, value: unknown): void
    • Parameters

      • carrier: Carrier
      • key: string
      • value: unknown

      Returns void

SumObserver

SumObserver: BaseObserver

Base interface for the SumObserver metrics.

TimeInput

TimeInput: HrTime | number | Date

Defines TimeInput.

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

UpDownSumObserver

UpDownSumObserver: BaseObserver

Base interface for the UpDownSumObserver metrics.

ValueObserver

ValueObserver: BaseObserver

Base interface for the ValueObserver metrics.

Variables

Const API_BACKWARDS_COMPATIBILITY_VERSION

API_BACKWARDS_COMPATIBILITY_VERSION: 0 = 0

A number which should be incremented each time a backwards incompatible change is made to the API. This number is used when an API package attempts to access the global API to ensure it is getting a compatible version. If the global API is not compatible with the API package attempting to get it, a NOOP API implementation will be returned.

Const GLOBAL_CONTEXT_MANAGER_API_KEY

GLOBAL_CONTEXT_MANAGER_API_KEY: unique symbol = Symbol.for('io.opentelemetry.js.api.context')

Const GLOBAL_METRICS_API_KEY

GLOBAL_METRICS_API_KEY: unique symbol = Symbol.for('io.opentelemetry.js.api.metrics')

Const GLOBAL_PROPAGATION_API_KEY

GLOBAL_PROPAGATION_API_KEY: unique symbol = Symbol.for('io.opentelemetry.js.api.propagation')

Const GLOBAL_TRACE_API_KEY

GLOBAL_TRACE_API_KEY: unique symbol = Symbol.for('io.opentelemetry.js.api.trace')

Const INVALID_SPANID

INVALID_SPANID: "0000000000000000" = "0000000000000000"

Const INVALID_TRACEID

INVALID_TRACEID: "00000000000000000000000000000000" = "00000000000000000000000000000000"

Const NOOP_BATCH_OBSERVER_METRIC

NOOP_BATCH_OBSERVER_METRIC: NoopBatchObserverMetric = new NoopBatchObserverMetric()

Const NOOP_BOUND_BASE_OBSERVER

NOOP_BOUND_BASE_OBSERVER: NoopBoundBaseObserver = new NoopBoundBaseObserver()

Const NOOP_BOUND_COUNTER

NOOP_BOUND_COUNTER: NoopBoundCounter = new NoopBoundCounter()

Const NOOP_BOUND_VALUE_RECORDER

NOOP_BOUND_VALUE_RECORDER: NoopBoundValueRecorder = new NoopBoundValueRecorder()

Const NOOP_CONTEXT_MANAGER

NOOP_CONTEXT_MANAGER: NoopContextManager = new NoopContextManager()

Const NOOP_COUNTER_METRIC

NOOP_COUNTER_METRIC: NoopCounterMetric = new NoopCounterMetric(NOOP_BOUND_COUNTER)

Const NOOP_METER

NOOP_METER: NoopMeter = new NoopMeter()

Const NOOP_METER_PROVIDER

NOOP_METER_PROVIDER: NoopMeterProvider = new NoopMeterProvider()

Const NOOP_SPAN

NOOP_SPAN: NoopSpan = new NoopSpan()

Const NOOP_SUM_OBSERVER_METRIC

NOOP_SUM_OBSERVER_METRIC: NoopBaseObserverMetric = new NoopBaseObserverMetric(NOOP_BOUND_BASE_OBSERVER)

Const NOOP_TEXT_MAP_PROPAGATOR

NOOP_TEXT_MAP_PROPAGATOR: NoopTextMapPropagator = new NoopTextMapPropagator()

Const NOOP_TRACER

NOOP_TRACER: NoopTracer = new NoopTracer()

Const NOOP_TRACER_PROVIDER

NOOP_TRACER_PROVIDER: NoopTracerProvider = new NoopTracerProvider()

Const NOOP_UP_DOWN_SUM_OBSERVER_METRIC

NOOP_UP_DOWN_SUM_OBSERVER_METRIC: NoopBaseObserverMetric = new NoopBaseObserverMetric(NOOP_BOUND_BASE_OBSERVER)

Const NOOP_VALUE_OBSERVER_METRIC

NOOP_VALUE_OBSERVER_METRIC: NoopBaseObserverMetric = new NoopBaseObserverMetric(NOOP_BOUND_BASE_OBSERVER)

Const NOOP_VALUE_RECORDER_METRIC

NOOP_VALUE_RECORDER_METRIC: NoopValueRecorderMetric = new NoopValueRecorderMetric(NOOP_BOUND_VALUE_RECORDER)

Const VALID_SPANID_REGEX

VALID_SPANID_REGEX: RegExp = /^[0-9a-f]{16}$/i

Const VALID_TRACEID_REGEX

VALID_TRACEID_REGEX: RegExp = /^([0-9a-f]{32})$/i

Const _global

_global: Partial<{ [GLOBAL_CONTEXT_MANAGER_API_KEY]: Get<ContextManager>; [GLOBAL_METRICS_API_KEY]: Get<MeterProvider>; [GLOBAL_PROPAGATION_API_KEY]: Get<TextMapPropagator>; [GLOBAL_TRACE_API_KEY]: Get<TracerProvider> }> = _globalThis as OtelGlobal

Const _globalThis

_globalThis: globalThis = typeof globalThis === 'object' ? globalThis : global

only globals that common to node and browsers are allowed

Const api1

api1: "/home/runner/work/opentelemetry-js/opentelemetry-js/packages/opentelemetry-api/src/index" = require('../../src') as typeof import('../../src')

Const api2

api2: "/home/runner/work/opentelemetry-js/opentelemetry-js/packages/opentelemetry-api/src/index" = require('../../src') as typeof import('../../src')

Const context

context: ContextAPI = ContextAPI.getInstance()

Entrypoint for context API

Const contextApi

contextApi: ContextAPI = ContextAPI.getInstance()

Const metrics

metrics: MetricsAPI = MetricsAPI.getInstance()

Entrypoint for metrics API

Const propagation

propagation: PropagationAPI = PropagationAPI.getInstance()

Entrypoint for propagation API

Const trace

trace: TraceAPI = TraceAPI.getInstance()

Entrypoint for trace API

Functions

defaultGetter

  • defaultGetter(carrier: any, key: string): unknown
  • Default getter which just does a simple property access. Returns undefined if the key is not set.

    Parameters

    • carrier: any
    • key: string

    Returns unknown

defaultSetter

  • defaultSetter(carrier: any, key: string, value: unknown): void

isSpanContextValid

  • isSpanContextValid(spanContext: SpanContext): boolean

isValidSpanId

  • isValidSpanId(spanId: string): boolean

isValidTraceId

  • isValidTraceId(traceId: string): boolean

makeGetter

  • makeGetter<T>(requiredVersion: number, instance: T, fallback: T): Get<T>
  • Make a function which accepts a version integer and returns the instance of an API if the version is compatible, or a fallback version (usually NOOP) if it is not.

    Type parameters

    • T

    Parameters

    • requiredVersion: number

      Backwards compatibility version which is required to return the instance

    • instance: T

      Instance which should be returned if the required version is compatible

    • fallback: T

      Fallback instance, usually NOOP, which will be returned if the required version is not compatible

    Returns Get<T>

Object literals

Const INVALID_SPAN_CONTEXT

INVALID_SPAN_CONTEXT: object

spanId

spanId: string = INVALID_SPANID

traceFlags

traceFlags: TraceFlags = TraceFlags.NONE

traceId

traceId: string = INVALID_TRACEID