import { URL } from "node:url"; import { DebugLoggerFunction } from "node:util"; import { Socket } from "./socket.js"; interface DebugLogger extends DebugLoggerFunction { enabled?: boolean; } /** * Enum of metrics types * @see https://github.com/statsd/statsd/blob/master/docs/metric_types.md */ export declare enum Types { counter = "c", timing = "ms", gauge = "g", set = "s" } export type Tags = { [key: string]: string | null; } | string[]; export interface Options { host?: string | URL; namespace?: string; bufferSize?: number; bufferFlushTimeout?: number; onError?: (error: Error) => void; debug?: DebugLoggerFunction; udpDnsCache?: boolean; udpDnsCacheTTL?: number; customSocket?: Socket; tags?: Tags; } /** * Statsd Client * @alias module:dats.Client */ declare class Client { protected bufferSize: number; protected bufferFlushTimeout: number; protected socket: Socket; protected buffer: { length: number; data: string; }; protected timeout: NodeJS.Timeout | null; protected timeoutActive: boolean; protected host: URL; protected namespace: string; protected debug: DebugLogger; protected isDebug: boolean; protected tags: string | undefined; constructor({ host, namespace, bufferSize, bufferFlushTimeout, udpDnsCache, udpDnsCacheTTL, debug, onError, customSocket, tags, }?: Options); connect(): Promise; protected buildMetric(type: Types, key: string, value?: number, sampling?: number): string; /** * @fires module:dats#error */ protected send(metric: string): void; protected refreshTimeout(): void; protected onTimeout(): void; protected push(string: string): void; /** * Flush the buffer batch */ protected flush(): void; protected createMetric(type: Types, key: string, value?: number, sampling?: number): void; getSupportedTypes(): typeof Types; counter(key: string, value?: number, sampling?: number): void; gauge(key: string, value?: number): void; set(key: string, value?: number): void; timing(key: string, value?: number, sampling?: number): void; /** * Close the client connection. * @returns {Promise} if no callback is passed */ close(done?: () => void): Promise | NodeJS.Immediate | void; } export default Client;