Skip to content

Commit

Permalink
feat(datadog): add option to disable gzip-size
Browse files Browse the repository at this point in the history
  • Loading branch information
brandondoran committed Oct 31, 2018
1 parent d8d494b commit 3cb7e7a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/reporters/datadog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@ const getTimestamp = () => parseInt(`${new Date().getTime() / 1000}`, 10);

export interface DataDogStatsReporterOptions {
apiKey: string;
gzipSize: boolean;
metricName: string;
tags?: string[]
}

export class DataDogStatsReporter {
private readonly apiKey: string;
private readonly gzipSize: boolean;
private readonly metricName: string;
private readonly tags: string[];
private readonly url: string;

constructor(options: DataDogStatsReporterOptions) {
this.apiKey = options.apiKey;
this.gzipSize = options.gzipSize
this.metricName = options.metricName;
this.tags = options.tags || [];
this.url = `${API_URL}?api_key=${this.apiKey}`;
Expand All @@ -49,7 +52,9 @@ export class DataDogStatsReporter {
const { assets, outputPath } = stats;
const now = getTimestamp();
const promises = assets.map(async (asset: any) => {
const size = await gzipSize.file(path.join(outputPath, asset.name));
const size = this.gzipSize === false
? asset.size
: await gzipSize.file(path.join(outputPath, asset.name));
return {
metric: `${this.metricName}.bytes${path.extname(asset.name)}`,
points: [[ now, size ]],
Expand Down

0 comments on commit 3cb7e7a

Please sign in to comment.