A telemetry service that does nothing — used when no exporter is configured.
-
withSpan<T>(): Promise<T>_name: string,fn: (span: ISpan) => Promise<T>,_options?: SpanOptions
Creates a span, runs the callback, and ends the span.
Creates the request-span middleware.
Creates a telemetry plugin.
Per-instrumentation entry. Presence of the parent key enables; this configures or injects.
-
config: Readonly<Record<string, unknown>>
Opaque config object forwarded VERBATIM to the OTel instrumentation constructor's
configargument (the LAZY half). Framework-owned and untyped on purpose: OTel instrumentation config surfaces evolve independently and re-typing them here would fabricate field names and drift. -
instrumentation: unknown
An already-constructed OTel
Instrumentationinstance — the INJECT half of the inject-or-lazy seam. When set, the registry skips the lazynpm:import and uses this instance directly.
Configuration for auto-instrumentations.
-
amqplib: true | InstrumentationConfig
amqplib via @opentelemetry/instrumentation-amqplib. Node-only; no-op elsewhere.
-
fetch: true | InstrumentationConfig
Node undici/fetch via @opentelemetry/instrumentation-undici. Node-only; no-op elsewhere.
-
http: true | InstrumentationConfig
node:http/https via @opentelemetry/instrumentation-http. Node-only; no-op elsewhere.
-
ioredis: true | InstrumentationConfig
ioredis via @opentelemetry/instrumentation-ioredis. Node-only; no-op elsewhere.
-
kafkajs: true | InstrumentationConfig
kafkajs via @opentelemetry/instrumentation-kafkajs. Node-only; no-op elsewhere.
A span represents a single operation within a trace.
-
end(): void
Ends the span. Must be called exactly once.
-
recordException(error: Error): void
Records an exception on this span.
-
setAttribute(): thiskey: string,value: SpanAttributeValue
Sets a single attribute on the span.
-
setAttributes(attributes: Readonly<Record<string, SpanAttributeValue>>): this
Sets multiple attributes on the span.
-
setStatus(status: SpanStatus): void
Sets the status of the span.
-
spanContext(): SpanContext
Returns the span's context (traceId, spanId, traceFlags).
Telemetry service — the primary API for creating spans.
-
activeSpanContext(): SpanContext | undefined
Reports the identifiers of the span that is active RIGHT NOW, so a signal emitted outside any span-creating call — a log record, most of all — can name the trace it belongs to.
-
withSpan<T>(): Promise<T>name: string,fn: (span: ISpan) => Promise<T>,options?: SpanOptions
Creates a span, runs the callback, and ends the span.
Sampling configuration.
-
ratio: number
Sampling ratio between 0.0 and 1.0 (default: 1.0).
-
type: "traceidratio"
Currently only
'traceidratio'is supported.
Options for span creation.
-
attributes: Readonly<Record<string, SpanAttributeValue>>
Initial attributes to set on the span.
-
kind: SpanKind
The span kind (defaults to
'internal'). -
parentContext: TelemetryContext
Optional parent context for span parenting.
Opaque handle representing the parent context for span creation.
-
_opaque: TELEMETRY_CONTEXT_OPAQUE
Internal marker — consumers must not inspect this type.
-
spanId: string
16-character lowercase hex parent span ID (W3C format).
-
traceFlags: string
2-character lowercase hex trace flags (W3C format).
-
traceId: string
32-character lowercase hex trace ID (W3C format).
-
tracestate: string
Raw
tracestateheader value, if present.
Options for the TelemetryPlugin.
-
contextManagerFactory: () => Promise<{ enable(): unknown; disable(): unknown; }>
Injectable loader for the OTel context manager.
-
contextPropagation: boolean
Whether real OTel spans become active for nested work (default:
true). -
endpoint: string
OTLP endpoint URL (required when
exporter: 'otlp'). -
exporter: SpanExporterKind
Which exporter to use. Absent = noop mode.
-
headers: Record<string, string>
Optional headers sent with OTLP requests.
-
instrumentations: InstrumentationsConfig
Auto-instrumentation configuration.
-
middleware: boolean
Whether to register the request-span middleware (default:
true). -
sampling: SamplingConfig
Sampling configuration.
-
serviceName: string
Service name reported to the exporter (required when exporter is configured).
-
serviceVersion: string
Service version (default:
'1.0.0'). -
spanProcessor: SpanProcessorKind
Span processor to use (
'simple'by default,'batch'as an option). -
tracerProviderFactory: () => Promise<TracerHost>
Injectable factory that returns a pre-built TracerHost (test seam).
The host seam returned by loadOtelTracerProvider.
-
activate<T>(): Promise<T>span: unknown,fn: () => Promise<T>
Runs work with the supplied span as the active OTel span, when supported.
-
activeSpanContext(): SpanContext | undefined
Reports the identifiers of the span the OTel context currently holds active, or
undefinedwhen nothing is active. -
extractContext(headers: Headers): TelemetryContext
Extracts a context from incoming headers (for traceparent propagation).
-
forceFlush(): Promise<void>
Forces flush of pending spans.
-
injectContext(context: TelemetryContext): Record<string, string>
Injects a context into outgoing headers.
-
otelProvider: unknown
The underlying OTel TracerProvider; undefined for noop/custom hosts (instrumentations then no-op).
-
shutdown(): Promise<void>
Shuts down the provider and flushes pending spans.
-
startSpan(): unknownname: string,options?: { kind?: number; attributes?: Record<string, unknown>; parentContext?: TelemetryContext; }
Starts a new span.
The kind of instrumentation to enable.
| number
| boolean
| ReadonlyArray<string | number | boolean>
Attribute value — a span attribute can be a primitive or an array of primitives.
Which span exporter to use.
The kind of span. Maps to OTel SpanKind at the implementation boundary.
Which span processor to use.
Span status — whether the span completed successfully or not.
The key used to store the active span on ctx.state.
Usage
import * as OpenTelemetry_distributed_tracing_plugin_for_Setu_TS___Provides__ITelemetryService__registration_under__CAPABILITIES_TELEMETRY___a_request_span_middleware_at_priority_30__and_lazy_loaded_OTel_SDK_support__ from "telemetry-plugin/src/index.ts";