import { MaybePromise } from "@entwico/dash"; import { Attributes, Context, Span, SpanKind } from "@opentelemetry/api"; //#region src/observability/telemetry/index.d.ts export interface InstrumentOptions { /** instrumentation scope, `@astroscope/`; defaults to `@astroscope/node` */ scope?: string | undefined; description?: string | undefined; /** UCUM unit, e.g. `s`, `{request}` */ unit?: string | undefined; } export interface HistogramOptions extends InstrumentOptions { /** explicit bucket boundaries; the SDK default set starts at 5, useless for seconds */ buckets: readonly number[]; } export interface HistogramHandle { record(value: number, attributes?: Attributes | undefined): void; } export interface CounterHandle { add(value: number, attributes?: Attributes | undefined): void; } /** what an observable gauge callback reports: one value per attribute set */ export interface ObservableHandle { observe(value: number, attributes?: Attributes | undefined): void; } /** * Bucket boundaries in seconds for the three kinds of durations the platform * measures: `http` is the semconv set for server requests, `io` covers one * outbound call (1 ms – 2.5 s), `compute` a synchronous render (10 µs – 50 ms). */ export declare const DURATION_BUCKETS: { readonly http: readonly [0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10]; readonly io: readonly [0.001, 0.0025, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5]; readonly compute: readonly [0.00001, 0.00005, 0.0001, 0.00025, 0.0005, 0.001, 0.0025, 0.005, 0.01, 0.05]; }; export declare function createHistogram(name: string, options: HistogramOptions): HistogramHandle; export declare function createCounter(name: string, options?: InstrumentOptions): CounterHandle; export declare function createUpDownCounter(name: string, options?: InstrumentOptions): CounterHandle; /** * An asynchronous gauge: `observe` runs at every collection (the Prometheus * scrape) and reports the current values. Registered with the SDK when it * starts, so calling this at module level is fine. */ export declare function createObservableGauge(name: string, options: InstrumentOptions, observe: (result: ObservableHandle) => void): void; /** the `error.type` attribute value for a thrown value: the error's class, else its type */ export declare function errorType(error: unknown): string; export interface SpanOptions { /** instrumentation scope, `@astroscope/`; defaults to `@astroscope/node` */ scope?: string | undefined; attributes?: Attributes | undefined; kind?: SpanKind | undefined; /** parent context; defaults to the active one (the request span inside a request) */ parent?: Context | undefined; } export interface StartedSpan { span: Span; /** the context with `span` active — pass as `parent` to nest children */ context: Context; } /** starts a span the caller ends itself; `withSpan` for work that is one function */ export declare function startSpan(name: string, options?: SpanOptions): StartedSpan; /** * Runs `fn` inside a span: status from the outcome, the span active for * everything `fn` awaits. A synchronous `fn` stays synchronous — no promise * is allocated on the common path. */ export declare function withSpan(name: string, options: SpanOptions, fn: () => MaybePromise): MaybePromise; //#endregion //# sourceMappingURL=telemetry.d.ts.map