nestlens 0.12.0 → 0.14.0
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/api/api.controller.d.ts +34 -3
- package/dist/api/api.controller.js +36 -8
- package/dist/api/dto/clear-entries.dto.d.ts +12 -0
- package/dist/api/dto/clear-entries.dto.js +32 -0
- package/dist/api/dto/entry-types.d.ts +9 -0
- package/dist/api/dto/entry-types.js +11 -21
- package/dist/api/dto/index.d.ts +1 -0
- package/dist/api/dto/index.js +1 -0
- package/dist/core/alerting.service.js +37 -1
- package/dist/core/collector.service.d.ts +18 -0
- package/dist/core/collector.service.js +26 -0
- package/dist/core/storage/memory.storage.d.ts +1 -1
- package/dist/core/storage/memory.storage.js +15 -1
- package/dist/core/storage/redis-url.d.ts +26 -0
- package/dist/core/storage/redis-url.js +51 -0
- package/dist/core/storage/redis.storage.d.ts +1 -1
- package/dist/core/storage/redis.storage.js +22 -45
- package/dist/core/storage/sqlite.storage.d.ts +1 -1
- package/dist/core/storage/sqlite.storage.js +13 -1
- package/dist/core/storage/storage.interface.d.ts +11 -3
- package/dist/dashboard/public/assets/{BatchDetailView-Kz8lmg7b.js → BatchDetailView-BGIncdDY.js} +1 -1
- package/dist/dashboard/public/assets/BatchesPage-ugxH2v0z.js +1 -0
- package/dist/dashboard/public/assets/{CacheDetailView-gWQ36gpT.js → CacheDetailView-DszaZXmk.js} +1 -1
- package/dist/dashboard/public/assets/CachePage-tk4-Mzj-.js +1 -0
- package/dist/dashboard/public/assets/{CommandDetailView-tLDOIYKo.js → CommandDetailView-oe6WXq6m.js} +1 -1
- package/dist/dashboard/public/assets/CommandsPage-BT5pa5B8.js +1 -0
- package/dist/dashboard/public/assets/{CopyButton-Dp88z3zD.js → CopyButton-djrkphpR.js} +1 -1
- package/dist/dashboard/public/assets/{DashboardPage-CHgsQI3w.js → DashboardPage-D0ukXtDo.js} +1 -1
- package/dist/dashboard/public/assets/{DataTable-CiPeRzYj.js → DataTable-CDqXyed8.js} +1 -1
- package/dist/dashboard/public/assets/{DetailRow-ZFijkJy9.js → DetailRow-CWJp1tTe.js} +1 -1
- package/dist/dashboard/public/assets/{DumpDetailView-BQ_0UMzI.js → DumpDetailView-BMkCXdx-.js} +1 -1
- package/dist/dashboard/public/assets/DumpsPage-C0_N90Tx.js +1 -0
- package/dist/dashboard/public/assets/{EntryDetailPage-BhGVuHY8.js → EntryDetailPage-Dw2pcYO2.js} +3 -3
- package/dist/dashboard/public/assets/{EntrySearchInput-BhuYJjcJ.js → EntrySearchInput-BGWM929F.js} +1 -1
- package/dist/dashboard/public/assets/{EventDetailView-CqB1VO-o.js → EventDetailView-CqLCbVkJ.js} +1 -1
- package/dist/dashboard/public/assets/EventsPage-CRGB2aCi.js +1 -0
- package/dist/dashboard/public/assets/{ExceptionDetailView-BrwzI-Ny.js → ExceptionDetailView-Dq8Di5sK.js} +1 -1
- package/dist/dashboard/public/assets/ExceptionsPage-CA8ilfoK.js +6 -0
- package/dist/dashboard/public/assets/{GateDetailView-DETgnBEJ.js → GateDetailView-DYDLxDRn.js} +1 -1
- package/dist/dashboard/public/assets/GatesPage-Do-qOR5X.js +1 -0
- package/dist/dashboard/public/assets/{GraphQLDetailView-Z2P5Z_wK.js → GraphQLDetailView-BFwIn1GM.js} +1 -1
- package/dist/dashboard/public/assets/GraphQLPage-CNWITXJX.js +6 -0
- package/dist/dashboard/public/assets/{HttpClientDetailView-DjgiZtq7.js → HttpClientDetailView-BgYy7Ucb.js} +1 -1
- package/dist/dashboard/public/assets/{HttpClientPage-D-9rOwxW.js → HttpClientPage-BJd_ibF6.js} +1 -1
- package/dist/dashboard/public/assets/{JobDetailView-DVKXNyhm.js → JobDetailView-B3psHOxq.js} +1 -1
- package/dist/dashboard/public/assets/JobsPage-DAdrYeU-.js +1 -0
- package/dist/dashboard/public/assets/{LogDetailView-Cdwx8HAo.js → LogDetailView-BealPvcV.js} +1 -1
- package/dist/dashboard/public/assets/LogsPage-CCwjLuWQ.js +1 -0
- package/dist/dashboard/public/assets/{MailDetailView-5VJ2aebx.js → MailDetailView-CM54VOlh.js} +1 -1
- package/dist/dashboard/public/assets/MailPage-CdiZI_hh.js +1 -0
- package/dist/dashboard/public/assets/{ModelDetailView-Btpt8H6c.js → ModelDetailView-B8KVVw2M.js} +1 -1
- package/dist/dashboard/public/assets/ModelsPage-0-jYL1-U.js +1 -0
- package/dist/dashboard/public/assets/{NotificationDetailView-84rPC1SX.js → NotificationDetailView-0VYorYuc.js} +1 -1
- package/dist/dashboard/public/assets/NotificationsPage-szMmustZ.js +1 -0
- package/dist/dashboard/public/assets/PageHeader-9OQepDeQ.js +1 -0
- package/dist/dashboard/public/assets/QueriesPage-BJfywln6.js +1 -0
- package/dist/dashboard/public/assets/{QueryDetailView-CIJHScnv.js → QueryDetailView-BRe55CUs.js} +1 -1
- package/dist/dashboard/public/assets/{RedisDetailView-C2MB0DYY.js → RedisDetailView-BZ8zYVsk.js} +1 -1
- package/dist/dashboard/public/assets/RedisPage-CHxk1zKp.js +1 -0
- package/dist/dashboard/public/assets/{RequestDetailView-w80IdX1R.js → RequestDetailView-BT568MaZ.js} +1 -1
- package/dist/dashboard/public/assets/RequestsPage-BPeHtBRn.js +1 -0
- package/dist/dashboard/public/assets/{ScheduleDetailView-DJyMNKdl.js → ScheduleDetailView-OG--Lyzr.js} +1 -1
- package/dist/dashboard/public/assets/SchedulePage-uM09HkqS.js +1 -0
- package/dist/dashboard/public/assets/{UserCard-DWitStWv.js → UserCard-CfcScmF8.js} +1 -1
- package/dist/dashboard/public/assets/{ViewDetailView-DVM9EkE8.js → ViewDetailView-CcWB9bLw.js} +1 -1
- package/dist/dashboard/public/assets/ViewsPage-L56Rz7jz.js +1 -0
- package/dist/dashboard/public/assets/{calendar-DSvr3OS6.js → calendar-B4UUBe_A.js} +1 -1
- package/dist/dashboard/public/assets/{circle-alert-sFDCyGtd.js → circle-alert-s9ODnOC3.js} +1 -1
- package/dist/dashboard/public/assets/{circle-check-big-1nqSueTn.js → circle-check-big-C4ws6-wY.js} +1 -1
- package/dist/dashboard/public/assets/{circle-x-DuabRgyL.js → circle-x-D14U2UWr.js} +1 -1
- package/dist/dashboard/public/assets/{eye-Bx7jqdVx.js → eye-CIA_cZlW.js} +1 -1
- package/dist/dashboard/public/assets/index-ReuerEhs.css +1 -0
- package/dist/dashboard/public/assets/index-dkeMTrq0.js +361 -0
- package/dist/dashboard/public/assets/{search-CzOe6pQ2.js → search-C0XvQMrJ.js} +1 -1
- package/dist/dashboard/public/assets/{send-CQVyUZLn.js → send-CTeWfM1I.js} +1 -1
- package/dist/dashboard/public/assets/{timer-Wzp2Wnna.js → timer-BVP3d7zc.js} +1 -1
- package/dist/dashboard/public/assets/{types-Dd6NUxj7.js → types-CuCQ6L2Z.js} +1 -1
- package/dist/dashboard/public/assets/{users-64hxmfDp.js → users-UyMivszP.js} +1 -1
- package/dist/dashboard/public/assets/{zap-DvUE0l48.js → zap-CAbVWiHg.js} +1 -1
- package/dist/dashboard/public/index.html +2 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +0 -1
- package/dist/nestlens.config.d.ts +67 -5
- package/dist/nestlens.module.js +9 -2
- package/dist/presets.d.ts +29 -0
- package/dist/presets.js +78 -0
- package/dist/startup-summary.d.ts +15 -0
- package/dist/startup-summary.js +84 -0
- package/dist/types/entry.types.d.ts +13 -1
- package/dist/types/entry.types.js +33 -0
- package/dist/types/graphql.types.d.ts +18 -2
- package/dist/watchers/cache.watcher.js +33 -60
- package/dist/watchers/graphql/adapters/apollo.adapter.d.ts +23 -1
- package/dist/watchers/graphql/adapters/apollo.adapter.js +55 -20
- package/dist/watchers/graphql/graphql.watcher.js +6 -1
- package/package.json +1 -1
- package/dist/dashboard/public/assets/BatchesPage-DFiQiYm9.js +0 -1
- package/dist/dashboard/public/assets/CachePage-CcP5UUIo.js +0 -1
- package/dist/dashboard/public/assets/CommandsPage-x_pU8uSm.js +0 -1
- package/dist/dashboard/public/assets/DumpsPage-D0o-EOvX.js +0 -1
- package/dist/dashboard/public/assets/EventsPage-BWvlMQOM.js +0 -1
- package/dist/dashboard/public/assets/ExceptionsPage-7wZOjI4L.js +0 -6
- package/dist/dashboard/public/assets/GatesPage-Biem1pTa.js +0 -1
- package/dist/dashboard/public/assets/GraphQLPage-D7IVeu7T.js +0 -6
- package/dist/dashboard/public/assets/JobsPage-DudumyIp.js +0 -1
- package/dist/dashboard/public/assets/LogsPage-DWkRIHul.js +0 -1
- package/dist/dashboard/public/assets/MailPage-ClZNTH_r.js +0 -1
- package/dist/dashboard/public/assets/ModelsPage-PxJ57v2N.js +0 -1
- package/dist/dashboard/public/assets/NotificationsPage-qNuVSo-j.js +0 -1
- package/dist/dashboard/public/assets/PageHeader-BlZTS6Mp.js +0 -1
- package/dist/dashboard/public/assets/QueriesPage-BY0lUO0g.js +0 -1
- package/dist/dashboard/public/assets/RedisPage-C0MTmo7p.js +0 -1
- package/dist/dashboard/public/assets/RequestsPage-DDoBHD10.js +0 -1
- package/dist/dashboard/public/assets/SchedulePage-D3Y5zH7a.js +0 -1
- package/dist/dashboard/public/assets/ViewsPage-CvOj7zwQ.js +0 -1
- package/dist/dashboard/public/assets/index-C256oDAK.css +0 -1
- package/dist/dashboard/public/assets/index-QEFm0Hwa.js +0 -361
|
@@ -3,7 +3,7 @@ import { PruningService } from '../core';
|
|
|
3
3
|
import { CollectorService } from '../core';
|
|
4
4
|
import { NestLensConfig } from '../nestlens.config';
|
|
5
5
|
import { CursorPaginatedResponse, Entry } from '../types';
|
|
6
|
-
import { CheckNewQueryDto, CursorQueryDto, EntriesQueryDto, LatestSequenceQueryDto, LogsQueryDto, PauseRecordingDto, QueriesQueryDto } from './dto';
|
|
6
|
+
import { CheckNewQueryDto, CursorQueryDto, EntriesQueryDto, LatestSequenceQueryDto, ClearEntriesQueryDto, LogsQueryDto, PauseRecordingDto, QueriesQueryDto } from './dto';
|
|
7
7
|
/**
|
|
8
8
|
* Every handler here takes an unused `@Res() _res` parameter. It is not a
|
|
9
9
|
* mistake and the value is never touched: its presence is how a handler tells
|
|
@@ -162,8 +162,23 @@ export declare class NestLensApiController {
|
|
|
162
162
|
nextRun: string | null;
|
|
163
163
|
};
|
|
164
164
|
}>;
|
|
165
|
-
|
|
165
|
+
/**
|
|
166
|
+
* Deletes entries — all of them, or all of one type.
|
|
167
|
+
*
|
|
168
|
+
* Different from pruning, which deletes by age and leaves a monitored tag's
|
|
169
|
+
* entries alone. This is somebody pressing delete: age is not consulted and
|
|
170
|
+
* a monitored tag does not stand in the way, because monitoring says *do not
|
|
171
|
+
* let pruning take these*, which is a different sentence.
|
|
172
|
+
*
|
|
173
|
+
* Answers with how many went, so the page that asked can say so rather than
|
|
174
|
+
* assume.
|
|
175
|
+
*/
|
|
176
|
+
clearEntries(query: ClearEntriesQueryDto, _res?: unknown): Promise<{
|
|
166
177
|
success: boolean;
|
|
178
|
+
data: {
|
|
179
|
+
deleted: number;
|
|
180
|
+
type: "query" | "request" | "exception" | "log" | "cache" | "event" | "job" | "schedule" | "mail" | "http-client" | "redis" | "model" | "notification" | "view" | "command" | "gate" | "batch" | "dump" | "graphql" | null;
|
|
181
|
+
};
|
|
167
182
|
message: string;
|
|
168
183
|
}>;
|
|
169
184
|
/**
|
|
@@ -210,10 +225,26 @@ export declare class NestLensApiController {
|
|
|
210
225
|
};
|
|
211
226
|
}>;
|
|
212
227
|
/**
|
|
213
|
-
*
|
|
228
|
+
* Whether recording is on, and what it has been doing.
|
|
229
|
+
*
|
|
230
|
+
* The counts are here because "nothing was recorded" and "nothing happened"
|
|
231
|
+
* look identical on a dashboard: an application spent two days deciding
|
|
232
|
+
* which of the two it was looking at. Sampling and the filter each drop
|
|
233
|
+
* entries deliberately, and this says how many.
|
|
214
234
|
*/
|
|
215
235
|
getRecordingStatus(_res?: unknown): Promise<{
|
|
216
236
|
data: {
|
|
237
|
+
counts: {
|
|
238
|
+
recorded: number;
|
|
239
|
+
droppedBySampling: number;
|
|
240
|
+
droppedByFilter: number;
|
|
241
|
+
droppedByBuffer: number;
|
|
242
|
+
};
|
|
243
|
+
buffer: {
|
|
244
|
+
pending: number;
|
|
245
|
+
capacity: number;
|
|
246
|
+
dropped: number;
|
|
247
|
+
};
|
|
217
248
|
isPaused: boolean;
|
|
218
249
|
pausedAt?: Date;
|
|
219
250
|
pauseReason?: string;
|
|
@@ -211,9 +211,26 @@ let NestLensApiController = class NestLensApiController {
|
|
|
211
211
|
},
|
|
212
212
|
};
|
|
213
213
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
214
|
+
/**
|
|
215
|
+
* Deletes entries — all of them, or all of one type.
|
|
216
|
+
*
|
|
217
|
+
* Different from pruning, which deletes by age and leaves a monitored tag's
|
|
218
|
+
* entries alone. This is somebody pressing delete: age is not consulted and
|
|
219
|
+
* a monitored tag does not stand in the way, because monitoring says *do not
|
|
220
|
+
* let pruning take these*, which is a different sentence.
|
|
221
|
+
*
|
|
222
|
+
* Answers with how many went, so the page that asked can say so rather than
|
|
223
|
+
* assume.
|
|
224
|
+
*/
|
|
225
|
+
async clearEntries(query, _res) {
|
|
226
|
+
const deleted = await this.storage.clear(query.type);
|
|
227
|
+
return {
|
|
228
|
+
success: true,
|
|
229
|
+
data: { deleted, type: query.type ?? null },
|
|
230
|
+
message: query.type
|
|
231
|
+
? `Cleared ${deleted} ${query.type} ${deleted === 1 ? 'entry' : 'entries'}`
|
|
232
|
+
: `Cleared ${deleted} ${deleted === 1 ? 'entry' : 'entries'}`,
|
|
233
|
+
};
|
|
217
234
|
}
|
|
218
235
|
// ==================== Resolution Endpoints ====================
|
|
219
236
|
/**
|
|
@@ -260,11 +277,21 @@ let NestLensApiController = class NestLensApiController {
|
|
|
260
277
|
return { success: true, data: status };
|
|
261
278
|
}
|
|
262
279
|
/**
|
|
263
|
-
*
|
|
280
|
+
* Whether recording is on, and what it has been doing.
|
|
281
|
+
*
|
|
282
|
+
* The counts are here because "nothing was recorded" and "nothing happened"
|
|
283
|
+
* look identical on a dashboard: an application spent two days deciding
|
|
284
|
+
* which of the two it was looking at. Sampling and the filter each drop
|
|
285
|
+
* entries deliberately, and this says how many.
|
|
264
286
|
*/
|
|
265
287
|
async getRecordingStatus(_res) {
|
|
266
|
-
|
|
267
|
-
|
|
288
|
+
return {
|
|
289
|
+
data: {
|
|
290
|
+
...this.collectorService.getRecordingStatus(),
|
|
291
|
+
counts: this.collectorService.getRecordingCounts(),
|
|
292
|
+
buffer: this.collectorService.getBufferSize(),
|
|
293
|
+
},
|
|
294
|
+
};
|
|
268
295
|
}
|
|
269
296
|
};
|
|
270
297
|
exports.NestLensApiController = NestLensApiController;
|
|
@@ -387,9 +414,10 @@ __decorate([
|
|
|
387
414
|
], NestLensApiController.prototype, "runPruning", null);
|
|
388
415
|
__decorate([
|
|
389
416
|
(0, common_1.Delete)('entries'),
|
|
390
|
-
__param(0, (0, common_1.
|
|
417
|
+
__param(0, (0, common_1.Query)()),
|
|
418
|
+
__param(1, (0, common_1.Res)()),
|
|
391
419
|
__metadata("design:type", Function),
|
|
392
|
-
__metadata("design:paramtypes", [Object]),
|
|
420
|
+
__metadata("design:paramtypes", [dto_1.ClearEntriesQueryDto, Object]),
|
|
393
421
|
__metadata("design:returntype", Promise)
|
|
394
422
|
], NestLensApiController.prototype, "clearEntries", null);
|
|
395
423
|
__decorate([
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EntryType } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Query of `DELETE entries`.
|
|
4
|
+
*
|
|
5
|
+
* Without a type it deletes everything, which is what the button in the
|
|
6
|
+
* sidebar has always done. With one it deletes that type and leaves the rest —
|
|
7
|
+
* `pruneByType` existed on every storage and on the interface, and nothing
|
|
8
|
+
* called it: the capability was there and had no door.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ClearEntriesQueryDto {
|
|
11
|
+
type?: EntryType;
|
|
12
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ClearEntriesQueryDto = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
const entry_types_1 = require("./entry-types");
|
|
15
|
+
/**
|
|
16
|
+
* Query of `DELETE entries`.
|
|
17
|
+
*
|
|
18
|
+
* Without a type it deletes everything, which is what the button in the
|
|
19
|
+
* sidebar has always done. With one it deletes that type and leaves the rest —
|
|
20
|
+
* `pruneByType` existed on every storage and on the interface, and nothing
|
|
21
|
+
* called it: the capability was there and had no door.
|
|
22
|
+
*/
|
|
23
|
+
class ClearEntriesQueryDto {
|
|
24
|
+
}
|
|
25
|
+
exports.ClearEntriesQueryDto = ClearEntriesQueryDto;
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, class_validator_1.IsOptional)(),
|
|
28
|
+
(0, class_validator_1.IsIn)(entry_types_1.ENTRY_TYPES, {
|
|
29
|
+
message: `type must be one of: ${entry_types_1.ENTRY_TYPES.join(', ')}`,
|
|
30
|
+
}),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], ClearEntriesQueryDto.prototype, "type", void 0);
|
|
@@ -6,4 +6,13 @@ import { EntryType } from '../../types';
|
|
|
6
6
|
* does not record, or rejects one it does, is a filter that silently returns
|
|
7
7
|
* nothing.
|
|
8
8
|
*/
|
|
9
|
+
/**
|
|
10
|
+
* Every type an entry can have, from the one list that defines them.
|
|
11
|
+
*
|
|
12
|
+
* Written out here as well until the Redis driver's copy of the same list fell
|
|
13
|
+
* one type behind and made `graphql` entries invisible to stats. A DTO that
|
|
14
|
+
* accepts a type the storage does not record, or rejects one it does, is a
|
|
15
|
+
* filter that silently returns nothing — so this is the same list, not another
|
|
16
|
+
* one.
|
|
17
|
+
*/
|
|
9
18
|
export declare const ENTRY_TYPES: EntryType[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ENTRY_TYPES = void 0;
|
|
4
|
+
const types_1 = require("../../types");
|
|
4
5
|
/**
|
|
5
6
|
* Every type an entry can have.
|
|
6
7
|
*
|
|
@@ -8,24 +9,13 @@ exports.ENTRY_TYPES = void 0;
|
|
|
8
9
|
* does not record, or rejects one it does, is a filter that silently returns
|
|
9
10
|
* nothing.
|
|
10
11
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
'http-client',
|
|
22
|
-
'redis',
|
|
23
|
-
'model',
|
|
24
|
-
'notification',
|
|
25
|
-
'view',
|
|
26
|
-
'command',
|
|
27
|
-
'gate',
|
|
28
|
-
'batch',
|
|
29
|
-
'dump',
|
|
30
|
-
'graphql',
|
|
31
|
-
];
|
|
12
|
+
/**
|
|
13
|
+
* Every type an entry can have, from the one list that defines them.
|
|
14
|
+
*
|
|
15
|
+
* Written out here as well until the Redis driver's copy of the same list fell
|
|
16
|
+
* one type behind and made `graphql` entries invisible to stats. A DTO that
|
|
17
|
+
* accepts a type the storage does not record, or rejects one it does, is a
|
|
18
|
+
* filter that silently returns nothing — so this is the same list, not another
|
|
19
|
+
* one.
|
|
20
|
+
*/
|
|
21
|
+
exports.ENTRY_TYPES = [...types_1.ENTRY_TYPES];
|
package/dist/api/dto/index.d.ts
CHANGED
package/dist/api/dto/index.js
CHANGED
|
@@ -38,6 +38,42 @@ const MAX_TIMEOUT_MS = 2 ** 31 - 1;
|
|
|
38
38
|
* expire, and a cap alone would evict live keys under load.
|
|
39
39
|
*/
|
|
40
40
|
const MAX_THROTTLE_KEYS = 5_000;
|
|
41
|
+
/**
|
|
42
|
+
* Whether a webhook is for this entry.
|
|
43
|
+
*
|
|
44
|
+
* `events` is a list of types, and the thing people actually want to be told
|
|
45
|
+
* about is *failures* — which needs a list per type plus an entry filter that
|
|
46
|
+
* knows the shape of each payload. An application reported reaching that at a
|
|
47
|
+
* hundred lines of configuration. `'failures'` says it directly.
|
|
48
|
+
*
|
|
49
|
+
* A 4xx is not a failure here: a malformed query or a bad request is the
|
|
50
|
+
* caller's mistake, and a webhook anyone with curl can ring is a pager anyone
|
|
51
|
+
* with curl can ring.
|
|
52
|
+
*/
|
|
53
|
+
const announces = (events, entry) => {
|
|
54
|
+
if (events === 'failures')
|
|
55
|
+
return isFailure(entry);
|
|
56
|
+
return events.includes(entry.type);
|
|
57
|
+
};
|
|
58
|
+
const isFailure = (entry) => {
|
|
59
|
+
switch (entry.type) {
|
|
60
|
+
case 'exception':
|
|
61
|
+
return true;
|
|
62
|
+
case 'graphql':
|
|
63
|
+
return entry.payload.hasErrors === true && (entry.payload.statusCode ?? 500) >= 500;
|
|
64
|
+
case 'request':
|
|
65
|
+
return (entry.payload.statusCode ?? 0) >= 500;
|
|
66
|
+
case 'job':
|
|
67
|
+
case 'schedule':
|
|
68
|
+
case 'mail':
|
|
69
|
+
case 'notification':
|
|
70
|
+
return entry.payload.status === 'failed';
|
|
71
|
+
case 'log':
|
|
72
|
+
return entry.payload.level === 'error';
|
|
73
|
+
default:
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
41
77
|
/**
|
|
42
78
|
* Sends collected entries (exceptions by default) to Slack/Discord/generic
|
|
43
79
|
* webhooks in real time. Subscribes to the collector's entry stream, so it
|
|
@@ -72,7 +108,7 @@ let AlertingService = AlertingService_1 = class AlertingService {
|
|
|
72
108
|
async dispatch(entry) {
|
|
73
109
|
const webhooks = this.config?.webhooks ?? [];
|
|
74
110
|
await Promise.all(webhooks
|
|
75
|
-
.filter((webhook) => (webhook.events ?? DEFAULT_EVENTS
|
|
111
|
+
.filter((webhook) => announces(webhook.events ?? DEFAULT_EVENTS, entry))
|
|
76
112
|
.filter((webhook) => !this.isThrottled(webhook, entry))
|
|
77
113
|
.map((webhook) => this.send(webhook, entry)));
|
|
78
114
|
}
|
|
@@ -37,6 +37,10 @@ export declare class CollectorService implements OnModuleDestroy {
|
|
|
37
37
|
*/
|
|
38
38
|
private storageIsFailing;
|
|
39
39
|
private droppedEntries;
|
|
40
|
+
/** Counted where they are decided; read by `getRecordingCounts`. */
|
|
41
|
+
private recordedEntries;
|
|
42
|
+
private droppedBySampling;
|
|
43
|
+
private droppedByFilter;
|
|
40
44
|
private isPaused;
|
|
41
45
|
private pausedAt?;
|
|
42
46
|
private pauseReason?;
|
|
@@ -90,6 +94,20 @@ export declare class CollectorService implements OnModuleDestroy {
|
|
|
90
94
|
capacity: number;
|
|
91
95
|
dropped: number;
|
|
92
96
|
};
|
|
97
|
+
/**
|
|
98
|
+
* What was recorded, and what was dropped on the way in.
|
|
99
|
+
*
|
|
100
|
+
* "Nothing was recorded" and "nothing happened" look identical on the
|
|
101
|
+
* dashboard, and an application spent two days deciding which of the two it
|
|
102
|
+
* was looking at. Sampling and the filter each drop entries deliberately;
|
|
103
|
+
* saying how many turns that question into a glance.
|
|
104
|
+
*/
|
|
105
|
+
getRecordingCounts(): {
|
|
106
|
+
recorded: number;
|
|
107
|
+
droppedBySampling: number;
|
|
108
|
+
droppedByFilter: number;
|
|
109
|
+
droppedByBuffer: number;
|
|
110
|
+
};
|
|
93
111
|
/**
|
|
94
112
|
* Collect an entry
|
|
95
113
|
* Uses discriminated union pattern - the type parameter determines the expected payload type
|
|
@@ -72,6 +72,10 @@ let CollectorService = CollectorService_1 = class CollectorService {
|
|
|
72
72
|
*/
|
|
73
73
|
this.storageIsFailing = false;
|
|
74
74
|
this.droppedEntries = 0;
|
|
75
|
+
/** Counted where they are decided; read by `getRecordingCounts`. */
|
|
76
|
+
this.recordedEntries = 0;
|
|
77
|
+
this.droppedBySampling = 0;
|
|
78
|
+
this.droppedByFilter = 0;
|
|
75
79
|
this.isPaused = false;
|
|
76
80
|
// Real-time stream of persisted entries. Powers the SSE live-tail and the
|
|
77
81
|
// alerting service. Entries are emitted after they have been saved (so they
|
|
@@ -148,6 +152,22 @@ let CollectorService = CollectorService_1 = class CollectorService {
|
|
|
148
152
|
dropped: this.droppedEntries,
|
|
149
153
|
};
|
|
150
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* What was recorded, and what was dropped on the way in.
|
|
157
|
+
*
|
|
158
|
+
* "Nothing was recorded" and "nothing happened" look identical on the
|
|
159
|
+
* dashboard, and an application spent two days deciding which of the two it
|
|
160
|
+
* was looking at. Sampling and the filter each drop entries deliberately;
|
|
161
|
+
* saying how many turns that question into a glance.
|
|
162
|
+
*/
|
|
163
|
+
getRecordingCounts() {
|
|
164
|
+
return {
|
|
165
|
+
recorded: this.recordedEntries,
|
|
166
|
+
droppedBySampling: this.droppedBySampling,
|
|
167
|
+
droppedByFilter: this.droppedByFilter,
|
|
168
|
+
droppedByBuffer: this.droppedEntries,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
151
171
|
/**
|
|
152
172
|
* Collect an entry
|
|
153
173
|
* Uses discriminated union pattern - the type parameter determines the expected payload type
|
|
@@ -173,6 +193,7 @@ let CollectorService = CollectorService_1 = class CollectorService {
|
|
|
173
193
|
requestId: requestId ?? (0, request_context_1.currentRequestId)(),
|
|
174
194
|
};
|
|
175
195
|
if (this.sampler && !this.sampler.shouldRecord(entry)) {
|
|
196
|
+
this.droppedBySampling += 1;
|
|
176
197
|
return;
|
|
177
198
|
}
|
|
178
199
|
// The filter callback runs in the application's own process against its own
|
|
@@ -180,6 +201,7 @@ let CollectorService = CollectorService_1 = class CollectorService {
|
|
|
180
201
|
// there stored, streamed and posted to webhooks — is masked.
|
|
181
202
|
const shouldCollect = await this.applyFilter(entry);
|
|
182
203
|
if (!shouldCollect) {
|
|
204
|
+
this.droppedByFilter += 1;
|
|
183
205
|
return;
|
|
184
206
|
}
|
|
185
207
|
try {
|
|
@@ -192,6 +214,7 @@ let CollectorService = CollectorService_1 = class CollectorService {
|
|
|
192
214
|
this.logger.warn(`Failed to record entry: ${error}`);
|
|
193
215
|
return;
|
|
194
216
|
}
|
|
217
|
+
this.recordedEntries += 1;
|
|
195
218
|
this.enforceBufferLimit();
|
|
196
219
|
// Flush if buffer is full — unless storage is already failing, in which
|
|
197
220
|
// case the periodic timer retries and the caller is not made to wait.
|
|
@@ -216,15 +239,18 @@ let CollectorService = CollectorService_1 = class CollectorService {
|
|
|
216
239
|
requestId: requestId ?? (0, request_context_1.currentRequestId)(),
|
|
217
240
|
};
|
|
218
241
|
if (this.sampler && !this.sampler.shouldRecord(entry)) {
|
|
242
|
+
this.droppedBySampling += 1;
|
|
219
243
|
return null;
|
|
220
244
|
}
|
|
221
245
|
// Apply filter
|
|
222
246
|
const shouldCollect = await this.applyFilter(entry);
|
|
223
247
|
if (!shouldCollect) {
|
|
248
|
+
this.droppedByFilter += 1;
|
|
224
249
|
return null;
|
|
225
250
|
}
|
|
226
251
|
try {
|
|
227
252
|
const savedEntry = await this.storage.save(this.mask(entry));
|
|
253
|
+
this.recordedEntries += 1;
|
|
228
254
|
// Apply auto-tagging and family hash after saving
|
|
229
255
|
await this.applyAutoTagging(savedEntry);
|
|
230
256
|
this.emit(savedEntry);
|
|
@@ -26,7 +26,7 @@ export declare class MemoryStorage implements StorageInterface, OnModuleDestroy
|
|
|
26
26
|
findWithCursor(type: EntryType | undefined, params: CursorPaginationParams): Promise<CursorPaginatedResponse<Entry>>;
|
|
27
27
|
findById(id: number): Promise<Entry | null>;
|
|
28
28
|
count(type?: EntryType): Promise<number>;
|
|
29
|
-
clear(): Promise<
|
|
29
|
+
clear(type?: EntryType): Promise<number>;
|
|
30
30
|
close(): Promise<void>;
|
|
31
31
|
getLatestSequence(type?: EntryType): Promise<number | null>;
|
|
32
32
|
hasEntriesAfter(sequence: number, type?: EntryType): Promise<number>;
|
|
@@ -184,13 +184,27 @@ let MemoryStorage = MemoryStorage_1 = class MemoryStorage {
|
|
|
184
184
|
}
|
|
185
185
|
return results.length;
|
|
186
186
|
}
|
|
187
|
-
async clear() {
|
|
187
|
+
async clear(type) {
|
|
188
|
+
if (type) {
|
|
189
|
+
let deleted = 0;
|
|
190
|
+
for (const [id, entry] of this.entries) {
|
|
191
|
+
if (entry.type !== type)
|
|
192
|
+
continue;
|
|
193
|
+
this.entries.delete(id);
|
|
194
|
+
this.removeEntryTagsInternal(id);
|
|
195
|
+
deleted += 1;
|
|
196
|
+
}
|
|
197
|
+
this.logger.log(`Cleared ${deleted} ${type} entries`);
|
|
198
|
+
return deleted;
|
|
199
|
+
}
|
|
200
|
+
const deleted = this.entries.size;
|
|
188
201
|
this.entries.clear();
|
|
189
202
|
this.entryTags.clear();
|
|
190
203
|
this.tagIndex.clear();
|
|
191
204
|
this.nextId = 1;
|
|
192
205
|
this.oldestId = 1;
|
|
193
206
|
this.logger.log('Storage cleared');
|
|
207
|
+
return deleted;
|
|
194
208
|
}
|
|
195
209
|
async close() {
|
|
196
210
|
this.logger.log('In-memory storage closed');
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The connection URL with the configured database in it.
|
|
3
|
+
*
|
|
4
|
+
* `url` and `db` look additive — the URL for where the server is, `db` for
|
|
5
|
+
* which database — and they are not: ioredis takes the database from the URL's
|
|
6
|
+
* path and ignores the option beside it. Measured against ioredis:
|
|
7
|
+
* `new Redis('redis://127.0.0.1:6379/0', { db: 9 })` connects to 0.
|
|
8
|
+
*
|
|
9
|
+
* So an application that configured
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* redis: { url: process.env.REDIS_URL, db: 1, keyPrefix: 'nestlens:' }
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* wrote every entry into database 0, silently — reported by a deployment that
|
|
16
|
+
* found it by asking Redis. `keyPrefix` keeps the keys apart from the
|
|
17
|
+
* application's own, but `FLUSHDB` does not, and neither does an eviction
|
|
18
|
+
* policy: under `allkeys-lru` the entries and the application's cache compete
|
|
19
|
+
* for the same memory and evict each other.
|
|
20
|
+
*
|
|
21
|
+
* The setting is honoured instead of ignored: the database goes into the URL,
|
|
22
|
+
* which is the one place ioredis reads it from. Where the URL already names a
|
|
23
|
+
* different one, that is a configuration disagreeing with itself and it is
|
|
24
|
+
* said out loud rather than resolved quietly.
|
|
25
|
+
*/
|
|
26
|
+
export declare const withDatabase: (url: string, db: number | undefined) => string;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withDatabase = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const logger = new common_1.Logger('RedisStorage');
|
|
6
|
+
/**
|
|
7
|
+
* The connection URL with the configured database in it.
|
|
8
|
+
*
|
|
9
|
+
* `url` and `db` look additive — the URL for where the server is, `db` for
|
|
10
|
+
* which database — and they are not: ioredis takes the database from the URL's
|
|
11
|
+
* path and ignores the option beside it. Measured against ioredis:
|
|
12
|
+
* `new Redis('redis://127.0.0.1:6379/0', { db: 9 })` connects to 0.
|
|
13
|
+
*
|
|
14
|
+
* So an application that configured
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* redis: { url: process.env.REDIS_URL, db: 1, keyPrefix: 'nestlens:' }
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* wrote every entry into database 0, silently — reported by a deployment that
|
|
21
|
+
* found it by asking Redis. `keyPrefix` keeps the keys apart from the
|
|
22
|
+
* application's own, but `FLUSHDB` does not, and neither does an eviction
|
|
23
|
+
* policy: under `allkeys-lru` the entries and the application's cache compete
|
|
24
|
+
* for the same memory and evict each other.
|
|
25
|
+
*
|
|
26
|
+
* The setting is honoured instead of ignored: the database goes into the URL,
|
|
27
|
+
* which is the one place ioredis reads it from. Where the URL already names a
|
|
28
|
+
* different one, that is a configuration disagreeing with itself and it is
|
|
29
|
+
* said out loud rather than resolved quietly.
|
|
30
|
+
*/
|
|
31
|
+
const withDatabase = (url, db) => {
|
|
32
|
+
if (db === undefined)
|
|
33
|
+
return url;
|
|
34
|
+
let parsed;
|
|
35
|
+
try {
|
|
36
|
+
parsed = new URL(url);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
// Not a URL this can read — ioredis has its own parser and may well
|
|
40
|
+
// accept it, so it is passed on untouched rather than refused here.
|
|
41
|
+
return url;
|
|
42
|
+
}
|
|
43
|
+
const inUrl = parsed.pathname.replace(/^\//, '');
|
|
44
|
+
if (inUrl.length > 0 && inUrl !== String(db)) {
|
|
45
|
+
logger.warn(`storage.redis.url names database ${inUrl} and storage.redis.db says ${db}. ` +
|
|
46
|
+
`Using ${db}; remove one of them so the configuration says one thing.`);
|
|
47
|
+
}
|
|
48
|
+
parsed.pathname = `/${db}`;
|
|
49
|
+
return parsed.toString();
|
|
50
|
+
};
|
|
51
|
+
exports.withDatabase = withDatabase;
|
|
@@ -145,7 +145,7 @@ export declare class RedisStorage implements StorageInterface, OnModuleDestroy {
|
|
|
145
145
|
* batches, and the deletes go out in pipelines rather than as one `DEL` with
|
|
146
146
|
* a million arguments.
|
|
147
147
|
*/
|
|
148
|
-
clear(): Promise<
|
|
148
|
+
clear(type?: EntryType): Promise<number>;
|
|
149
149
|
/**
|
|
150
150
|
* Closes the connection, whether or not there ever was one.
|
|
151
151
|
*
|
|
@@ -45,9 +45,11 @@ var RedisStorage_1;
|
|
|
45
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
46
|
exports.RedisStorage = void 0;
|
|
47
47
|
const common_1 = require("@nestjs/common");
|
|
48
|
+
const types_1 = require("../../types");
|
|
48
49
|
const entry_filter_1 = require("./entry-filter");
|
|
49
50
|
const tag_normalization_1 = require("./tag-normalization");
|
|
50
51
|
const serialize_payload_1 = require("./serialize-payload");
|
|
52
|
+
const redis_url_1 = require("./redis-url");
|
|
51
53
|
/**
|
|
52
54
|
* Redis storage implementation for NestLens.
|
|
53
55
|
* Requires ioredis to be installed.
|
|
@@ -138,7 +140,7 @@ let RedisStorage = RedisStorage_1 = class RedisStorage {
|
|
|
138
140
|
const { default: RedisClient } = await Promise.resolve().then(() => __importStar(require('ioredis')));
|
|
139
141
|
const commandTimeout = this.config.commandTimeout ?? 5000;
|
|
140
142
|
const client = this.config.url
|
|
141
|
-
? new RedisClient(this.config.url, { commandTimeout })
|
|
143
|
+
? new RedisClient((0, redis_url_1.withDatabase)(this.config.url, this.config.db), { commandTimeout })
|
|
142
144
|
: new RedisClient({
|
|
143
145
|
host: this.config.host ?? 'localhost',
|
|
144
146
|
port: this.config.port ?? 6379,
|
|
@@ -605,10 +607,20 @@ let RedisStorage = RedisStorage_1 = class RedisStorage {
|
|
|
605
607
|
* batches, and the deletes go out in pipelines rather than as one `DEL` with
|
|
606
608
|
* a million arguments.
|
|
607
609
|
*/
|
|
608
|
-
async clear() {
|
|
610
|
+
async clear(type) {
|
|
611
|
+
if (type) {
|
|
612
|
+
// Every id of that type, whatever its age and whether or not a monitored
|
|
613
|
+
// tag protects it from *pruning*: this is somebody deleting, not the
|
|
614
|
+
// timer tidying.
|
|
615
|
+
const ids = await this.getClient().zrange(this.key('entries', 'type', type), 0, -1);
|
|
616
|
+
await this.deleteEntries(ids);
|
|
617
|
+
this.logger.log(`Cleared ${ids.length} ${type} entries`);
|
|
618
|
+
return ids.length;
|
|
619
|
+
}
|
|
609
620
|
const client = this.getClient();
|
|
610
621
|
let cursor = '0';
|
|
611
622
|
let removed = 0;
|
|
623
|
+
const total = await client.zcard(this.key('entries', 'all'));
|
|
612
624
|
do {
|
|
613
625
|
const [next, keys] = await client.scan(cursor, 'MATCH', `${this.keyPrefix}*`, 'COUNT', 500);
|
|
614
626
|
cursor = next;
|
|
@@ -622,6 +634,7 @@ let RedisStorage = RedisStorage_1 = class RedisStorage {
|
|
|
622
634
|
}
|
|
623
635
|
} while (cursor !== '0');
|
|
624
636
|
this.logger.log(`Storage cleared (${removed} keys)`);
|
|
637
|
+
return total;
|
|
625
638
|
}
|
|
626
639
|
/**
|
|
627
640
|
* Closes the connection, whether or not there ever was one.
|
|
@@ -699,28 +712,10 @@ let RedisStorage = RedisStorage_1 = class RedisStorage {
|
|
|
699
712
|
return client.zcount(key, `(${sequence}`, '+inf');
|
|
700
713
|
}
|
|
701
714
|
async getStats() {
|
|
702
|
-
//
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
'exception',
|
|
707
|
-
'log',
|
|
708
|
-
'cache',
|
|
709
|
-
'event',
|
|
710
|
-
'job',
|
|
711
|
-
'schedule',
|
|
712
|
-
'mail',
|
|
713
|
-
'http-client',
|
|
714
|
-
'redis',
|
|
715
|
-
'model',
|
|
716
|
-
'notification',
|
|
717
|
-
'view',
|
|
718
|
-
'command',
|
|
719
|
-
'gate',
|
|
720
|
-
'batch',
|
|
721
|
-
'dump',
|
|
722
|
-
];
|
|
723
|
-
const { byType, total } = await this.countByType(types);
|
|
715
|
+
// Every type there is, from the one list that defines them. Written out
|
|
716
|
+
// here, this fell one behind the union — `graphql` was missing, so those
|
|
717
|
+
// entries were invisible to stats however many the store held.
|
|
718
|
+
const { byType, total } = await this.countByType([...types_1.ENTRY_TYPES]);
|
|
724
719
|
const [unresolvedExceptions, slowQueries, avgResponseTime] = await Promise.all([
|
|
725
720
|
this.countUnresolvedExceptions(),
|
|
726
721
|
this.countSlowQueries(),
|
|
@@ -807,27 +802,9 @@ let RedisStorage = RedisStorage_1 = class RedisStorage {
|
|
|
807
802
|
}
|
|
808
803
|
async getStorageStats() {
|
|
809
804
|
const client = this.getClient();
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
'exception',
|
|
814
|
-
'log',
|
|
815
|
-
'cache',
|
|
816
|
-
'event',
|
|
817
|
-
'job',
|
|
818
|
-
'schedule',
|
|
819
|
-
'mail',
|
|
820
|
-
'http-client',
|
|
821
|
-
'redis',
|
|
822
|
-
'model',
|
|
823
|
-
'notification',
|
|
824
|
-
'view',
|
|
825
|
-
'command',
|
|
826
|
-
'gate',
|
|
827
|
-
'batch',
|
|
828
|
-
'dump',
|
|
829
|
-
];
|
|
830
|
-
const { byType, total } = await this.countByType(types);
|
|
805
|
+
// The same one list, for the same reason: written out here, this was the
|
|
806
|
+
// second place `graphql` was missing from.
|
|
807
|
+
const { byType, total } = await this.countByType([...types_1.ENTRY_TYPES]);
|
|
831
808
|
const [oldest, newest] = await client
|
|
832
809
|
.pipeline()
|
|
833
810
|
.zrange(this.key('entries', 'all'), 0, 0)
|
|
@@ -166,7 +166,7 @@ export declare class SqliteStorage implements StorageInterface, OnModuleInit, On
|
|
|
166
166
|
getLatestSequence(type?: EntryType): Promise<number | null>;
|
|
167
167
|
hasEntriesAfter(sequence: number, type?: EntryType): Promise<number>;
|
|
168
168
|
getStorageStats(): Promise<StorageStats>;
|
|
169
|
-
clear(): Promise<
|
|
169
|
+
clear(type?: EntryType): Promise<number>;
|
|
170
170
|
close(): Promise<void>;
|
|
171
171
|
addTags(entryId: number, tags: string[]): Promise<void>;
|
|
172
172
|
removeTags(entryId: number, tags: string[]): Promise<void>;
|