Skip to content

Commit

Permalink
fix(exporter-prometheus): add appendTimestamp option to ExporterConfig
Browse files Browse the repository at this point in the history
Signed-off-by: Antonio Franco <[email protected]>
  • Loading branch information
antoniomrfranco committed Nov 24, 2020
1 parent 7242c76 commit 835cd73
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ export class PrometheusExporter implements MetricExporter {
port: 9464,
endpoint: '/metrics',
prefix: '',
appendTimestamp: true,
};

private readonly _logger: api.Logger;
private readonly _port: number;
private readonly _endpoint: string;
private readonly _server: Server;
private readonly _prefix?: string;
private readonly _appendTimestamp?: boolean;
private _serializer: PrometheusSerializer;
private _batcher = new PrometheusLabelsBatcher();

Expand All @@ -56,8 +58,9 @@ export class PrometheusExporter implements MetricExporter {
this._logger = config.logger || new NoopLogger();
this._port = config.port || PrometheusExporter.DEFAULT_OPTIONS.port;
this._prefix = config.prefix || PrometheusExporter.DEFAULT_OPTIONS.prefix;
this._appendTimestamp = config.appendTimestamp ?? PrometheusExporter.DEFAULT_OPTIONS.appendTimestamp;
this._server = createServer(this._requestHandler);
this._serializer = new PrometheusSerializer(this._prefix);
this._serializer = new PrometheusSerializer(this._prefix, this._appendTimestamp);

this._endpoint = (
config.endpoint || PrometheusExporter.DEFAULT_OPTIONS.endpoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ export interface ExporterConfig {
* */
prefix?: string;

/**
* Append timestamp to metrics
* @default true
*/
appendTimestamp?: boolean;

/**
* Endpoint the metrics should be exposed at with preceding slash
* @default '/metrics'
Expand Down

0 comments on commit 835cd73

Please sign in to comment.