UNPKG

@brizz/sdk

Version:

OpenTelemetry-based observability SDK for AI applications

139 lines (125 loc) 5.07 kB
import { LogRecordExporter } from '@opentelemetry/sdk-logs'; import { MetricReader } from '@opentelemetry/sdk-metrics'; import { SpanExporter } from '@opentelemetry/sdk-trace-base'; import { LogBody, SeverityNumber } from '@opentelemetry/api-logs'; export { SeverityNumber } from '@opentelemetry/api-logs'; import { SpanProcessor } from '@opentelemetry/sdk-trace-node'; import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http'; interface IInstrumentModules { openAI?: unknown; anthropic?: unknown; cohere?: unknown; google_vertexai?: unknown; google_aiplatform?: unknown; bedrock?: unknown; pinecone?: unknown; langchain?: { chains?: unknown; agents?: unknown; tools?: unknown; }; llamaindex?: unknown; chromadb?: unknown; qdrant?: unknown; together?: unknown; vercelAI?: unknown; } declare enum LogLevel { NONE = 0, ERROR = 1, WARN = 2, INFO = 3, DEBUG = 4 } interface ILogger { debug: (msg: string, ...meta: unknown[]) => void; info: (msg: string, ...meta: unknown[]) => void; warn: (msg: string, ...meta: unknown[]) => void; error: (msg: string, ...meta: unknown[]) => void; setLevel: (level: LogLevel) => void; getLevel: () => LogLevel; } declare const logger: ILogger; declare function setLogLevel(level: LogLevel | string): void; declare function getLogLevel(): LogLevel; type MaskingMode = 'partial' | 'full'; interface IPatternBasedMaskingRule { readonly patterns: readonly (IPatternEntry | string)[]; readonly mode?: MaskingMode; } interface IPatternEntry { readonly name?: string | undefined; readonly pattern: string; } interface IAttributesMaskingRule extends IPatternBasedMaskingRule { readonly patterns: readonly (IPatternEntry | string)[]; readonly attributePattern?: string; readonly mode?: MaskingMode; } interface IEventMaskingRule extends IAttributesMaskingRule { readonly eventNamePattern?: string; } interface ISpanMaskingConfig { readonly disableDefaultRules?: boolean; readonly rules?: readonly IAttributesMaskingRule[]; } interface ILogMaskingConfig { readonly disableDefaultRules?: boolean; readonly maskBody?: boolean; readonly rules?: readonly IAttributesMaskingRule[]; } type IEventMaskingConfig = ILogMaskingConfig; interface IMaskingConfig { readonly spanMasking?: ISpanMaskingConfig; readonly eventMasking?: IEventMaskingConfig; } declare const DEFAULT_PII_PATTERNS: IPatternEntry[]; declare function maskValue(value: unknown, rule: IPatternBasedMaskingRule): unknown; declare function maskAttributes(attributes: Record<string, unknown>, rules: readonly IAttributesMaskingRule[], outputOriginalValue?: boolean): Record<string, unknown>; interface IBrizzInitializeOptions { appName?: string; baseUrl?: string; apiKey?: string; headers?: Record<string, string>; disableBatch?: boolean; masking?: boolean | IMaskingConfig; logLevel?: LogLevel | string; instrumentModules?: IInstrumentModules; disableNodeSdk?: boolean; customSpanExporter?: SpanExporter; customLogExporter?: LogRecordExporter; customMetricReader?: MetricReader; } declare class _Brizz { private static instance; private _initialized; private _sdk; static getInstance(): _Brizz; initialize(options: IBrizzInitializeOptions): void; private setupInstrumentation; private createAndStartNodeSDK; private initializeModules; private detectModuleSystem; shutdown(): Promise<void>; private shutdownModules; } declare const Brizz: _Brizz; declare function emitEvent(name: string, attributes?: Record<string, string | number | boolean>, body?: LogBody, severityNumber?: SeverityNumber): void; declare function getSpanExporter(): SpanExporter; declare function getSpanProcessor(): SpanProcessor; declare function withSessionId<F extends (this: any, ...args: any[]) => any>(sessionId: string, fn: F, thisArg?: ThisParameterType<F>): F; declare function callWithSessionId<A extends unknown[], F extends (...args: A) => ReturnType<F>>(sessionId: string, fn: F, thisArg?: ThisParameterType<F>, ...args: A): ReturnType<F>; declare function getMetricsExporter(): OTLPMetricExporter; declare function getMetricsReader(): MetricReader; interface RuntimeInfo { isESM: boolean; isCJS: boolean; nodeVersion: string; supportsLoaderAPI: boolean; supportsRegister: boolean; } declare function detectRuntime(): RuntimeInfo; declare namespace init { export { }; } export { Brizz, DEFAULT_PII_PATTERNS, type IAttributesMaskingRule, type IBrizzInitializeOptions, type IEventMaskingConfig, type IEventMaskingRule, type IInstrumentModules, type ILogMaskingConfig, type ILogger, type IMaskingConfig, type ISpanMaskingConfig, LogLevel, type MaskingMode, type RuntimeInfo, callWithSessionId, detectRuntime, emitEvent, getLogLevel, getMetricsExporter, getMetricsReader, getSpanExporter, getSpanProcessor, init, logger, maskAttributes, maskValue, setLogLevel, withSessionId };