UNPKG

@ogcio/o11y-sdk-node

Version:

Opentelemetry standard instrumentation SDK for NodeJS based project

21 lines (20 loc) 840 B
import { Span, SpanOptions } from "@opentelemetry/api"; export type WithSpanParams<T> = { /** * The name of the trace the span should belong to. * NOTE: If you want the new span to belong to an already existing trace, you should provide the same tracer name */ traceName?: string; spanName: string; spanOptions?: SpanOptions; /** A function defining the task you want to be wrapped by this span */ fn: (span: Span) => T | Promise<T>; }; /** * Gets the currently active OpenTelemetry span. * * @returns {Span | undefined} The active span with redaction logic applied, * or `undefined` if there is no active span in context. */ export declare function getActiveSpan(): Span | undefined; export declare function withSpan<T>({ traceName, spanName, spanOptions, fn, }: WithSpanParams<T>): Promise<T>;