/// import { ExportResult } from '@opentelemetry/core'; import { MetricExporter, MetricRecord } from '@opentelemetry/metrics'; import { IncomingMessage, ServerResponse } from 'http'; import { ExporterConfig } from './export/types'; export declare class PrometheusExporter implements MetricExporter { static readonly DEFAULT_OPTIONS: { host: undefined; port: number; endpoint: string; prefix: string; appendTimestamp: boolean; }; private readonly _host?; private readonly _port; private readonly _endpoint; private readonly _server; private readonly _prefix?; private readonly _appendTimestamp; private _serializer; private _batcher; /** * Constructor * @param config Exporter configuration * @param callback Callback to be called after a server was started */ constructor(config?: ExporterConfig, callback?: () => void); /** * Saves the current values of all exported {@link MetricRecord}s so that * they can be pulled by the Prometheus backend. * * In its current state, the exporter saves the current values of all metrics * when export is called and returns them when the export endpoint is called. * In the future, this should be a no-op and the exporter should reach into * the metrics when the export endpoint is called. As there is currently no * interface to do this, this is our only option. * * @param records Metrics to be sent to the prometheus backend * @param cb result callback to be called on finish */ export(records: MetricRecord[], cb: (result: ExportResult) => void): void; /** * Shuts down the export server and clears the registry */ shutdown(): Promise; /** * Stops the Prometheus export server */ stopServer(): Promise; /** * Starts the Prometheus export server */ startServer(): Promise; /** * Request handler that responds with the current state of metrics * @param request Incoming HTTP request of server instance * @param response HTTP response objet used to response to request */ getMetricsRequestHandler(_request: IncomingMessage, response: ServerResponse): void; /** * Request handler used by http library to respond to incoming requests * for the current state of metrics by the Prometheus backend. * * @param request Incoming HTTP request to export server * @param response HTTP response object used to respond to request */ private _requestHandler; /** * Responds to incoming message with current state of all metrics. */ private _exportMetrics; /** * Responds with 404 status code to all requests that do not match the configured endpoint. */ private _notFound; }