import { opentelemetry } from "./lib"; export type SessionContext = { sessionId?: string; }; export type SessionContextOptions = { sessionId: string; }; /** * Gets the current active context * @returns The active `Context` */ export declare const getActiveContext: () => opentelemetry.api.Context; /** * Gets the Core SessionContext from the current active context * @returns A `SessionContext` Object */ export declare function getSessionContext(): SessionContext; /** * Bind the current active context to a target function or event emitter * This is needed for example when you want to trace code * that is triggered from an `EventEmitter`. * Due to how the context is propagated, the callback would otherwise lose its parent context. * * @param target function or `EventEmitter` to bind * @returns The bound function or `EventEmitter` */ export declare function bindActiveContext(target: T): T; /** * Sets the `sessionId` from the `SessionContext` * on a new Context and executes the wrapped function with that context. * Used to automatically annotate any spans below with the `SessionContext` data attributes. * * @param sessionContextOptions The new Core `SessionContext` to set * @param fn The callback function which executes with the new context * @returns A promise resolving with the callback's return value */ export declare function withSessionContext(sessionContextOptions: SessionContextOptions, fn: () => Promise): Promise;