UNPKG

sfcoe-ailabs

Version:

AI-powered code review tool with static analysis integration for comprehensive code quality assessment.

149 lines (148 loc) 4.99 kB
import winston from 'winston'; import { type DatadogLoggerConfig } from '../observability/logging/index.js'; import { type DatadogMetricsConfig } from '../observability/metrics/index.js'; /** * Centralized logger utility for debug and error logging * This serves as a facade to the Datadog logger backend */ export declare class Logger { private static initialized; /** * Initialize the logger with Datadog configuration * * @param config - The Datadog logger configuration object * @returns The initialized Winston logger instance */ static initialize(config: DatadogLoggerConfig): winston.Logger; /** * Check if logger is initialized * * @returns True if the logger is initialized, false otherwise */ static isInitialized(): boolean; /** * Log debug messages (only when debug is enabled) * * @param message - The debug message to log * @param args - Additional arguments to include in the log metadata */ static debug(message: string, ...args: unknown[]): void; /** * Log info messages */ static info(message: string, ...args: unknown[]): void; /** * Log warning messages */ static warn(message: string, ...args: unknown[]): void; /** * Log error messages */ static error(message: string, ...args: unknown[]): void; /** * Log with custom level and metadata (backward compatibility) */ static log(level: string, message: string, ...args: unknown[]): void; /** * Convert variadic arguments to metadata object for structured logging */ private static argsToMeta; } /** * High-level metrics utility for the application * This serves as a facade to the Datadog metrics backend */ export declare class Metrics { private static initialized; /** * Initialize the metrics system with Datadog configuration */ static initialize(config: DatadogMetricsConfig): void; /** * Check if metrics system is initialized */ static isInitialized(): boolean; /** * Send a counter metric */ static increment(metric: string, value?: number, tags?: string[]): void; /** * Send a decrement metric */ static decrement(metric: string, value?: number, tags?: string[]): void; /** * Send a gauge metric */ static gauge(metric: string, value: number, tags?: string[]): void; /** * Send a histogram metric */ static histogram(metric: string, value: number, tags?: string[]): void; /** * Send a timing metric */ static timing(metric: string, value: number, tags?: string[]): void; /** * Send a distribution metric */ static distribution(metric: string, value: number, tags?: string[]): void; /** * Send a set metric */ static set(metric: string, value: string | number, tags?: string[]): void; /** * Flush buffered metrics immediately */ static flush(): void; /** * Close the metrics client */ static close(): void; } /** * Utility to initialize observability components (logging and metrics) */ export declare class ObservabilityInitializer { private static initialized; /** * Initialize both logging and metrics with provided configuration * * @param flags Record of command flags that will be included in logs and metrics. * The following flags are included by default: * - pull-request-id: Added as pullRequestId in logs and pull-request-id tag in metrics * - repo-dir: Added as repoDir in logs and repo-dir tag in metrics * - from: Added as from in logs and from tag in metrics * - to: Added as to in logs and to tag in metrics * - ai-provider: Added as aiProvider in logs and ai-provider tag in metrics * - ai-model: Added as aiModel in logs and ai-model tag in metrics * - git-provider: Added as gitProvider in logs and git-provider tag in metrics * - git-owner: Added as gitOwner in logs and git-owner tag in metrics * - git-repo: Added as gitRepo in logs and git-repo tag in metrics * * @example * ```typescript * // Basic usage with command flags * ObservabilityInitializer.initialize(flags); * * // Usage with custom flags object * ObservabilityInitializer.initialize({ * 'pull-request-id': '123', * 'ai-provider': 'OpenAI', * 'custom-flag': 'custom-value' // This won't be included unless added to default list * }); * ``` */ static initialize(flags?: Record<string, unknown>): void; /** * Check if observability is initialized */ static isInitialized(): boolean; /** * Get default flags to include in observability metadata */ static getDefaultFlagsToInclude(): string[]; /** * Build configuration from environment variables and flags with custom flag inclusion */ private static buildConfigFromEnv; }