couchbase
Version:
The official Couchbase Node.js Client Library.
121 lines (120 loc) • 3.17 kB
TypeScript
/**
* @internal
*/
import { CouchbaseLogger } from './logger';
import { Meter, ValueRecorder } from './metrics';
/**
* Represents the percentile values for a set of recorded metrics.
*
* @internal
*/
interface PercentileReport {
/**
* Total count of all recorded values.
*/
total_count: number;
/**
* Mapping of percentile value (e.g., "50", "90") to recorded value.
*/
percentiles_us: Record<string, number>;
}
/**
* Represents a complete logging meter report with metadata.
*
* @internal
*/
interface LoggingMeterReport {
/**
* Metadata about the report.
*/
meta: {
/**
* The interval (in seconds) at which reports are emitted.
*/
emit_interval_s: number;
};
/**
* Operations organized by service type.
*/
operations: Record<string, Record<string, PercentileReport>>;
}
/**
* Internal class for periodically emitting meter reports.
*
* @internal
*/
declare class LoggingMeterReporter {
private readonly _loggingMeter;
private readonly _emitInterval;
private readonly _logger;
private _timerId;
private _stopped;
constructor(loggingMeter: LoggingMeter, emitInterval: number, logger: CouchbaseLogger);
/**
* @internal
*/
start(): void;
/**
* @internal
*/
stop(): void;
/**
* @internal
*/
report(): void;
/**
* @internal
*/
toJSON(): Record<string, any>;
}
/**
* A logging-based meter implementation that records metrics using HDR histograms
* and periodically reports percentile statistics.
*
* @internal
*/
export declare class LoggingMeter implements Meter {
private readonly _recorders;
private readonly _reporter;
private readonly _emitInterval;
/**
* Creates a new LoggingMeter with the specified flush interval.
*
* @param logger - The logger to be used by the LoggingMeter.
* @param emitInterval - The interval in milliseconds between reports (default: 600000ms = 10 minutes).
*/
constructor(logger: CouchbaseLogger, emitInterval?: number);
/**
* Gets the meter's LoggingMeterReporter.
*
* @internal
*/
get reporter(): LoggingMeterReporter;
/**
* Gets or creates a value recorder for the specified metric name and tags.
*
* @param _name - Unused.
* @param tags - Key-value pairs that categorize the metric.
* @returns A value recorder for recording values.
*/
valueRecorder(_name: string, tags: Record<string, string>): ValueRecorder;
/**
* Creates a report of all recorded metrics and resets the histograms.
*
* @returns The logging meter report with percentile statistics.
*/
createReport(): LoggingMeterReport | null;
/**
* Stops the threshold logging reporter and cleans up resources.
*
* This method should be called when shutting down the application or when
* the tracer is no longer needed to ensure the periodic reporting timer
* is properly cleared.
*/
cleanup(): void;
/**
* @internal
*/
toJSON(): Record<string, any>;
}
export {};