@ogcio/o11y-sdk-node
Version:
Opentelemetry standard instrumentation SDK for NodeJS based project
22 lines (21 loc) • 980 B
TypeScript
import { type Span, type SpanOptions } from "@opentelemetry/api";
export type WithSpanParams<T> = {
/**
* The name of the trace the span should belong to.
* If not provided the span will default to the "o11y-sdk" tracer or the serviceName provided in the SDK config if available.
* 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>;