///
import { inspect } from 'util';
import { CouchbaseLogger } from './logger.js';
import { Meter, ValueRecorder } from './metrics.js';
/**
* 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;
}
/**
* 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>;
}
/**
* 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;
}
/**
* A logging-based meter implementation that records metrics using HDR histograms
* and periodically reports percentile statistics.
*
* This is the meter a {@link Cluster} uses by default. It is exported so it can
* be combined with other meters in a {@link MeterGroup}.
*
* @category Observability
*/
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; falls back to
* {@link createDefaultLogger} when omitted.
* @param emitInterval - The interval in milliseconds between reports.
* Defaults to 600_000 (10 minutes) when omitted.
*/
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): 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
*/
[inspect.custom](): Record;
/**
* @internal
*/
toJSON(): Record;
/**
* Exposes only the meter's configuration. The reporter is deliberately
* omitted: it holds a periodic-flush timer handle (`setInterval`), a circular
* structure that breaks `JSON.stringify` and produces noisy `util.inspect`
* output. Custom meters should do the same — see the observability guide.
*
* @internal
*/
private _toConfigSnapshot;
}
export {};