notification-processor 4.19.3 → 4.19.5
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.
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
|
+
|
|
5
|
+
// Generated by CoffeeScript 2.7.0
|
|
6
|
+
(function () {
|
|
7
|
+
var IgnoredError;
|
|
8
|
+
|
|
9
|
+
module.exports = IgnoredError = function () {
|
|
10
|
+
var IgnoredError = function IgnoredError(message, cause) {
|
|
11
|
+
_classCallCheck(this, IgnoredError);
|
|
12
|
+
|
|
13
|
+
this.cause = cause;
|
|
14
|
+
this.name = this.constructor.name;
|
|
15
|
+
this.message = message;
|
|
16
|
+
this.stack = new Error().stack;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
;
|
|
20
|
+
|
|
21
|
+
IgnoredError.prototype = new Error();
|
|
22
|
+
|
|
23
|
+
IgnoredError.prototype.constructor = IgnoredError;
|
|
24
|
+
|
|
25
|
+
return IgnoredError;
|
|
26
|
+
}.call(this);
|
|
27
|
+
}).call(undefined);
|
|
@@ -6,7 +6,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
6
6
|
|
|
7
7
|
// Generated by CoffeeScript 2.7.0
|
|
8
8
|
(function () {
|
|
9
|
-
var AWS, MonitoringCenterObserver, Promise, _, debug, moment, retry;
|
|
9
|
+
var AWS, MESSAGE_PROPERTIES, MonitoringCenterObserver, Promise, TYPE_PROPERTIES, _, debug, moment, retry;
|
|
10
10
|
|
|
11
11
|
_ = require("lodash");
|
|
12
12
|
|
|
@@ -20,6 +20,10 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
20
20
|
|
|
21
21
|
moment = require("moment");
|
|
22
22
|
|
|
23
|
+
TYPE_PROPERTIES = ["cause.type", "type"];
|
|
24
|
+
|
|
25
|
+
MESSAGE_PROPERTIES = ["cause.message", "message"];
|
|
26
|
+
|
|
23
27
|
module.exports = MonitoringCenterObserver = function () {
|
|
24
28
|
function MonitoringCenterObserver(_ref) {
|
|
25
29
|
var sender = _ref.sender,
|
|
@@ -36,7 +40,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
36
40
|
|
|
37
41
|
_classCallCheck(this, MonitoringCenterObserver);
|
|
38
42
|
|
|
39
|
-
this.
|
|
43
|
+
this.registerRecord = this.registerRecord.bind(this);
|
|
40
44
|
this.sender = sender;
|
|
41
45
|
this.clientId = clientId;
|
|
42
46
|
this.app = app1;
|
|
@@ -53,28 +57,26 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
53
57
|
var _this = this;
|
|
54
58
|
|
|
55
59
|
observable.on("unsuccessful_non_retryable", function (payload) {
|
|
56
|
-
return _this.
|
|
60
|
+
return _this.registerRecord(payload, "unsuccessful");
|
|
57
61
|
});
|
|
58
62
|
observable.on("unsuccessful", function (payload) {
|
|
59
|
-
return _this.
|
|
63
|
+
return _this.registerRecord(payload, "unsuccessful");
|
|
60
64
|
});
|
|
61
65
|
observable.on("started", function (payload) {
|
|
62
|
-
return _this.
|
|
66
|
+
return _this.registerRecord(payload, "pending");
|
|
63
67
|
});
|
|
64
68
|
return observable.on("successful", function (payload) {
|
|
65
|
-
return _this.
|
|
69
|
+
return _this.registerRecord(payload, "successful");
|
|
66
70
|
});
|
|
67
71
|
}
|
|
68
72
|
}, {
|
|
69
|
-
key: "
|
|
70
|
-
value: function
|
|
73
|
+
key: "registerRecord",
|
|
74
|
+
value: function registerRecord(payload, executionStatus) {
|
|
71
75
|
var _this2 = this;
|
|
72
76
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return this._mapper(id, notification, error, executionStatus).then(function (record) {
|
|
77
|
+
return this._mapper(_.merge({ executionStatus: executionStatus }, payload)).tap(function (record) {
|
|
78
|
+
return debug("Record to save in firehose %s %j", _this2.deliveryStream, record);
|
|
79
|
+
}).then(function (record) {
|
|
78
80
|
var __uploadToFirehose, uploadParams;
|
|
79
81
|
if (_.isEmpty(record)) {
|
|
80
82
|
return;
|
|
@@ -85,25 +87,31 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
85
87
|
Data: JSON.stringify(record)
|
|
86
88
|
}
|
|
87
89
|
};
|
|
88
|
-
debug("Uploading
|
|
90
|
+
debug("Uploading record " + record.event + "/" + record.id + " to firehose delivery stream " + uploadParams.DeliveryStreamName);
|
|
89
91
|
__uploadToFirehose = function __uploadToFirehose() {
|
|
90
92
|
return _this2.uploadToFirehose(uploadParams);
|
|
91
93
|
};
|
|
92
94
|
return retry(__uploadToFirehose, {
|
|
93
95
|
throw_original: true
|
|
94
96
|
}).tap(function () {
|
|
95
|
-
return debug("Uploaded
|
|
97
|
+
return debug("Uploaded record " + record.event + "/" + record.id + " to firehose delivery stream " + uploadParams.DeliveryStreamName);
|
|
96
98
|
}).catch(function (e) {
|
|
97
99
|
// We'll do nothing with this error
|
|
98
|
-
return debug("Error uploading
|
|
100
|
+
return debug("Error uploading record " + record.event + "/" + record.id + " to firehose delivery stream " + uploadParams.DeliveryStreamName + " %o", e);
|
|
99
101
|
});
|
|
100
102
|
});
|
|
101
103
|
}
|
|
102
104
|
}, {
|
|
103
105
|
key: "_mapper",
|
|
104
|
-
value: function _mapper(
|
|
106
|
+
value: function _mapper(_ref2) {
|
|
105
107
|
var _this3 = this;
|
|
106
108
|
|
|
109
|
+
var id = _ref2.id,
|
|
110
|
+
notification = _ref2.notification,
|
|
111
|
+
error = _ref2.error,
|
|
112
|
+
warnings = _ref2.warnings,
|
|
113
|
+
executionStatus = _ref2.executionStatus;
|
|
114
|
+
|
|
107
115
|
return Promise.method(this.sender.monitoringCenterFields.bind(this.sender))(notification).then(function (_ref3) {
|
|
108
116
|
var eventType = _ref3.eventType,
|
|
109
117
|
resource = _ref3.resource,
|
|
@@ -122,9 +130,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
122
130
|
if (!eventId) {
|
|
123
131
|
return Promise.resolve({});
|
|
124
132
|
}
|
|
125
|
-
theRequest = _.get(
|
|
126
|
-
errorType = _this3._retrieveMessageFromError(
|
|
127
|
-
errorMessage = _this3._retrieveMessageFromError(
|
|
133
|
+
theRequest = _.get(error, "detail.request") || _.get(error, "cause.detail.request");
|
|
134
|
+
errorType = _this3._retrieveMessageFromError(error, TYPE_PROPERTIES, "unknown");
|
|
135
|
+
errorMessage = _this3._retrieveMessageFromError(error, MESSAGE_PROPERTIES, "");
|
|
128
136
|
now = new Date();
|
|
129
137
|
return {
|
|
130
138
|
id: id,
|
|
@@ -147,9 +155,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
147
155
|
clientId: _this3.clientId,
|
|
148
156
|
job: _this3.job,
|
|
149
157
|
app: _this3.app,
|
|
150
|
-
error: _.omit(
|
|
158
|
+
error: _.omit(error, ["detail.request", "cause.detail.request"]),
|
|
151
159
|
request: _.omit(theRequest, _.castArray(_this3.propertiesToOmit).concat("auth")),
|
|
152
|
-
tags: _.get(
|
|
160
|
+
tags: _.get(error, "tags", []),
|
|
153
161
|
message: partialMessage || notification.message
|
|
154
162
|
}),
|
|
155
163
|
status: executionStatus,
|
|
@@ -158,17 +166,24 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
158
166
|
// Generic app fields
|
|
159
167
|
event_timestamp: eventTimestamp || now.getTime(),
|
|
160
168
|
error_type: errorType,
|
|
169
|
+
output_message: errorMessage,
|
|
161
170
|
user_settings_version: null, //TODO
|
|
162
171
|
env_version: null, //TODO
|
|
163
|
-
code_version: null //TODO
|
|
172
|
+
code_version: null, //TODO
|
|
173
|
+
warnings: warnings != null ? warnings.map(function (warning) {
|
|
174
|
+
return {
|
|
175
|
+
type: _this3._retrieveMessageFromError(warning, TYPE_PROPERTIES, "unknown"),
|
|
176
|
+
message: _this3._retrieveMessageFromError(warning, MESSAGE_PROPERTIES, "")
|
|
177
|
+
};
|
|
178
|
+
}) : void 0
|
|
164
179
|
};
|
|
165
180
|
});
|
|
166
181
|
}
|
|
167
182
|
}, {
|
|
168
183
|
key: "_retrieveMessageFromError",
|
|
169
|
-
value: function _retrieveMessageFromError(
|
|
170
|
-
return
|
|
171
|
-
return _.get(
|
|
184
|
+
value: function _retrieveMessageFromError(error, properties, defaultValue) {
|
|
185
|
+
return error && _(properties).map(function (property) {
|
|
186
|
+
return _.get(error, property);
|
|
172
187
|
}).reject(_.isEmpty).get(0, defaultValue);
|
|
173
188
|
}
|
|
174
189
|
}]);
|
package/lib/processor.js
CHANGED
|
@@ -12,6 +12,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
|
|
|
12
12
|
(function () {
|
|
13
13
|
var ENABLE_EVENTS,
|
|
14
14
|
EventEmitter,
|
|
15
|
+
IgnoredError,
|
|
15
16
|
NonRetryable,
|
|
16
17
|
Processor,
|
|
17
18
|
Promise,
|
|
@@ -28,6 +29,8 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
|
|
|
28
29
|
|
|
29
30
|
NonRetryable = require("./exceptions/non.retryable");
|
|
30
31
|
|
|
32
|
+
IgnoredError = require("./exceptions/ignored.error");
|
|
33
|
+
|
|
31
34
|
EventEmitter = require("events");
|
|
32
35
|
|
|
33
36
|
Promise = require("bluebird");
|
|
@@ -93,6 +96,13 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
|
|
|
93
96
|
};
|
|
94
97
|
execute().tap(function () {
|
|
95
98
|
return _this2._emitEvent("successful", { context: context, id: id, notification: notification });
|
|
99
|
+
}).catch(IgnoredError, function (error) {
|
|
100
|
+
return _this2._emitEvent("successful", {
|
|
101
|
+
context: context,
|
|
102
|
+
id: id,
|
|
103
|
+
notification: notification,
|
|
104
|
+
warnings: [error]
|
|
105
|
+
});
|
|
96
106
|
}).catch(function (error) {
|
|
97
107
|
if (!(error instanceof NonRetryable)) {
|
|
98
108
|
throw error;
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
// Generated by CoffeeScript 2.7.0
|
|
4
4
|
(function () {
|
|
5
|
-
var MESSAGE_PROPERTIES, NonRetryableError, Promise, RequestError, StatusCodeError, _, __isIncludedInStatusesError, _safeParse, _type, errorConditions, httpStatus, request;
|
|
5
|
+
var IgnoredError, MESSAGE_PROPERTIES, NonRetryableError, Promise, RequestError, StatusCodeError, _, __isIncludedInStatusesError, _safeParse, _type, errorConditions, httpStatus, request;
|
|
6
6
|
|
|
7
7
|
_ = require("lodash");
|
|
8
8
|
|
|
9
9
|
NonRetryableError = require("../exceptions/non.retryable");
|
|
10
10
|
|
|
11
|
+
IgnoredError = require("../exceptions/ignored.error");
|
|
12
|
+
|
|
11
13
|
Promise = require("bluebird");
|
|
12
14
|
|
|
13
15
|
request = require("request-promise");
|
|
@@ -102,7 +104,7 @@
|
|
|
102
104
|
}
|
|
103
105
|
});
|
|
104
106
|
}).catch(__isIncludedInStatusesError(silentErrors), function (err) {
|
|
105
|
-
|
|
107
|
+
throw new IgnoredError("An error has ocurred in that request but should be ignored", _.omit(err, "response"));
|
|
106
108
|
}).catch(__isIncludedInStatusesError(nonRetryable), function (err) {
|
|
107
109
|
throw new NonRetryableError("An error has ocurred in that request", _.omit(err, "response"));
|
|
108
110
|
});
|