Options
All
  • Public
  • Public/Protected
  • All
Menu

OpenTelemetry API for JavaScript

Index

Type aliases

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<HttpTextPropagator>; [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

TimeInput

TimeInput: HrTime | number | Date

Defines TimeInput.

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

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_SPAN_ID

INVALID_SPAN_ID: "0" = "0"

Const INVALID_TRACE_ID

INVALID_TRACE_ID: "0" = "0"

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_HTTP_TEXT_PROPAGATOR

NOOP_HTTP_TEXT_PROPAGATOR: NoopHttpTextPropagator = new NoopHttpTextPropagator()

Const NOOP_METER

NOOP_METER: NoopMeter = new NoopMeter()

Const NOOP_METER_PROVIDER

NOOP_METER_PROVIDER: NoopMeterProvider = new NoopMeterProvider()

Const NOOP_OBSERVER_METRIC

NOOP_OBSERVER_METRIC: NoopObserverMetric = new NoopObserverMetric()

Const NOOP_SPAN

NOOP_SPAN: NoopSpan = new NoopSpan()

Const NOOP_TRACER

NOOP_TRACER: NoopTracer = new NoopTracer()

Const NOOP_TRACER_PROVIDER

NOOP_TRACER_PROVIDER: NoopTracerProvider = new NoopTracerProvider()

Const NOOP_VALUE_RECORDER_METRIC

NOOP_VALUE_RECORDER_METRIC: NoopValueRecorderMetric = new NoopValueRecorderMetric(NOOP_BOUND_VALUE_RECORDER)

Const _global

_global: {} = _globalThis as OtelGlobal

Type declaration

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

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_SPAN_ID

traceFlags

traceFlags: TraceFlags = TraceFlags.NONE

traceId

traceId: string = INVALID_TRACE_ID