@zucker-framework/monitoring 1.0.0 → 1.0.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.
- package/README.md +11 -0
- package/dist/index.d.mts +75 -3
- package/dist/index.d.ts +75 -3
- package/dist/index.js +229 -83
- package/dist/index.mjs +229 -86
- package/package.json +14 -4
package/dist/index.js
CHANGED
|
@@ -35,6 +35,7 @@ __export(index_exports, {
|
|
|
35
35
|
AlertManagerService: () => AlertManagerService,
|
|
36
36
|
Counter: () => Counter,
|
|
37
37
|
ERROR_REPORTER: () => ERROR_REPORTER,
|
|
38
|
+
ERROR_TRACKER_OPTIONS: () => ERROR_TRACKER_OPTIONS,
|
|
38
39
|
ErrorTracker: () => ErrorTracker,
|
|
39
40
|
Gauge: () => Gauge,
|
|
40
41
|
HEALTH_OPTIONS: () => HEALTH_OPTIONS,
|
|
@@ -48,17 +49,20 @@ __export(index_exports, {
|
|
|
48
49
|
MetricsRegistry: () => MetricsRegistry,
|
|
49
50
|
NoopErrorReporter: () => NoopErrorReporter,
|
|
50
51
|
PrometheusExporter: () => PrometheusExporter,
|
|
52
|
+
SentryErrorReporter: () => SentryErrorReporter,
|
|
51
53
|
Summary: () => Summary,
|
|
52
54
|
SystemMetricsCollector: () => SystemMetricsCollector,
|
|
53
55
|
Timer: () => Timer,
|
|
54
56
|
UsageTracker: () => UsageTracker,
|
|
55
57
|
ZuckerMonitoringModule: () => ZuckerMonitoringModule,
|
|
58
|
+
errorFingerprint: () => errorFingerprint,
|
|
56
59
|
getProcessUptime: () => getProcessUptime,
|
|
57
60
|
renderPrometheusMetrics: () => renderPrometheusMetrics
|
|
58
61
|
});
|
|
59
62
|
module.exports = __toCommonJS(index_exports);
|
|
60
63
|
|
|
61
64
|
// src/error-tracker.ts
|
|
65
|
+
var import_node_crypto = require("crypto");
|
|
62
66
|
var import_common = require("@nestjs/common");
|
|
63
67
|
function _ts_decorate(decorators, target, key, desc) {
|
|
64
68
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -74,40 +78,80 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
74
78
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
75
79
|
}
|
|
76
80
|
__name(_ts_decorate, "_ts_decorate");
|
|
81
|
+
function _ts_metadata(metadataKey, metadataValue) {
|
|
82
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
83
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
__name(_ts_metadata, "_ts_metadata");
|
|
87
|
+
function _ts_param(paramIndex, decorator) {
|
|
88
|
+
return function(target, key) {
|
|
89
|
+
decorator(target, key, paramIndex);
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
__name(_ts_param, "_ts_param");
|
|
93
|
+
var ERROR_TRACKER_OPTIONS = /* @__PURE__ */ Symbol("ERROR_TRACKER_OPTIONS");
|
|
94
|
+
function errorFingerprint(error, endpoint = "") {
|
|
95
|
+
return (0, import_node_crypto.createHash)("sha256").update([
|
|
96
|
+
error.name,
|
|
97
|
+
error.message,
|
|
98
|
+
error.stack?.split("\n")[1]?.trim() ?? "",
|
|
99
|
+
endpoint
|
|
100
|
+
].join("::")).digest("hex");
|
|
101
|
+
}
|
|
102
|
+
__name(errorFingerprint, "errorFingerprint");
|
|
77
103
|
var ErrorTracker = class _ErrorTracker {
|
|
78
104
|
static {
|
|
79
105
|
__name(this, "ErrorTracker");
|
|
80
106
|
}
|
|
107
|
+
options;
|
|
81
108
|
logger = new import_common.Logger(_ErrorTracker.name);
|
|
82
109
|
errors = /* @__PURE__ */ new Map();
|
|
83
110
|
counter = 0;
|
|
111
|
+
constructor(options = {}) {
|
|
112
|
+
this.options = options;
|
|
113
|
+
if (options.retentionMs !== void 0 && (!Number.isFinite(options.retentionMs) || options.retentionMs <= 0)) throw new Error("Invalid error retention window");
|
|
114
|
+
}
|
|
115
|
+
prune() {
|
|
116
|
+
if (this.options.retentionMs === void 0) return;
|
|
117
|
+
const cutoff = Date.now() - this.options.retentionMs;
|
|
118
|
+
for (const [key, record] of this.errors) if (record.firstOccurrence.getTime() <= cutoff) this.errors.delete(key);
|
|
119
|
+
}
|
|
84
120
|
track(error, category = "unknown", metadata) {
|
|
85
|
-
|
|
121
|
+
this.prune();
|
|
122
|
+
const key = this.options.fingerprint?.(error, category, metadata) ?? `${category}:${error.message}`;
|
|
123
|
+
const safeMetadata = metadata ? this.options.sanitizeMetadata?.(metadata) ?? metadata : void 0;
|
|
86
124
|
const existing = this.errors.get(key);
|
|
87
125
|
if (existing) {
|
|
88
126
|
existing.count++;
|
|
89
127
|
existing.lastOccurrence = /* @__PURE__ */ new Date();
|
|
90
|
-
if (
|
|
128
|
+
if (safeMetadata) {
|
|
91
129
|
existing.metadata = {
|
|
92
130
|
...existing.metadata,
|
|
93
|
-
...
|
|
131
|
+
...safeMetadata
|
|
94
132
|
};
|
|
95
133
|
}
|
|
96
134
|
} else {
|
|
97
|
-
|
|
135
|
+
const record = {
|
|
98
136
|
id: `err_${++this.counter}`,
|
|
99
|
-
message: error.message,
|
|
100
|
-
stack: error.stack,
|
|
137
|
+
message: this.options.sanitizeText?.(error.message) ?? error.message,
|
|
138
|
+
stack: error.stack ? this.options.sanitizeText?.(error.stack) ?? error.stack : void 0,
|
|
101
139
|
category,
|
|
102
140
|
count: 1,
|
|
103
141
|
firstOccurrence: /* @__PURE__ */ new Date(),
|
|
104
142
|
lastOccurrence: /* @__PURE__ */ new Date(),
|
|
105
|
-
metadata
|
|
106
|
-
}
|
|
143
|
+
metadata: safeMetadata
|
|
144
|
+
};
|
|
145
|
+
this.errors.set(key, record);
|
|
146
|
+
this.options.onNewError?.(error, record);
|
|
147
|
+
}
|
|
148
|
+
if (this.options.logEntries !== false) {
|
|
149
|
+
const record = this.errors.get(key);
|
|
150
|
+
this.logger.warn(`[${category}] ${record.message} (count: ${record.count})`);
|
|
107
151
|
}
|
|
108
|
-
this.logger.warn(`[${category}] ${error.message} (count: ${this.errors.get(key).count})`);
|
|
109
152
|
}
|
|
110
153
|
getErrors() {
|
|
154
|
+
this.prune();
|
|
111
155
|
return Array.from(this.errors.values());
|
|
112
156
|
}
|
|
113
157
|
getErrorsByCategory(category) {
|
|
@@ -128,7 +172,13 @@ var ErrorTracker = class _ErrorTracker {
|
|
|
128
172
|
}
|
|
129
173
|
};
|
|
130
174
|
ErrorTracker = _ts_decorate([
|
|
131
|
-
(0, import_common.Injectable)()
|
|
175
|
+
(0, import_common.Injectable)(),
|
|
176
|
+
_ts_param(0, (0, import_common.Optional)()),
|
|
177
|
+
_ts_param(0, (0, import_common.Inject)(ERROR_TRACKER_OPTIONS)),
|
|
178
|
+
_ts_metadata("design:type", Function),
|
|
179
|
+
_ts_metadata("design:paramtypes", [
|
|
180
|
+
typeof ErrorTrackerOptions === "undefined" ? Object : ErrorTrackerOptions
|
|
181
|
+
])
|
|
132
182
|
], ErrorTracker);
|
|
133
183
|
|
|
134
184
|
// src/error-reporter.ts
|
|
@@ -180,10 +230,22 @@ var HealthCheckService = class _HealthCheckService {
|
|
|
180
230
|
unregisterIndicator(name) {
|
|
181
231
|
this.indicators = this.indicators.filter((i) => i.name !== name);
|
|
182
232
|
}
|
|
183
|
-
|
|
233
|
+
/** Select a declared subset for readiness vs. diagnostics; absent indicators fail closed. */
|
|
234
|
+
async checkAll(names) {
|
|
184
235
|
const checks = [];
|
|
185
236
|
let overallStatus = "UP";
|
|
186
|
-
|
|
237
|
+
const indicators = names === void 0 ? this.indicators : names.map((name) => this.indicators.find((indicator) => indicator.name === name) ?? {
|
|
238
|
+
name,
|
|
239
|
+
check: /* @__PURE__ */ __name(async () => ({
|
|
240
|
+
name,
|
|
241
|
+
status: "DOWN",
|
|
242
|
+
details: {
|
|
243
|
+
error: "Health indicator not registered"
|
|
244
|
+
},
|
|
245
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
246
|
+
}), "check")
|
|
247
|
+
});
|
|
248
|
+
for (const indicator of indicators) {
|
|
187
249
|
try {
|
|
188
250
|
const result = await indicator.check();
|
|
189
251
|
checks.push(result);
|
|
@@ -757,12 +819,12 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
757
819
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
758
820
|
}
|
|
759
821
|
__name(_ts_decorate4, "_ts_decorate");
|
|
760
|
-
function
|
|
822
|
+
function _ts_metadata2(metadataKey, metadataValue) {
|
|
761
823
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
762
824
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
763
825
|
}
|
|
764
826
|
}
|
|
765
|
-
__name(
|
|
827
|
+
__name(_ts_metadata2, "_ts_metadata");
|
|
766
828
|
var SystemMetricsCollector = class {
|
|
767
829
|
static {
|
|
768
830
|
__name(this, "SystemMetricsCollector");
|
|
@@ -885,8 +947,8 @@ var SystemMetricsCollector = class {
|
|
|
885
947
|
};
|
|
886
948
|
SystemMetricsCollector = _ts_decorate4([
|
|
887
949
|
(0, import_common4.Injectable)(),
|
|
888
|
-
|
|
889
|
-
|
|
950
|
+
_ts_metadata2("design:type", Function),
|
|
951
|
+
_ts_metadata2("design:paramtypes", [
|
|
890
952
|
typeof MetricsRegistry === "undefined" ? Object : MetricsRegistry
|
|
891
953
|
])
|
|
892
954
|
], SystemMetricsCollector);
|
|
@@ -907,18 +969,18 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
907
969
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
908
970
|
}
|
|
909
971
|
__name(_ts_decorate5, "_ts_decorate");
|
|
910
|
-
function
|
|
972
|
+
function _ts_metadata3(metadataKey, metadataValue) {
|
|
911
973
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
912
974
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
913
975
|
}
|
|
914
976
|
}
|
|
915
|
-
__name(
|
|
916
|
-
function
|
|
977
|
+
__name(_ts_metadata3, "_ts_metadata");
|
|
978
|
+
function _ts_param2(paramIndex, decorator) {
|
|
917
979
|
return function(target, key) {
|
|
918
980
|
decorator(target, key, paramIndex);
|
|
919
981
|
};
|
|
920
982
|
}
|
|
921
|
-
__name(
|
|
983
|
+
__name(_ts_param2, "_ts_param");
|
|
922
984
|
function formatLabels(labels) {
|
|
923
985
|
const entries = Object.entries(labels);
|
|
924
986
|
if (entries.length === 0) return "";
|
|
@@ -1012,15 +1074,15 @@ var PrometheusExporter = class {
|
|
|
1012
1074
|
_ts_decorate5([
|
|
1013
1075
|
(0, import_common5.Get)(),
|
|
1014
1076
|
(0, import_common5.Header)("Content-Type", "text/plain; version=0.0.4; charset=utf-8"),
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1077
|
+
_ts_metadata3("design:type", Function),
|
|
1078
|
+
_ts_metadata3("design:paramtypes", []),
|
|
1079
|
+
_ts_metadata3("design:returntype", String)
|
|
1018
1080
|
], PrometheusExporter.prototype, "getMetrics", null);
|
|
1019
1081
|
PrometheusExporter = _ts_decorate5([
|
|
1020
1082
|
(0, import_common5.Controller)("metrics"),
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1083
|
+
_ts_param2(0, (0, import_common5.Inject)(MetricsRegistry)),
|
|
1084
|
+
_ts_metadata3("design:type", Function),
|
|
1085
|
+
_ts_metadata3("design:paramtypes", [
|
|
1024
1086
|
typeof MetricsRegistry === "undefined" ? Object : MetricsRegistry
|
|
1025
1087
|
])
|
|
1026
1088
|
], PrometheusExporter);
|
|
@@ -1056,18 +1118,18 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
1056
1118
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1057
1119
|
}
|
|
1058
1120
|
__name(_ts_decorate6, "_ts_decorate");
|
|
1059
|
-
function
|
|
1121
|
+
function _ts_metadata4(metadataKey, metadataValue) {
|
|
1060
1122
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1061
1123
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1062
1124
|
}
|
|
1063
1125
|
}
|
|
1064
|
-
__name(
|
|
1065
|
-
function
|
|
1126
|
+
__name(_ts_metadata4, "_ts_metadata");
|
|
1127
|
+
function _ts_param3(paramIndex, decorator) {
|
|
1066
1128
|
return function(target, key) {
|
|
1067
1129
|
decorator(target, key, paramIndex);
|
|
1068
1130
|
};
|
|
1069
1131
|
}
|
|
1070
|
-
__name(
|
|
1132
|
+
__name(_ts_param3, "_ts_param");
|
|
1071
1133
|
var Public = /* @__PURE__ */ __name(() => (0, import_common6.SetMetadata)("zucker:auth:isPublic", true), "Public");
|
|
1072
1134
|
var HEALTH_OPTIONS = /* @__PURE__ */ Symbol("HEALTH_OPTIONS");
|
|
1073
1135
|
var HealthController = class {
|
|
@@ -1126,36 +1188,36 @@ var HealthController = class {
|
|
|
1126
1188
|
};
|
|
1127
1189
|
_ts_decorate6([
|
|
1128
1190
|
(0, import_common6.Get)(),
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1191
|
+
_ts_param3(0, (0, import_common6.Res)()),
|
|
1192
|
+
_ts_metadata4("design:type", Function),
|
|
1193
|
+
_ts_metadata4("design:paramtypes", [
|
|
1132
1194
|
Object
|
|
1133
1195
|
]),
|
|
1134
|
-
|
|
1196
|
+
_ts_metadata4("design:returntype", Promise)
|
|
1135
1197
|
], HealthController.prototype, "check", null);
|
|
1136
1198
|
_ts_decorate6([
|
|
1137
1199
|
(0, import_common6.Get)("live"),
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1200
|
+
_ts_param3(0, (0, import_common6.Res)()),
|
|
1201
|
+
_ts_metadata4("design:type", Function),
|
|
1202
|
+
_ts_metadata4("design:paramtypes", [
|
|
1141
1203
|
Object
|
|
1142
1204
|
]),
|
|
1143
|
-
|
|
1205
|
+
_ts_metadata4("design:returntype", void 0)
|
|
1144
1206
|
], HealthController.prototype, "live", null);
|
|
1145
1207
|
_ts_decorate6([
|
|
1146
1208
|
(0, import_common6.Get)("ready"),
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1209
|
+
_ts_param3(0, (0, import_common6.Res)()),
|
|
1210
|
+
_ts_metadata4("design:type", Function),
|
|
1211
|
+
_ts_metadata4("design:paramtypes", [
|
|
1150
1212
|
Object
|
|
1151
1213
|
]),
|
|
1152
|
-
|
|
1214
|
+
_ts_metadata4("design:returntype", Promise)
|
|
1153
1215
|
], HealthController.prototype, "ready", null);
|
|
1154
1216
|
HealthController = _ts_decorate6([
|
|
1155
1217
|
(0, import_common6.Controller)("health"),
|
|
1156
1218
|
Public(),
|
|
1157
|
-
|
|
1158
|
-
|
|
1219
|
+
_ts_metadata4("design:type", Function),
|
|
1220
|
+
_ts_metadata4("design:paramtypes", [
|
|
1159
1221
|
typeof HealthCheckService === "undefined" ? Object : HealthCheckService
|
|
1160
1222
|
])
|
|
1161
1223
|
], HealthController);
|
|
@@ -1178,18 +1240,18 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
1178
1240
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1179
1241
|
}
|
|
1180
1242
|
__name(_ts_decorate7, "_ts_decorate");
|
|
1181
|
-
function
|
|
1243
|
+
function _ts_metadata5(metadataKey, metadataValue) {
|
|
1182
1244
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1183
1245
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1184
1246
|
}
|
|
1185
1247
|
}
|
|
1186
|
-
__name(
|
|
1187
|
-
function
|
|
1248
|
+
__name(_ts_metadata5, "_ts_metadata");
|
|
1249
|
+
function _ts_param4(paramIndex, decorator) {
|
|
1188
1250
|
return function(target, key) {
|
|
1189
1251
|
decorator(target, key, paramIndex);
|
|
1190
1252
|
};
|
|
1191
1253
|
}
|
|
1192
|
-
__name(
|
|
1254
|
+
__name(_ts_param4, "_ts_param");
|
|
1193
1255
|
function nextAlertId() {
|
|
1194
1256
|
return `alert-${Date.now()}-${(0, import_crypto.randomUUID)().slice(0, 8)}`;
|
|
1195
1257
|
}
|
|
@@ -1410,11 +1472,11 @@ var AlertManagerService = class _AlertManagerService {
|
|
|
1410
1472
|
};
|
|
1411
1473
|
AlertManagerService = _ts_decorate7([
|
|
1412
1474
|
(0, import_common7.Injectable)(),
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1475
|
+
_ts_param4(0, (0, import_common7.Optional)()),
|
|
1476
|
+
_ts_param4(1, (0, import_common7.Optional)()),
|
|
1477
|
+
_ts_param4(1, (0, import_common7.Inject)("DATABASE_ADAPTER")),
|
|
1478
|
+
_ts_metadata5("design:type", Function),
|
|
1479
|
+
_ts_metadata5("design:paramtypes", [
|
|
1418
1480
|
typeof import_event_emitter.EventEmitter2 === "undefined" ? Object : import_event_emitter.EventEmitter2,
|
|
1419
1481
|
Object
|
|
1420
1482
|
])
|
|
@@ -1436,18 +1498,18 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
1436
1498
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1437
1499
|
}
|
|
1438
1500
|
__name(_ts_decorate8, "_ts_decorate");
|
|
1439
|
-
function
|
|
1501
|
+
function _ts_metadata6(metadataKey, metadataValue) {
|
|
1440
1502
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1441
1503
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1442
1504
|
}
|
|
1443
1505
|
}
|
|
1444
|
-
__name(
|
|
1445
|
-
function
|
|
1506
|
+
__name(_ts_metadata6, "_ts_metadata");
|
|
1507
|
+
function _ts_param5(paramIndex, decorator) {
|
|
1446
1508
|
return function(target, key) {
|
|
1447
1509
|
decorator(target, key, paramIndex);
|
|
1448
1510
|
};
|
|
1449
1511
|
}
|
|
1450
|
-
__name(
|
|
1512
|
+
__name(_ts_param5, "_ts_param");
|
|
1451
1513
|
var Permissions = /* @__PURE__ */ __name(() => (0, import_common8.SetMetadata)("zucker:auth:permissions", []), "Permissions");
|
|
1452
1514
|
var AlertController = class {
|
|
1453
1515
|
static {
|
|
@@ -1513,63 +1575,63 @@ var AlertController = class {
|
|
|
1513
1575
|
};
|
|
1514
1576
|
_ts_decorate8([
|
|
1515
1577
|
(0, import_common8.Get)(),
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1578
|
+
_ts_metadata6("design:type", Function),
|
|
1579
|
+
_ts_metadata6("design:paramtypes", []),
|
|
1580
|
+
_ts_metadata6("design:returntype", void 0)
|
|
1519
1581
|
], AlertController.prototype, "getAlerts", null);
|
|
1520
1582
|
_ts_decorate8([
|
|
1521
1583
|
(0, import_common8.Get)("rules"),
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1584
|
+
_ts_metadata6("design:type", Function),
|
|
1585
|
+
_ts_metadata6("design:paramtypes", []),
|
|
1586
|
+
_ts_metadata6("design:returntype", void 0)
|
|
1525
1587
|
], AlertController.prototype, "getRules", null);
|
|
1526
1588
|
_ts_decorate8([
|
|
1527
1589
|
(0, import_common8.Post)("rules"),
|
|
1528
1590
|
(0, import_common8.HttpCode)(import_common8.HttpStatus.CREATED),
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1591
|
+
_ts_param5(0, (0, import_common8.Body)()),
|
|
1592
|
+
_ts_metadata6("design:type", Function),
|
|
1593
|
+
_ts_metadata6("design:paramtypes", [
|
|
1532
1594
|
typeof AlertRule === "undefined" ? Object : AlertRule
|
|
1533
1595
|
]),
|
|
1534
|
-
|
|
1596
|
+
_ts_metadata6("design:returntype", void 0)
|
|
1535
1597
|
], AlertController.prototype, "createRule", null);
|
|
1536
1598
|
_ts_decorate8([
|
|
1537
1599
|
(0, import_common8.Delete)("rules/:id"),
|
|
1538
1600
|
(0, import_common8.HttpCode)(import_common8.HttpStatus.NO_CONTENT),
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1601
|
+
_ts_param5(0, (0, import_common8.Param)("id")),
|
|
1602
|
+
_ts_metadata6("design:type", Function),
|
|
1603
|
+
_ts_metadata6("design:paramtypes", [
|
|
1542
1604
|
String
|
|
1543
1605
|
]),
|
|
1544
|
-
|
|
1606
|
+
_ts_metadata6("design:returntype", void 0)
|
|
1545
1607
|
], AlertController.prototype, "deleteRule", null);
|
|
1546
1608
|
_ts_decorate8([
|
|
1547
1609
|
(0, import_common8.Put)(":id/acknowledge"),
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1610
|
+
_ts_param5(0, (0, import_common8.Param)("id")),
|
|
1611
|
+
_ts_param5(1, (0, import_common8.Body)("userId")),
|
|
1612
|
+
_ts_metadata6("design:type", Function),
|
|
1613
|
+
_ts_metadata6("design:paramtypes", [
|
|
1552
1614
|
String,
|
|
1553
1615
|
String
|
|
1554
1616
|
]),
|
|
1555
|
-
|
|
1617
|
+
_ts_metadata6("design:returntype", void 0)
|
|
1556
1618
|
], AlertController.prototype, "acknowledgeAlert", null);
|
|
1557
1619
|
_ts_decorate8([
|
|
1558
1620
|
(0, import_common8.Put)(":id/resolve"),
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1621
|
+
_ts_param5(0, (0, import_common8.Param)("id")),
|
|
1622
|
+
_ts_param5(1, (0, import_common8.Body)("userId")),
|
|
1623
|
+
_ts_metadata6("design:type", Function),
|
|
1624
|
+
_ts_metadata6("design:paramtypes", [
|
|
1563
1625
|
String,
|
|
1564
1626
|
String
|
|
1565
1627
|
]),
|
|
1566
|
-
|
|
1628
|
+
_ts_metadata6("design:returntype", void 0)
|
|
1567
1629
|
], AlertController.prototype, "resolveAlert", null);
|
|
1568
1630
|
AlertController = _ts_decorate8([
|
|
1569
1631
|
(0, import_common8.Controller)("monitoring/alerts"),
|
|
1570
1632
|
Permissions(),
|
|
1571
|
-
|
|
1572
|
-
|
|
1633
|
+
_ts_metadata6("design:type", Function),
|
|
1634
|
+
_ts_metadata6("design:paramtypes", [
|
|
1573
1635
|
typeof AlertManagerService === "undefined" ? Object : AlertManagerService
|
|
1574
1636
|
])
|
|
1575
1637
|
], AlertController);
|
|
@@ -1719,12 +1781,94 @@ var UsageTracker = class _UsageTracker {
|
|
|
1719
1781
|
UsageTracker = _ts_decorate10([
|
|
1720
1782
|
(0, import_common10.Injectable)()
|
|
1721
1783
|
], UsageTracker);
|
|
1784
|
+
|
|
1785
|
+
// src/sentry-error-reporter.ts
|
|
1786
|
+
var import_privacy = require("@zucker-framework/core/privacy");
|
|
1787
|
+
var SentryErrorReporter = class {
|
|
1788
|
+
static {
|
|
1789
|
+
__name(this, "SentryErrorReporter");
|
|
1790
|
+
}
|
|
1791
|
+
options;
|
|
1792
|
+
sdk;
|
|
1793
|
+
initializing;
|
|
1794
|
+
constructor(options) {
|
|
1795
|
+
this.options = options;
|
|
1796
|
+
}
|
|
1797
|
+
onModuleInit() {
|
|
1798
|
+
return this.initializing ??= this.initialize();
|
|
1799
|
+
}
|
|
1800
|
+
async initialize() {
|
|
1801
|
+
if (!this.options.dsn) {
|
|
1802
|
+
this.options.onUnavailable?.();
|
|
1803
|
+
return;
|
|
1804
|
+
}
|
|
1805
|
+
const sdk = await (this.options.loadSdk?.() ?? import("@sentry/node").then((module2) => module2));
|
|
1806
|
+
sdk.init({
|
|
1807
|
+
dsn: this.options.dsn,
|
|
1808
|
+
environment: this.options.environment,
|
|
1809
|
+
release: this.options.release,
|
|
1810
|
+
tracesSampleRate: this.options.tracesSampleRate,
|
|
1811
|
+
beforeSend: /* @__PURE__ */ __name((event) => {
|
|
1812
|
+
const redaction = this.options.redaction;
|
|
1813
|
+
let safe = event;
|
|
1814
|
+
if (redaction) {
|
|
1815
|
+
safe = {
|
|
1816
|
+
...event
|
|
1817
|
+
};
|
|
1818
|
+
for (const section of redaction.sections) {
|
|
1819
|
+
const value = event[section];
|
|
1820
|
+
if (value !== null && typeof value === "object") {
|
|
1821
|
+
safe[section] = (0, import_privacy.redactFields)(value, redaction.fields, redaction.replacement);
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
return this.options.beforeSend ? this.options.beforeSend(safe) : safe;
|
|
1826
|
+
}, "beforeSend")
|
|
1827
|
+
});
|
|
1828
|
+
this.sdk = sdk;
|
|
1829
|
+
this.options.onInitialized?.();
|
|
1830
|
+
}
|
|
1831
|
+
captureException(error, context) {
|
|
1832
|
+
const sdk = this.sdk;
|
|
1833
|
+
if (!sdk) return;
|
|
1834
|
+
sdk.withScope((scope) => {
|
|
1835
|
+
this.applyContext(scope, context, "exception");
|
|
1836
|
+
sdk.captureException(error);
|
|
1837
|
+
});
|
|
1838
|
+
}
|
|
1839
|
+
captureMessage(message, context) {
|
|
1840
|
+
const sdk = this.sdk;
|
|
1841
|
+
if (!sdk) return;
|
|
1842
|
+
sdk.withScope((scope) => {
|
|
1843
|
+
this.applyContext(scope, context, "message");
|
|
1844
|
+
sdk.captureMessage(message);
|
|
1845
|
+
});
|
|
1846
|
+
}
|
|
1847
|
+
setUser(user) {
|
|
1848
|
+
this.sdk?.setUser(user);
|
|
1849
|
+
}
|
|
1850
|
+
applyContext(scope, context, kind) {
|
|
1851
|
+
if (!context) return;
|
|
1852
|
+
const mapped = this.options.mapContext?.(context, kind) ?? {
|
|
1853
|
+
tags: context.requestId ? {
|
|
1854
|
+
requestId: context.requestId
|
|
1855
|
+
} : void 0,
|
|
1856
|
+
user: context.userId ? {
|
|
1857
|
+
id: context.userId
|
|
1858
|
+
} : void 0
|
|
1859
|
+
};
|
|
1860
|
+
for (const [key, value] of Object.entries(mapped.tags ?? {})) scope.setTag(key, value);
|
|
1861
|
+
if (mapped.user !== void 0) scope.setUser(mapped.user);
|
|
1862
|
+
for (const [key, value] of Object.entries(mapped.extra ?? {})) scope.setExtra(key, value);
|
|
1863
|
+
}
|
|
1864
|
+
};
|
|
1722
1865
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1723
1866
|
0 && (module.exports = {
|
|
1724
1867
|
AlertController,
|
|
1725
1868
|
AlertManagerService,
|
|
1726
1869
|
Counter,
|
|
1727
1870
|
ERROR_REPORTER,
|
|
1871
|
+
ERROR_TRACKER_OPTIONS,
|
|
1728
1872
|
ErrorTracker,
|
|
1729
1873
|
Gauge,
|
|
1730
1874
|
HEALTH_OPTIONS,
|
|
@@ -1738,11 +1882,13 @@ UsageTracker = _ts_decorate10([
|
|
|
1738
1882
|
MetricsRegistry,
|
|
1739
1883
|
NoopErrorReporter,
|
|
1740
1884
|
PrometheusExporter,
|
|
1885
|
+
SentryErrorReporter,
|
|
1741
1886
|
Summary,
|
|
1742
1887
|
SystemMetricsCollector,
|
|
1743
1888
|
Timer,
|
|
1744
1889
|
UsageTracker,
|
|
1745
1890
|
ZuckerMonitoringModule,
|
|
1891
|
+
errorFingerprint,
|
|
1746
1892
|
getProcessUptime,
|
|
1747
1893
|
renderPrometheusMetrics
|
|
1748
1894
|
});
|