1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
18 | return new (P || (P = Promise))(function (resolve, reject) {
|
19 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
20 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
21 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
22 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
23 | });
|
24 | };
|
25 | Object.defineProperty(exports, "__esModule", { value: true });
|
26 | const automation_client_1 = require("@atomist/automation-client");
|
27 | const cluster = require("cluster");
|
28 | const _ = require("lodash");
|
29 |
|
30 |
|
31 |
|
32 | class SdmGoalMetricReportingAutomationEventListener extends automation_client_1.AutomationEventListenerSupport {
|
33 | startupSuccessful(client) {
|
34 | return __awaiter(this, void 0, void 0, function* () {
|
35 | if (cluster.isMaster && client.configuration.statsd.enabled) {
|
36 | this.statsd = client.configuration.statsd.__instance;
|
37 | }
|
38 | });
|
39 | }
|
40 | eventIncoming(payload) {
|
41 | if (cluster.isMaster && !!this.statsd && process.env.ATOMIST_ISOLATED_GOAL !== "forked") {
|
42 | const ts = _.get(payload.data, "SdmGoal[0].ts");
|
43 | const name = _.get(payload.data, "SdmGoal[0].name");
|
44 | if (!!name) {
|
45 | this.statsd.increment(`counter.goal`, 1, [`atomist_goal:${name}`], () => {
|
46 | });
|
47 | }
|
48 | if (ts) {
|
49 | this.statsd.timing("timer.goal.round_trip", Date.now() - ts, 1, {}, () => {
|
50 | });
|
51 | }
|
52 | }
|
53 | }
|
54 | }
|
55 | exports.SdmGoalMetricReportingAutomationEventListener = SdmGoalMetricReportingAutomationEventListener;
|
56 |
|
\ | No newline at end of file |