import * as metricTypes from './metric'; import * as reporterTypes from './reporter'; interface Tags { [key: string]: string | number; } interface Fields { [key: string]: string | number | boolean; } interface Metric { _init(...args: any[]): void; _read(): Fields | undefined; } declare class Measurement { private readonly createMetric; private readonly defaultTags; private readonly options; _metrics: Map; constructor(createMetric: () => T, defaultTags: Tags, options: any); tag(tags: Tags): T; _remove(tags: string): void; } interface MeasurementCreator { /** * Get or create counter measurement with options default tags. * @param tags Default tags that will be marked on every points. * This parameter is ignore when measurement already exist. */ counter(name: string, tags?: Tags, creatingOptions?: metricTypes.Counter.Options): Measurement & metricTypes.Counter; /** * Get or create gauge measurement with options default tags. * @param tags Default tags that will be marked on every points. * This parameter is ignore when measurement already exist. */ gauge(name: string, tags?: Tags): Measurement & metricTypes.Gauge; /** * Get or create histogram measurement with options default tags. * @param tags Default tags that will be marked on every points. * This parameter is ignore when measurement already exist. */ histogram(name: string, tags?: Tags, creatingOptions?: metricTypes.Histogram.Options): Measurement & metricTypes.Histogram; /** * Get or create timing measurement with options default tags. * @param tags Default tags that will be marked on every points. * This parameter is ignore when measurement already exist. */ timing(name: string, tags?: Tags, creatingOptions?: metricTypes.Histogram.Options): Measurement & metricTypes.Timing; } interface MetricsCollection extends MeasurementCreator { /** * Release the collection. * JavaScript has no weak-ref, so have to release explicitly to avoid memory leak. */ release(): void; } interface MeasurementPoint { name: string; /** stringified `Tags` */ tags: string; fields: Fields; } interface Reporter { send(points: MeasurementPoint[]): void; } /** * Report metrics via a reporter. * Setting new reporter will remove the old one. * * @param reporter * @param every seconds to report, default 30. */ declare function reportTo(reporter: Reporter, every?: number): void; /** * Create a new metrics collection and bind it to reporter. * * When a collection is no longer used, must release it to avoid memory leak. */ declare function newCollection(): MetricsCollection; export { Tags, Fields, Metric, MeasurementPoint, Measurement, MeasurementCreator, MetricsCollection, Reporter, reportTo, newCollection, reporterTypes as reporter, metricTypes as metric, };