import type pino from 'pino'; import type { NodeSDKConfiguration } from '@opentelemetry/sdk-node'; import { REQUEST_ID_PARAM_NAME, USER_ID_PARAM_NAME, USER_LANGUAGE_PARAM_NAME } from './lib/consts'; import type { LoggingLevel, NodeKitLogger } from './lib/logging'; export interface AppConfig { appName?: string; appVersion?: string; appEnv?: string; appInstallation?: string; appDevMode?: boolean; nkDefaultSensitiveKeys?: string[]; nkDefaultSensitiveHeaders?: string[]; nkDefaultHeadersWithSensitiveUrls?: string[]; nkDefaultSensitiveQueryParams?: string[]; /** * Default timeout for shutdown handlers in milliseconds. * Used when appShutdownTimeout is not specified. * @default 20000 */ nkDefaultShutdownTimeout?: number; appSensitiveKeys?: string[]; appSensitiveHeaders?: string[]; appHeadersWithSensitiveUrls?: string[]; appSensitiveQueryParams?: string[]; appLoggingDestination?: pino.DestinationStream; appLoggingLevel?: LoggingLevel; appLogger?: NodeKitLogger; appTracingEnabled?: boolean; /** * Service name for all created spans. * @default appName from AppConfig */ appTracingServiceName?: string; /** * Enable debug for tracing with DiagLogLevel.DEBUG. Will be printed with pino. * @default false */ appTracingDebugLogging?: boolean; /** * Tracing sampler. By default write all spans. * @default tracing.TraceIdRatioBasedSampler(1) */ appTracingSampler?: NodeSDKConfiguration['sampler']; /** * Tracing span exporter. By default write all spans. * @default OTLPTraceExporter({ url: appTracingCollectorEndpoint } */ appTracingSpanExporter?: NodeSDKConfiguration['traceExporter']; /** * Additional autoinstrumentations. * @default [] */ appTracingInstrumentations?: NodeSDKConfiguration['instrumentations']; /** * Tracing collector endpoint. * @default http://localhost:4318/v1/traces */ appTracingCollectorEndpoint?: string; /** * Protocols to transport trace data. * https://opentelemetry.io/docs/languages/js/exporters/#otlp-dependencies * @default HTTP/JSON */ appTracingCollectorProtocol?: 'HTTP/JSON' | 'HTTP/Proto' | 'gRPC'; /** * Disable TLS for gRPC protocol. * @default undefined */ appTracingDisableTLS?: boolean | undefined; /** * Experimental: bridge OpenTelemetry Log Records into pino. * * This option may be removed or changed in future versions without a * backwards-compatible migration path. * * When enabled, a PinoLogRecordProcessor is registered as the global * OTel LoggerProvider. Log records emitted by OTel-instrumented libraries * (e.g. `@opentelemetry/instrumentation-openai`) will be written to the * NodeKit pino logger instead of being silently dropped. * * Each bridged log line contains all original OTel attributes plus * `otelScope`, `traceId` and `spanId` fields. * * Note: `otelScope`, `traceId` and `spanId` take precedence over any OTel * attributes with the same names. * * Note: when enabled, env-based OTel Logs configuration is ignored by the SDK * (OTEL_LOGS_EXPORTER, OTEL_EXPORTER_OTLP_LOGS_ENDPOINT, etc.) — explicit * processors take priority over env configuration. * * Note: must be enabled during NodeKit initialization, before any other code * registers an OpenTelemetry LoggerProvider — the global OTel provider can * only be set once per process. * @default false */ experimentalAppTracingLogsBridge?: boolean; appTelemetryChHost?: string; appTelemetryChPort?: string; appTelemetryChAuth?: string; appTelemetryChDatabase?: string; appTelemetryChTables?: { [name: string]: { [name: string]: 'number' | 'string' | 'timestamp'; }; }; appTelemetryChSendInterval?: number; appTelemetryChBatchSize?: number; appTelemetryChBacklogSize?: number; appTelemetryChMirrorToLogs?: boolean; /** * Timeout for shutdown handlers in milliseconds. * Overrides nkDefaultShutdownTimeout when specified. */ appShutdownTimeout?: number; } export interface AppContextParams { [REQUEST_ID_PARAM_NAME]?: string; [USER_ID_PARAM_NAME]?: string; [USER_LANGUAGE_PARAM_NAME]?: string; } export interface AppDynamicConfig { } export type Dict = { [key: string]: unknown; }; export interface ShutdownHandler { (signal: 'SIGTERM' | 'SIGINT'): Promise | void; } export interface TelemetryClickhouseTableDescription { [name: string]: 'number' | 'string' | 'timestamp'; } export { SpanKind } from '@opentelemetry/api';