k6-perf-reporter 1.7.1 → 1.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +7 -0
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
- package/src/cli.ts +7 -0
package/dist/cli.js
CHANGED
|
@@ -6,6 +6,7 @@ const config_1 = require("./config");
|
|
|
6
6
|
const data_collector_1 = require("./data-collector");
|
|
7
7
|
const datasources_1 = require("./datasources");
|
|
8
8
|
const reporters_1 = require("./reporters");
|
|
9
|
+
const logger_1 = require("./logger");
|
|
9
10
|
const VALID_REPORTERS = ["cli", "json", "markdown", "slack"];
|
|
10
11
|
function defaultOutputPath(name, runId) {
|
|
11
12
|
const extensions = {
|
|
@@ -17,12 +18,15 @@ function defaultOutputPath(name, runId) {
|
|
|
17
18
|
}
|
|
18
19
|
async function runReporter(name, report, options, configInstance) {
|
|
19
20
|
const output = options.output || defaultOutputPath(name, report.runId);
|
|
21
|
+
logger_1.logger.info(`runReporter: starting reporter=${name}${output ? `, output=${output}` : ""}`);
|
|
20
22
|
switch (name) {
|
|
21
23
|
case "json":
|
|
22
24
|
new reporters_1.JsonReporter().report(report, output);
|
|
25
|
+
logger_1.logger.info(`runReporter: json report generated`);
|
|
23
26
|
break;
|
|
24
27
|
case "markdown":
|
|
25
28
|
new reporters_1.MarkdownReporter().report(report, output);
|
|
29
|
+
logger_1.logger.info(`runReporter: markdown report generated`);
|
|
26
30
|
break;
|
|
27
31
|
case "slack": {
|
|
28
32
|
const slackConfig = configInstance.getSlackConfig();
|
|
@@ -31,11 +35,13 @@ async function runReporter(name, report, options, configInstance) {
|
|
|
31
35
|
}
|
|
32
36
|
const slackReporter = new reporters_1.SlackReporter(slackConfig.token, slackConfig.channel);
|
|
33
37
|
await slackReporter.report(report);
|
|
38
|
+
logger_1.logger.info(`runReporter: slack report sent to channel=${slackConfig.channel}`);
|
|
34
39
|
console.log("Report sent to Slack");
|
|
35
40
|
break;
|
|
36
41
|
}
|
|
37
42
|
case "cli":
|
|
38
43
|
new reporters_1.CliReporter().report(report);
|
|
44
|
+
logger_1.logger.info(`runReporter: cli report printed`);
|
|
39
45
|
break;
|
|
40
46
|
}
|
|
41
47
|
}
|
|
@@ -69,6 +75,7 @@ function main() {
|
|
|
69
75
|
const report = await collector.collect(options.runId, options.startTime || "-1h", options.endTime || "now()");
|
|
70
76
|
if (options.report) {
|
|
71
77
|
const reporters = options.report.split(",").map((r) => r.trim());
|
|
78
|
+
logger_1.logger.info(`generate: using --report with reporters=[${reporters.join(", ")}]`);
|
|
72
79
|
const invalid = reporters.filter((r) => !VALID_REPORTERS.includes(r));
|
|
73
80
|
if (invalid.length > 0) {
|
|
74
81
|
throw new Error(`Invalid reporter(s): ${invalid.join(", ")}. Valid options: ${VALID_REPORTERS.join(", ")}`);
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AAEA,yCAAoC;AACpC,qCAAkD;AAClD,qDAAiD;AACjD,+CAAiD;AACjD,2CAAyF;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AAEA,yCAAoC;AACpC,qCAAkD;AAClD,qDAAiD;AACjD,+CAAiD;AACjD,2CAAyF;AACzF,qCAAkC;AAGlC,MAAM,eAAe,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,CAAU,CAAC;AAGtE,SAAS,iBAAiB,CAAC,IAAkB,EAAE,KAAa;IAC1D,MAAM,UAAU,GAA0C;QACxD,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACf,CAAC;IACF,MAAM,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAC7B,OAAO,GAAG,CAAC,CAAC,CAAC,UAAU,KAAK,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,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AAC;YACrF,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;YACxE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,mBAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,wBAAwB,CAAC;SACrC,MAAM,CAAC,GAAG,EAAE;QACX,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgGX,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEL,mBAAO,CAAC,KAAK,EAAE,CAAC;AAClB,CAAC;AAED,IAAI,EAAE,CAAC"}
|
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { Config, DataSourceType } from "./config";
|
|
|
5
5
|
import { DataCollector } from "./data-collector";
|
|
6
6
|
import { createDataSource } from "./datasources";
|
|
7
7
|
import { JsonReporter, CliReporter, SlackReporter, MarkdownReporter } from "./reporters";
|
|
8
|
+
import { logger } from "./logger";
|
|
8
9
|
import { ReporterResponse } from "./types";
|
|
9
10
|
|
|
10
11
|
const VALID_REPORTERS = ["cli", "json", "markdown", "slack"] as const;
|
|
@@ -26,12 +27,15 @@ async function runReporter(
|
|
|
26
27
|
configInstance: Config
|
|
27
28
|
): Promise<void> {
|
|
28
29
|
const output = options.output || defaultOutputPath(name, report.runId);
|
|
30
|
+
logger.info(`runReporter: starting reporter=${name}${output ? `, output=${output}` : ""}`);
|
|
29
31
|
switch (name) {
|
|
30
32
|
case "json":
|
|
31
33
|
new JsonReporter().report(report, output);
|
|
34
|
+
logger.info(`runReporter: json report generated`);
|
|
32
35
|
break;
|
|
33
36
|
case "markdown":
|
|
34
37
|
new MarkdownReporter().report(report, output);
|
|
38
|
+
logger.info(`runReporter: markdown report generated`);
|
|
35
39
|
break;
|
|
36
40
|
case "slack": {
|
|
37
41
|
const slackConfig = configInstance.getSlackConfig();
|
|
@@ -40,11 +44,13 @@ async function runReporter(
|
|
|
40
44
|
}
|
|
41
45
|
const slackReporter = new SlackReporter(slackConfig.token, slackConfig.channel);
|
|
42
46
|
await slackReporter.report(report);
|
|
47
|
+
logger.info(`runReporter: slack report sent to channel=${slackConfig.channel}`);
|
|
43
48
|
console.log("Report sent to Slack");
|
|
44
49
|
break;
|
|
45
50
|
}
|
|
46
51
|
case "cli":
|
|
47
52
|
new CliReporter().report(report);
|
|
53
|
+
logger.info(`runReporter: cli report printed`);
|
|
48
54
|
break;
|
|
49
55
|
}
|
|
50
56
|
}
|
|
@@ -86,6 +92,7 @@ function main(): void {
|
|
|
86
92
|
|
|
87
93
|
if (options.report) {
|
|
88
94
|
const reporters = options.report.split(",").map((r: string) => r.trim());
|
|
95
|
+
logger.info(`generate: using --report with reporters=[${reporters.join(", ")}]`);
|
|
89
96
|
const invalid = reporters.filter((r: string) => !VALID_REPORTERS.includes(r as ReporterName));
|
|
90
97
|
if (invalid.length > 0) {
|
|
91
98
|
throw new Error(`Invalid reporter(s): ${invalid.join(", ")}. Valid options: ${VALID_REPORTERS.join(", ")}`);
|