ds-sfcoe-ailabs
Version:
AI-powered code review tool with static analysis integration for comprehensive code quality assessment.
190 lines (189 loc) • 6.31 kB
TypeScript
import type { DatadogMetricsConfig } from '../../utils/index.js';
/**
* Datadog metrics client for sending custom metrics
* Provides a wrapper around the datadog-metrics library with initialization and error handling
*
* @example
* ```typescript
* // Initialize the metrics client
* const config = { apiKey: 'your-key', prefix: 'app.' };
* DatadogMetrics.initialize(config);
*
* // Send metrics
* DatadogMetrics.increment('requests.count', 1, ['service:api']);
* DatadogMetrics.gauge('memory.usage', 75.5, ['unit:percentage']);
* ```
*/
export declare class DatadogMetrics {
private static metricsClient;
private static config;
/**
* Initialize the Datadog metrics client with configuration
*
* @param config - The Datadog metrics configuration object
* @returns The initialized metrics client instance
* @example
* ```typescript
* const config = {
* apiKey: 'your-datadog-api-key',
* prefix: 'myapp.',
* host: 'localhost'
* };
* const client = DatadogMetrics.initialize(config);
* ```
*/
static initialize(config: DatadogMetricsConfig): any;
/**
* Get the configured metrics client instance
*
* @returns The metrics client instance
* @throws Error if metrics client is not initialized
* @example
* ```typescript
* try {
* const client = DatadogMetrics.getInstance();
* client.increment('custom.metric');
* } catch (error) {
* console.error('Metrics client not initialized');
* }
* ```
*/
static getInstance(): any;
/**
* Check if metrics client is initialized
*
* @returns True if the metrics client is initialized, false otherwise
* @example
* ```typescript
* if (DatadogMetrics.isInitialized()) {
* DatadogMetrics.increment('app.ready');
* }
* ```
*/
static isInitialized(): boolean;
/**
* Get current configuration
*
* @returns The current Datadog metrics configuration or null if not set
* @example
* ```typescript
* const config = DatadogMetrics.getConfig();
* if (config) {
* console.log(`Using prefix: ${config.prefix}`);
* }
* ```
*/
static getConfig(): DatadogMetricsConfig | null;
/**
* Send a counter metric
*
* @param metric - The metric name to increment
* @param value - The value to increment by (default: 1)
* @param tags - Array of tags to attach to the metric
* @example
* ```typescript
* DatadogMetrics.increment('api.requests'); // Increment by 1
* DatadogMetrics.increment('user.actions', 5, ['action:login']);
* ```
*/
static increment(metric: string, value?: number, tags?: string[]): void;
/**
* Send a decrement metric
*
* @param metric - The metric name to decrement
* @param value - The value to decrement by (default: 1)
* @param tags - Array of tags to attach to the metric
* @example
* ```typescript
* DatadogMetrics.decrement('queue.size'); // Decrement by 1
* DatadogMetrics.decrement('active.connections', 3, ['service:db']);
* ```
*/
static decrement(metric: string, value?: number, tags?: string[]): void;
/**
* Send a gauge metric
*
* @param metric - The metric name to set a gauge value for
* @param value - The gauge value to set
* @param tags - Array of tags to attach to the metric
* @example
* ```typescript
* DatadogMetrics.gauge('memory.usage', 75.5, ['unit:percentage']);
* DatadogMetrics.gauge('queue.depth', 42, ['queue:processing']);
* ```
*/
static gauge(metric: string, value: number, tags?: string[]): void;
/**
* Send a histogram metric
*
* @param metric - The metric name to send histogram data for
* @param value - The histogram value to record
* @param tags - Array of tags to attach to the metric
* @example
* ```typescript
* DatadogMetrics.histogram('response.time', 250, ['endpoint:users']);
* DatadogMetrics.histogram('file.size', 1024, ['type:image']);
* ```
*/
static histogram(metric: string, value: number, tags?: string[]): void;
/**
* Send a timing metric (histogram with time unit)
*
* @param metric - The metric name to send timing data for
* @param value - The timing value in milliseconds
* @param tags - Array of tags to attach to the metric
* @example
* ```typescript
* const start = Date.now();
* // ... perform operation ...
* DatadogMetrics.timing('operation.duration', Date.now() - start, ['operation:create']);
* ```
*/
static timing(metric: string, value: number, tags?: string[]): void;
/**
* Send a distribution metric
*
* @param metric - The metric name to send distribution data for
* @param value - The distribution value to record
* @param tags - Array of tags to attach to the metric
* @example
* ```typescript
* DatadogMetrics.distribution('score.review', 8.5, ['reviewer:ai']);
* DatadogMetrics.distribution('latency.network', 125, ['region:us-east']);
* ```
*/
static distribution(metric: string, value: number, tags?: string[]): void;
/**
* Send a set metric - not directly supported, use gauge instead
*
* @param metric - The metric name to set a value for
* @param value - The value to set (string or number)
* @param tags - Array of tags to attach to the metric
* @example
* ```typescript
* DatadogMetrics.set('users.unique', 'user123', ['action:login']);
* DatadogMetrics.set('ips.unique', '192.168.1.1', ['endpoint:api']);
* ```
*/
static set(metric: string, value: string | number, tags?: string[]): void;
/**
* Flush buffered metrics immediately
*
* @example
* ```typescript
* // Send all pending metrics immediately
* DatadogMetrics.flush();
* ```
*/
static flush(): void;
/**
* Close the metrics client and clean up resources
*
* @example
* ```typescript
* // Clean shutdown of metrics client
* DatadogMetrics.close();
* ```
*/
static close(): void;
}