@futurewindai/wotchi 0.1.0-beta.2 → 0.1.0-beta.6
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 +178 -47
- package/SECURITY.md +2 -2
- package/dist/cjs/core/admission.js +22 -0
- package/dist/cjs/core/client.js +416 -21
- package/dist/cjs/core/config.js +193 -18
- package/dist/cjs/core/diagnostics.js +16 -1
- package/dist/cjs/core/group-store.js +22 -9
- package/dist/cjs/core/incident-builder.js +18 -0
- package/dist/cjs/core/incident-policy.js +2 -7
- package/dist/cjs/core/limits.js +17 -0
- package/dist/cjs/core/normalize.js +16 -6
- package/dist/cjs/core/notification-queue.js +92 -6
- package/dist/cjs/core/prometheus.js +129 -0
- package/dist/cjs/core/redact.js +57 -8
- package/dist/cjs/core/runtime-monitor.js +109 -0
- package/dist/cjs/index.js +8 -1
- package/dist/cjs/integrations/express/error-handler.js +21 -4
- package/dist/cjs/integrations/express/index.js +2 -1
- package/dist/cjs/integrations/express/status-observer.js +6 -0
- package/dist/cjs/integrations/nest/capture.js +21 -0
- package/dist/cjs/integrations/nest/exception-filter.js +64 -8
- package/dist/cjs/integrations/nest/filter-wrapper.js +17 -0
- package/dist/cjs/integrations/nest/index.js +7 -1
- package/dist/cjs/integrations/nest/module.js +44 -0
- package/dist/cjs/integrations/nest/register.js +15 -1
- package/dist/cjs/integrations/request-context.js +83 -1
- package/dist/cjs/notifiers/alert-payload.js +20 -0
- package/dist/cjs/notifiers/console.js +85 -15
- package/dist/cjs/notifiers/telegram-format.js +75 -5
- package/dist/cjs/notifiers/webhook-http.js +394 -0
- package/dist/cjs/notifiers/webhook.js +28 -0
- package/dist/esm/core/admission.js +19 -0
- package/dist/esm/core/client.js +416 -21
- package/dist/esm/core/config.js +193 -18
- package/dist/esm/core/diagnostics.js +16 -1
- package/dist/esm/core/group-store.js +22 -9
- package/dist/esm/core/incident-builder.js +18 -0
- package/dist/esm/core/incident-policy.js +2 -7
- package/dist/esm/core/limits.js +14 -0
- package/dist/esm/core/normalize.js +16 -6
- package/dist/esm/core/notification-queue.js +92 -6
- package/dist/esm/core/prometheus.js +125 -0
- package/dist/esm/core/redact.js +57 -8
- package/dist/esm/core/runtime-monitor.js +106 -0
- package/dist/esm/index.js +4 -1
- package/dist/esm/integrations/express/error-handler.js +21 -4
- package/dist/esm/integrations/express/index.js +1 -1
- package/dist/esm/integrations/express/status-observer.js +6 -0
- package/dist/esm/integrations/nest/capture.js +17 -0
- package/dist/esm/integrations/nest/exception-filter.js +65 -9
- package/dist/esm/integrations/nest/filter-wrapper.js +14 -0
- package/dist/esm/integrations/nest/index.js +3 -1
- package/dist/esm/integrations/nest/module.js +41 -0
- package/dist/esm/integrations/nest/register.js +15 -1
- package/dist/esm/integrations/request-context.js +83 -1
- package/dist/esm/notifiers/alert-payload.js +16 -0
- package/dist/esm/notifiers/console.js +85 -15
- package/dist/esm/notifiers/telegram-format.js +75 -5
- package/dist/esm/notifiers/webhook-http.js +387 -0
- package/dist/esm/notifiers/webhook.js +24 -0
- package/dist/types/core/admission.d.ts +10 -0
- package/dist/types/core/config.d.ts +17 -1
- package/dist/types/core/diagnostics.d.ts +7 -1
- package/dist/types/core/incident-policy.d.ts +1 -1
- package/dist/types/core/limits.d.ts +14 -0
- package/dist/types/core/notification-queue.d.ts +14 -1
- package/dist/types/core/prometheus.d.ts +7 -0
- package/dist/types/core/runtime-monitor.d.ts +15 -0
- package/dist/types/core/types.d.ts +111 -2
- package/dist/types/index.d.ts +8 -2
- package/dist/types/integrations/express/index.d.ts +2 -2
- package/dist/types/integrations/nest/capture.d.ts +4 -0
- package/dist/types/integrations/nest/exception-filter.d.ts +6 -2
- package/dist/types/integrations/nest/filter-wrapper.d.ts +7 -0
- package/dist/types/integrations/nest/index.d.ts +6 -2
- package/dist/types/integrations/nest/module.d.ts +9 -0
- package/dist/types/integrations/nest/register.d.ts +3 -0
- package/dist/types/integrations/request-context.d.ts +3 -0
- package/dist/types/notifiers/alert-payload.d.ts +5 -0
- package/dist/types/notifiers/webhook-http.d.ts +37 -0
- package/dist/types/notifiers/webhook.d.ts +4 -0
- package/dist/types-cjs/core/admission.d.cts +10 -0
- package/dist/types-cjs/core/config.d.cts +17 -1
- package/dist/types-cjs/core/diagnostics.d.cts +7 -1
- package/dist/types-cjs/core/incident-policy.d.cts +1 -1
- package/dist/types-cjs/core/limits.d.cts +14 -0
- package/dist/types-cjs/core/notification-queue.d.cts +14 -1
- package/dist/types-cjs/core/prometheus.d.cts +7 -0
- package/dist/types-cjs/core/runtime-monitor.d.cts +15 -0
- package/dist/types-cjs/core/types.d.cts +111 -2
- package/dist/types-cjs/index.d.cts +8 -2
- package/dist/types-cjs/integrations/express/index.d.cts +2 -2
- package/dist/types-cjs/integrations/nest/capture.d.cts +4 -0
- package/dist/types-cjs/integrations/nest/exception-filter.d.cts +6 -2
- package/dist/types-cjs/integrations/nest/filter-wrapper.d.cts +7 -0
- package/dist/types-cjs/integrations/nest/index.d.cts +6 -2
- package/dist/types-cjs/integrations/nest/module.d.cts +9 -0
- package/dist/types-cjs/integrations/nest/register.d.cts +3 -0
- package/dist/types-cjs/integrations/request-context.d.cts +3 -0
- package/dist/types-cjs/notifiers/alert-payload.d.cts +5 -0
- package/dist/types-cjs/notifiers/webhook-http.d.cts +37 -0
- package/dist/types-cjs/notifiers/webhook.d.cts +4 -0
- package/package.json +17 -4
|
@@ -1,10 +1,40 @@
|
|
|
1
1
|
export type IncidentSeverity = "low" | "medium" | "high" | "critical";
|
|
2
|
-
export type WotchiEventKind = "error" | "manual" | "process-monitor";
|
|
2
|
+
export type WotchiEventKind = "error" | "manual" | "process-monitor" | "runtime-monitor";
|
|
3
|
+
export interface WotchiTraceContext {
|
|
4
|
+
traceId?: string;
|
|
5
|
+
spanId?: string;
|
|
6
|
+
}
|
|
3
7
|
export interface WotchiRequestContext extends Record<string, unknown> {
|
|
4
8
|
method?: string;
|
|
5
9
|
route?: string;
|
|
6
10
|
statusCode?: number;
|
|
7
11
|
requestId?: string;
|
|
12
|
+
correlationId?: string;
|
|
13
|
+
trace?: WotchiTraceContext;
|
|
14
|
+
}
|
|
15
|
+
export type WotchiTags = Readonly<Record<string, string>>;
|
|
16
|
+
export interface WotchiLinkTemplates {
|
|
17
|
+
log?: string;
|
|
18
|
+
trace?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface WotchiLinks {
|
|
21
|
+
log?: string;
|
|
22
|
+
trace?: string;
|
|
23
|
+
}
|
|
24
|
+
export type WotchiFingerprintCallback = (event: Readonly<SafeErrorEvent>) => string | undefined;
|
|
25
|
+
export type WotchiFingerprintOverride = string | WotchiFingerprintCallback;
|
|
26
|
+
export type WotchiEventFilter = (event: Readonly<SafeErrorEvent>) => boolean;
|
|
27
|
+
export type WotchiBeforeSend = (alert: Readonly<IncidentAlert>) => IncidentAlert | null | undefined;
|
|
28
|
+
export interface WotchiCaptureOptions {
|
|
29
|
+
fingerprint?: WotchiFingerprintOverride;
|
|
30
|
+
severity?: IncidentSeverity;
|
|
31
|
+
alertThreshold?: number;
|
|
32
|
+
request?: WotchiRequestContext;
|
|
33
|
+
trace?: WotchiTraceContext;
|
|
34
|
+
correlationId?: string;
|
|
35
|
+
operation?: string;
|
|
36
|
+
job?: string;
|
|
37
|
+
tags?: Record<string, unknown>;
|
|
8
38
|
}
|
|
9
39
|
export interface WotchiEventInput {
|
|
10
40
|
level: "error";
|
|
@@ -12,16 +42,28 @@ export interface WotchiEventInput {
|
|
|
12
42
|
message: string;
|
|
13
43
|
error?: unknown;
|
|
14
44
|
alertThreshold?: number;
|
|
45
|
+
severity?: IncidentSeverity;
|
|
46
|
+
fingerprint?: WotchiFingerprintOverride;
|
|
15
47
|
metadata?: Record<string, unknown>;
|
|
16
48
|
context?: Record<string, unknown>;
|
|
17
49
|
request?: WotchiRequestContext;
|
|
50
|
+
trace?: WotchiTraceContext;
|
|
51
|
+
correlationId?: string;
|
|
52
|
+
operation?: string;
|
|
53
|
+
job?: string;
|
|
54
|
+
tags?: Record<string, unknown>;
|
|
18
55
|
}
|
|
19
56
|
export interface SafeErrorEvent {
|
|
20
57
|
id: string;
|
|
21
58
|
timestamp: string;
|
|
22
59
|
service: string;
|
|
23
60
|
environment: string;
|
|
61
|
+
instance?: string;
|
|
24
62
|
release?: string;
|
|
63
|
+
correlationId?: string;
|
|
64
|
+
operation?: string;
|
|
65
|
+
job?: string;
|
|
66
|
+
tags?: WotchiTags;
|
|
25
67
|
error: {
|
|
26
68
|
name: string;
|
|
27
69
|
message: string;
|
|
@@ -29,6 +71,7 @@ export interface SafeErrorEvent {
|
|
|
29
71
|
code?: string;
|
|
30
72
|
};
|
|
31
73
|
request?: WotchiRequestContext;
|
|
74
|
+
trace?: WotchiTraceContext;
|
|
32
75
|
context?: Record<string, unknown>;
|
|
33
76
|
}
|
|
34
77
|
export interface IncidentGroup {
|
|
@@ -53,6 +96,19 @@ export interface IncidentAlert {
|
|
|
53
96
|
occurrences: number;
|
|
54
97
|
service: string;
|
|
55
98
|
environment: string;
|
|
99
|
+
instance?: string;
|
|
100
|
+
release?: string;
|
|
101
|
+
correlationId?: string;
|
|
102
|
+
operation?: string;
|
|
103
|
+
job?: string;
|
|
104
|
+
tags?: WotchiTags;
|
|
105
|
+
error?: SafeErrorEvent["error"] & {
|
|
106
|
+
applicationFrame?: string;
|
|
107
|
+
};
|
|
108
|
+
request?: WotchiRequestContext;
|
|
109
|
+
trace?: WotchiTraceContext;
|
|
110
|
+
context?: Record<string, unknown>;
|
|
111
|
+
links?: WotchiLinks;
|
|
56
112
|
}
|
|
57
113
|
export interface WotchiNotifier {
|
|
58
114
|
readonly name: string;
|
|
@@ -67,11 +123,33 @@ export interface TelegramNotifierOptions {
|
|
|
67
123
|
chatId: string;
|
|
68
124
|
timeoutMs?: number;
|
|
69
125
|
}
|
|
126
|
+
export interface WebhookNotifierOptions {
|
|
127
|
+
url: string;
|
|
128
|
+
headers?: Record<string, string>;
|
|
129
|
+
timeoutMs?: number;
|
|
130
|
+
maxRetries?: number;
|
|
131
|
+
allowHttpLoopback?: boolean;
|
|
132
|
+
allowPrivateDestinations?: boolean;
|
|
133
|
+
payloadBuilder?: (alert: Readonly<IncidentAlert>) => unknown;
|
|
134
|
+
}
|
|
135
|
+
export interface WotchiIncidentRule {
|
|
136
|
+
environment?: string;
|
|
137
|
+
route?: string;
|
|
138
|
+
ignore?: boolean;
|
|
139
|
+
alertThreshold?: number;
|
|
140
|
+
severity?: IncidentSeverity;
|
|
141
|
+
}
|
|
70
142
|
export interface WotchiConfig {
|
|
71
143
|
service: string;
|
|
72
144
|
environment: string;
|
|
145
|
+
instance?: string;
|
|
73
146
|
release?: string;
|
|
74
147
|
enabled?: boolean;
|
|
148
|
+
filter?: WotchiEventFilter;
|
|
149
|
+
fingerprint?: WotchiFingerprintCallback;
|
|
150
|
+
beforeSend?: WotchiBeforeSend;
|
|
151
|
+
links?: WotchiLinkTemplates;
|
|
152
|
+
rules?: readonly WotchiIncidentRule[];
|
|
75
153
|
grouping?: {
|
|
76
154
|
windowMs?: number;
|
|
77
155
|
alertThreshold?: number;
|
|
@@ -82,6 +160,16 @@ export interface WotchiConfig {
|
|
|
82
160
|
queue?: {
|
|
83
161
|
maxPendingAlerts?: number;
|
|
84
162
|
concurrency?: 1;
|
|
163
|
+
notifierTimeoutMs?: number;
|
|
164
|
+
notifierCircuitBreaker?: {
|
|
165
|
+
failureThreshold?: number;
|
|
166
|
+
cooldownMs?: number;
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
overload?: {
|
|
170
|
+
maxEventsPerSecond?: number;
|
|
171
|
+
burst?: number;
|
|
172
|
+
alertCooldownMs?: number;
|
|
85
173
|
};
|
|
86
174
|
privacy?: {
|
|
87
175
|
redactKeys?: string[];
|
|
@@ -100,12 +188,33 @@ export interface WotchiDiagnostics {
|
|
|
100
188
|
alertsDropped: number;
|
|
101
189
|
alertsSent: number;
|
|
102
190
|
notifierFailures: number;
|
|
191
|
+
fingerprintCallbackFailures: number;
|
|
192
|
+
filterFailures: number;
|
|
193
|
+
beforeSendFailures: number;
|
|
194
|
+
eventsSuppressed: number;
|
|
195
|
+
eventsDroppedOverload: number;
|
|
196
|
+
capturesAfterShutdown: number;
|
|
103
197
|
activeGroups: number;
|
|
104
198
|
pendingAlerts: number;
|
|
199
|
+
notifierTimeouts: number;
|
|
200
|
+
notifierCircuitOpenSkips: number;
|
|
201
|
+
}
|
|
202
|
+
export type WotchiTestAlertStatus = "sent" | "queue-full" | "timeout" | "notifier-failed";
|
|
203
|
+
export interface WotchiTestAlertResult {
|
|
204
|
+
status: WotchiTestAlertStatus;
|
|
205
|
+
configurationAccepted: true;
|
|
206
|
+
queued: boolean;
|
|
207
|
+
flushed: boolean;
|
|
208
|
+
delivered: boolean;
|
|
209
|
+
notifierFailures: number;
|
|
210
|
+
diagnostics: Readonly<WotchiDiagnostics>;
|
|
211
|
+
error?: string;
|
|
105
212
|
}
|
|
106
213
|
export interface WotchiClient {
|
|
107
|
-
captureException(error: unknown, context?: Record<string, unknown
|
|
214
|
+
captureException(error: unknown, context?: Record<string, unknown>, options?: WotchiCaptureOptions): void;
|
|
108
215
|
captureEvent(event: WotchiEventInput): void;
|
|
216
|
+
testAlert(): Promise<WotchiTestAlertResult>;
|
|
109
217
|
flush(timeoutMs?: number): Promise<void>;
|
|
218
|
+
shutdown(timeoutMs?: number): Promise<void>;
|
|
110
219
|
getDiagnostics(): Readonly<WotchiDiagnostics>;
|
|
111
220
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { createWotchi } from "./core/client.js";
|
|
2
2
|
import { registerWotchiProcessMonitor } from "./core/process-monitor.js";
|
|
3
|
+
import { createWotchiPrometheusExporter, PROMETHEUS_CONTENT_TYPE } from "./core/prometheus.js";
|
|
4
|
+
import { registerWotchiRuntimeWatcher } from "./core/runtime-monitor.js";
|
|
3
5
|
import { consoleNotifier } from "./notifiers/console.js";
|
|
4
6
|
import { telegramNotifier } from "./notifiers/telegram.js";
|
|
7
|
+
import { webhookNotifier } from "./notifiers/webhook.js";
|
|
5
8
|
export { WotchiConfigurationError } from "./core/errors.js";
|
|
6
9
|
export type { ProcessMonitorHandle } from "./core/process-monitor.js";
|
|
7
10
|
export type { NormalizedWotchiConfig } from "./core/config.js";
|
|
8
|
-
export type {
|
|
9
|
-
export {
|
|
11
|
+
export type { WotchiPrometheusExporter } from "./core/prometheus.js";
|
|
12
|
+
export type { WotchiRuntimeWatcherHandle, WotchiRuntimeWatcherOptions, } from "./core/runtime-monitor.js";
|
|
13
|
+
export type { ConsoleNotifierOptions, IncidentAlert, IncidentGroup, IncidentSeverity, SafeErrorEvent, TelegramNotifierOptions, WebhookNotifierOptions, WotchiBeforeSend, WotchiCaptureOptions, WotchiClient, WotchiConfig, WotchiDiagnostics, WotchiEventFilter, WotchiEventInput, WotchiEventKind, WotchiFingerprintOverride, WotchiFingerprintCallback, WotchiIncidentRule, WotchiLinkTemplates, WotchiLinks, WotchiNotifier, WotchiRequestContext, WotchiTags, WotchiTestAlertResult, WotchiTestAlertStatus, WotchiTraceContext, } from "./core/types.js";
|
|
14
|
+
export type { WebhookRequestFunction, WebhookRequestOptions, WebhookResponse, } from "./notifiers/webhook-http.js";
|
|
15
|
+
export { consoleNotifier, createWotchi, createWotchiPrometheusExporter, PROMETHEUS_CONTENT_TYPE, registerWotchiProcessMonitor, registerWotchiRuntimeWatcher, telegramNotifier, webhookNotifier, };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { WotchiClient } from "../../core/types.js";
|
|
2
2
|
import { createExpressErrorHandler } from "./error-handler.js";
|
|
3
3
|
import type { ExpressWotchiOptions } from "./request-context.js";
|
|
4
|
-
export { consoleNotifier, createWotchi, telegramNotifier } from "../../index.js";
|
|
5
|
-
export type { ConsoleNotifierOptions, IncidentAlert, IncidentGroup, IncidentSeverity, SafeErrorEvent, TelegramNotifierOptions, WotchiClient, WotchiConfig, WotchiDiagnostics, WotchiEventInput, WotchiNotifier, WotchiRequestContext, } from "../../index.js";
|
|
4
|
+
export { consoleNotifier, createWotchi, telegramNotifier, webhookNotifier } from "../../index.js";
|
|
5
|
+
export type { ConsoleNotifierOptions, IncidentAlert, IncidentGroup, IncidentSeverity, SafeErrorEvent, TelegramNotifierOptions, WebhookNotifierOptions, WotchiBeforeSend, WotchiCaptureOptions, WotchiClient, WotchiConfig, WotchiDiagnostics, WotchiEventFilter, WotchiEventInput, WotchiFingerprintCallback, WotchiFingerprintOverride, WotchiIncidentRule, WotchiLinkTemplates, WotchiLinks, WotchiNotifier, WotchiRequestContext, WotchiTags, WotchiTestAlertResult, WotchiTestAlertStatus, WotchiTraceContext, } from "../../index.js";
|
|
6
6
|
export type { ExpressWotchiOptions } from "./request-context.js";
|
|
7
7
|
export type { WotchiStatusClass, WotchiStatusObserverOptions } from "./status-observer.js";
|
|
8
8
|
export { wotchiStatusObserver } from "./status-observer.js";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ArgumentsHost } from "@nestjs/common";
|
|
2
|
+
import type { WotchiClient } from "../../core/types.js";
|
|
3
|
+
import { type NestWotchiOptions } from "./request-context.js";
|
|
4
|
+
export declare const captureWotchiNestException: (client: WotchiClient, exception: unknown, host: ArgumentsHost, options?: NestWotchiOptions) => void;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { type ArgumentsHost, type HttpServer } from "@nestjs/common";
|
|
2
2
|
import { BaseExceptionFilter } from "@nestjs/core";
|
|
3
3
|
import type { WotchiClient } from "../../core/types.js";
|
|
4
|
-
import {
|
|
4
|
+
import type { NestExceptionFilterLike } from "./filter-wrapper.js";
|
|
5
|
+
import type { NestWotchiOptions } from "./request-context.js";
|
|
5
6
|
export declare class WotchiNestExceptionFilter extends BaseExceptionFilter<unknown> {
|
|
6
7
|
private readonly client;
|
|
7
8
|
private readonly options?;
|
|
8
|
-
|
|
9
|
+
private readonly previousGlobalFilters;
|
|
10
|
+
constructor(client: WotchiClient, applicationRef?: HttpServer, options?: NestWotchiOptions | undefined, previousGlobalFilters?: readonly NestExceptionFilterLike[]);
|
|
9
11
|
catch(exception: unknown, host: ArgumentsHost): void;
|
|
12
|
+
private respondWithoutLoggingRawUnknownException;
|
|
13
|
+
private respondThroughExpressAdapter;
|
|
10
14
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ArgumentsHost } from "@nestjs/common";
|
|
2
|
+
import type { WotchiClient } from "../../core/types.js";
|
|
3
|
+
import type { NestWotchiOptions } from "./request-context.js";
|
|
4
|
+
export interface NestExceptionFilterLike {
|
|
5
|
+
catch(exception: unknown, host: ArgumentsHost): void;
|
|
6
|
+
}
|
|
7
|
+
export declare function withWotchiNestFilter<TFilter extends NestExceptionFilterLike>(client: WotchiClient, filter: TFilter, options?: NestWotchiOptions): TFilter;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
export { consoleNotifier, createWotchi, telegramNotifier } from "../../index.js";
|
|
1
|
+
export { consoleNotifier, createWotchi, telegramNotifier, webhookNotifier } from "../../index.js";
|
|
2
|
+
export { withWotchiNestFilter } from "./filter-wrapper.js";
|
|
3
|
+
export { WotchiModule, WOTCHI_CLIENT } from "./module.js";
|
|
2
4
|
export { registerWotchiNest, registerWotchiNestStatusObserver } from "./register.js";
|
|
3
|
-
export type { ConsoleNotifierOptions, IncidentAlert, IncidentGroup, IncidentSeverity, SafeErrorEvent, TelegramNotifierOptions, WotchiClient, WotchiConfig, WotchiDiagnostics, WotchiEventInput, WotchiNotifier, WotchiRequestContext, } from "../../index.js";
|
|
5
|
+
export type { ConsoleNotifierOptions, IncidentAlert, IncidentGroup, IncidentSeverity, SafeErrorEvent, TelegramNotifierOptions, WebhookNotifierOptions, WotchiBeforeSend, WotchiCaptureOptions, WotchiClient, WotchiConfig, WotchiDiagnostics, WotchiEventFilter, WotchiEventInput, WotchiFingerprintCallback, WotchiFingerprintOverride, WotchiIncidentRule, WotchiLinkTemplates, WotchiLinks, WotchiNotifier, WotchiRequestContext, WotchiTags, WotchiTestAlertResult, WotchiTestAlertStatus, WotchiTraceContext, } from "../../index.js";
|
|
4
6
|
export type { NestWotchiApplication, NestWotchiOptions } from "./register.js";
|
|
7
|
+
export type { NestExceptionFilterLike } from "./filter-wrapper.js";
|
|
8
|
+
export type { WotchiNestModuleOptions } from "./module.js";
|
|
5
9
|
export type { WotchiStatusClass, WotchiStatusObserverOptions } from "../express/status-observer.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type DynamicModule } from "@nestjs/common";
|
|
2
|
+
import type { WotchiConfig } from "../../core/types.js";
|
|
3
|
+
export declare const WOTCHI_CLIENT: unique symbol;
|
|
4
|
+
export interface WotchiNestModuleOptions {
|
|
5
|
+
registerGlobalFilter?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare class WotchiModule {
|
|
8
|
+
static forRoot(config: WotchiConfig, options?: WotchiNestModuleOptions): DynamicModule;
|
|
9
|
+
}
|
|
@@ -8,6 +8,9 @@ export interface NestWotchiApplication {
|
|
|
8
8
|
getHttpAdapter?: () => unknown;
|
|
9
9
|
use?: (...middleware: unknown[]) => unknown;
|
|
10
10
|
useGlobalFilters(...filters: unknown[]): unknown;
|
|
11
|
+
config?: {
|
|
12
|
+
getGlobalFilters?: () => unknown[];
|
|
13
|
+
};
|
|
11
14
|
}
|
|
12
15
|
export declare function registerWotchiNest(app: unknown, client: WotchiClient, options?: NestWotchiOptions): void;
|
|
13
16
|
export declare function registerWotchiNestStatusObserver(app: unknown, client: WotchiClient, options?: WotchiStatusObserverOptions): void;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { WotchiRequestContext } from "../core/types.js";
|
|
2
2
|
export interface RequestContextOptions {
|
|
3
3
|
requestIdProperty?: string;
|
|
4
|
+
correlationIdProperty?: string;
|
|
5
|
+
traceContextProperty?: string;
|
|
4
6
|
}
|
|
5
7
|
export declare function normalizeRoutePath(value: unknown): string | undefined;
|
|
6
8
|
export interface RequestContextInput {
|
|
@@ -8,6 +10,7 @@ export interface RequestContextInput {
|
|
|
8
10
|
method?: unknown;
|
|
9
11
|
route?: unknown;
|
|
10
12
|
statusCode?: unknown;
|
|
13
|
+
trace?: unknown;
|
|
11
14
|
options?: RequestContextOptions;
|
|
12
15
|
}
|
|
13
16
|
export declare function buildRequestContext(input: RequestContextInput): WotchiRequestContext | undefined;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SafeNormalizedValue } from "../core/normalize.js";
|
|
2
|
+
import type { IncidentAlert } from "../core/types.js";
|
|
3
|
+
export type BoundedAlertPayload = Record<string, SafeNormalizedValue>;
|
|
4
|
+
export declare function toBoundedPayload(value: unknown): BoundedAlertPayload;
|
|
5
|
+
export declare function toBoundedAlertPayload(alert: IncidentAlert): BoundedAlertPayload;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { IncidentAlert, WebhookNotifierOptions } from "../core/types.js";
|
|
2
|
+
export interface WebhookRequestOptions {
|
|
3
|
+
protocol: "http:" | "https:";
|
|
4
|
+
hostname: string;
|
|
5
|
+
port?: string;
|
|
6
|
+
method: "POST";
|
|
7
|
+
path: string;
|
|
8
|
+
headers: Record<string, string | number>;
|
|
9
|
+
allowPrivateDestinations?: boolean;
|
|
10
|
+
signal?: AbortSignal;
|
|
11
|
+
}
|
|
12
|
+
export interface WebhookResponse {
|
|
13
|
+
statusCode: number;
|
|
14
|
+
headers: Record<string, string | string[] | undefined>;
|
|
15
|
+
body: string;
|
|
16
|
+
}
|
|
17
|
+
export type WebhookRequestFunction = (options: WebhookRequestOptions, body: string, timeoutMs: number) => Promise<WebhookResponse>;
|
|
18
|
+
export interface WebhookSendOptions {
|
|
19
|
+
url: string;
|
|
20
|
+
alert: IncidentAlert;
|
|
21
|
+
headers?: Record<string, string>;
|
|
22
|
+
timeoutMs?: number;
|
|
23
|
+
maxRetries?: number;
|
|
24
|
+
allowHttpLoopback?: boolean;
|
|
25
|
+
allowPrivateDestinations?: boolean;
|
|
26
|
+
payloadBuilder?: (alert: Readonly<IncidentAlert>) => unknown;
|
|
27
|
+
}
|
|
28
|
+
export declare function normalizeWebhookOptions(options: WebhookNotifierOptions): {
|
|
29
|
+
url: URL;
|
|
30
|
+
headers?: Record<string, string>;
|
|
31
|
+
timeoutMs: number;
|
|
32
|
+
maxRetries: number;
|
|
33
|
+
allowHttpLoopback: boolean;
|
|
34
|
+
allowPrivateDestinations: boolean;
|
|
35
|
+
payloadBuilder?: WebhookNotifierOptions["payloadBuilder"];
|
|
36
|
+
};
|
|
37
|
+
export declare function sendWebhookAlert(options: WebhookSendOptions, request?: WebhookRequestFunction): Promise<void>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { WebhookNotifierOptions, WotchiNotifier } from "../core/types.js";
|
|
2
|
+
import { type WebhookRequestFunction } from "./webhook-http.js";
|
|
3
|
+
export declare function createWebhookNotifier(options: WebhookNotifierOptions, request?: WebhookRequestFunction): WotchiNotifier;
|
|
4
|
+
export declare function webhookNotifier(options: WebhookNotifierOptions): WotchiNotifier;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface CaptureAdmissionOptions {
|
|
2
|
+
maxEventsPerSecond: number;
|
|
3
|
+
burst: number;
|
|
4
|
+
now?: () => number;
|
|
5
|
+
}
|
|
6
|
+
export interface CaptureAdmission {
|
|
7
|
+
tryAcquire(): boolean;
|
|
8
|
+
}
|
|
9
|
+
/** A small token bucket used before normalization to bound overload work. */
|
|
10
|
+
export declare function createCaptureAdmission(options: CaptureAdmissionOptions): CaptureAdmission;
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import type { WotchiConfig, WotchiNotifier } from "./types.js";
|
|
1
|
+
import type { WotchiConfig, WotchiIncidentRule, WotchiLinkTemplates, WotchiNotifier } from "./types.js";
|
|
2
2
|
import { WotchiConfigurationError } from "./errors.js";
|
|
3
3
|
export { WotchiConfigurationError };
|
|
4
4
|
export interface NormalizedWotchiConfig {
|
|
5
5
|
readonly service: string;
|
|
6
6
|
readonly environment: string;
|
|
7
|
+
readonly instance?: string;
|
|
7
8
|
readonly release?: string;
|
|
8
9
|
readonly enabled: boolean;
|
|
10
|
+
readonly filter?: WotchiConfig["filter"];
|
|
11
|
+
readonly fingerprint?: WotchiConfig["fingerprint"];
|
|
12
|
+
readonly beforeSend?: WotchiConfig["beforeSend"];
|
|
13
|
+
readonly links?: Readonly<WotchiLinkTemplates>;
|
|
14
|
+
readonly rules: readonly WotchiIncidentRule[];
|
|
9
15
|
readonly grouping: {
|
|
10
16
|
readonly windowMs: number;
|
|
11
17
|
readonly alertThreshold: number;
|
|
@@ -16,6 +22,16 @@ export interface NormalizedWotchiConfig {
|
|
|
16
22
|
readonly queue: {
|
|
17
23
|
readonly maxPendingAlerts: number;
|
|
18
24
|
readonly concurrency: 1;
|
|
25
|
+
readonly notifierTimeoutMs: number;
|
|
26
|
+
readonly notifierCircuitBreaker: {
|
|
27
|
+
readonly failureThreshold: number;
|
|
28
|
+
readonly cooldownMs: number;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
readonly overload?: {
|
|
32
|
+
readonly maxEventsPerSecond: number;
|
|
33
|
+
readonly burst: number;
|
|
34
|
+
readonly alertCooldownMs: number;
|
|
19
35
|
};
|
|
20
36
|
readonly privacy: {
|
|
21
37
|
readonly redactKeys: readonly string[];
|
|
@@ -2,6 +2,12 @@ import type { WotchiDiagnostics } from "./types.js";
|
|
|
2
2
|
export interface DiagnosticsState {
|
|
3
3
|
capturedEvents: number;
|
|
4
4
|
captureFailures: number;
|
|
5
|
+
fingerprintCallbackFailures: number;
|
|
6
|
+
filterFailures: number;
|
|
7
|
+
beforeSendFailures: number;
|
|
8
|
+
eventsSuppressed: number;
|
|
9
|
+
eventsDroppedOverload: number;
|
|
10
|
+
capturesAfterShutdown: number;
|
|
5
11
|
}
|
|
6
12
|
export declare function createDiagnosticsState(): DiagnosticsState;
|
|
7
|
-
export declare function snapshotDiagnostics(state: DiagnosticsState, values: Omit<WotchiDiagnostics, "capturedEvents" | "captureFailures">): Readonly<WotchiDiagnostics>;
|
|
13
|
+
export declare function snapshotDiagnostics(state: DiagnosticsState, values: Omit<WotchiDiagnostics, "capturedEvents" | "captureFailures" | "fingerprintCallbackFailures" | "filterFailures" | "beforeSendFailures" | "eventsSuppressed" | "eventsDroppedOverload" | "capturesAfterShutdown">): Readonly<WotchiDiagnostics>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IncidentGroup, IncidentSeverity } from "./types.js";
|
|
2
|
-
export type IncidentEventKind = "error" | "manual" | "process-monitor";
|
|
2
|
+
export type IncidentEventKind = "error" | "manual" | "process-monitor" | "runtime-monitor";
|
|
3
3
|
export interface IncidentPolicyInput {
|
|
4
4
|
group: IncidentGroup;
|
|
5
5
|
now: number;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const MAX_GROUPS = 10000;
|
|
2
|
+
export declare const MAX_EVENTS_PER_WINDOW = 10000;
|
|
3
|
+
export declare const MAX_PENDING_ALERTS = 10000;
|
|
4
|
+
export declare const MAX_WINDOW_MS: number;
|
|
5
|
+
export declare const MAX_ALERT_THRESHOLD = 1000000;
|
|
6
|
+
export declare const MAX_COOLDOWN_MS: number;
|
|
7
|
+
export declare const MAX_CAPTURE_RATE = 1000000;
|
|
8
|
+
export declare const MAX_NOTIFIER_TIMEOUT_MS = 60000;
|
|
9
|
+
export declare const MAX_CIRCUIT_BREAKER_COOLDOWN_MS: number;
|
|
10
|
+
export declare const MAX_CIRCUIT_BREAKER_FAILURES = 100;
|
|
11
|
+
export declare const MAX_NORMALIZATION_DEPTH = 20;
|
|
12
|
+
export declare const MAX_NORMALIZATION_KEYS = 10000;
|
|
13
|
+
export declare const MAX_NORMALIZATION_STRING_LENGTH = 32768;
|
|
14
|
+
export declare const MAX_NORMALIZATION_STACK_LENGTH = 32768;
|
|
@@ -2,15 +2,28 @@ import type { IncidentAlert, WotchiNotifier } from "./types.js";
|
|
|
2
2
|
export interface NotificationQueueOptions {
|
|
3
3
|
maxPendingAlerts: number;
|
|
4
4
|
concurrency: 1;
|
|
5
|
+
notifierTimeoutMs?: number;
|
|
6
|
+
notifierCircuitBreaker?: {
|
|
7
|
+
failureThreshold: number;
|
|
8
|
+
cooldownMs: number;
|
|
9
|
+
};
|
|
5
10
|
onNotifierError?: (error: unknown, notifier: WotchiNotifier) => void;
|
|
6
11
|
}
|
|
12
|
+
export interface NotificationJobResult {
|
|
13
|
+
notifierFailures: number;
|
|
14
|
+
sent: number;
|
|
15
|
+
}
|
|
7
16
|
export interface NotificationQueue {
|
|
8
|
-
enqueue(alert: IncidentAlert, notifiers: readonly WotchiNotifier[]): boolean;
|
|
17
|
+
enqueue(alert: IncidentAlert, notifiers: readonly WotchiNotifier[], onComplete?: (result: NotificationJobResult) => void): boolean;
|
|
9
18
|
flush(timeoutMs?: number): Promise<void>;
|
|
19
|
+
close(timeoutMs?: number): Promise<void>;
|
|
20
|
+
isClosed(): boolean;
|
|
10
21
|
pending(): number;
|
|
11
22
|
alertsQueued(): number;
|
|
12
23
|
alertsDropped(): number;
|
|
13
24
|
alertsSent(): number;
|
|
14
25
|
notifierFailures(): number;
|
|
26
|
+
notifierTimeouts(): number;
|
|
27
|
+
notifierCircuitOpenSkips(): number;
|
|
15
28
|
}
|
|
16
29
|
export declare function createNotificationQueue(options: NotificationQueueOptions): NotificationQueue;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { WotchiClient } from "./types.js";
|
|
2
|
+
export declare const PROMETHEUS_CONTENT_TYPE = "text/plain; version=0.0.4; charset=utf-8";
|
|
3
|
+
export interface WotchiPrometheusExporter {
|
|
4
|
+
readonly contentType: typeof PROMETHEUS_CONTENT_TYPE;
|
|
5
|
+
render(): string;
|
|
6
|
+
}
|
|
7
|
+
export declare function createWotchiPrometheusExporter(client: Pick<WotchiClient, "getDiagnostics">): WotchiPrometheusExporter;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { WotchiClient } from "./types.js";
|
|
2
|
+
export interface WotchiRuntimeWatcherOptions {
|
|
3
|
+
intervalMs?: number;
|
|
4
|
+
cpuPercent?: number;
|
|
5
|
+
rssBytes?: number;
|
|
6
|
+
heapUsedBytes?: number;
|
|
7
|
+
eventLoopDelayMs?: number;
|
|
8
|
+
pendingAlerts?: number;
|
|
9
|
+
notifierFailures?: number;
|
|
10
|
+
alertThreshold?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface WotchiRuntimeWatcherHandle {
|
|
13
|
+
unregister(): void;
|
|
14
|
+
}
|
|
15
|
+
export declare function registerWotchiRuntimeWatcher(client: Pick<WotchiClient, "captureEvent" | "getDiagnostics">, options?: WotchiRuntimeWatcherOptions): WotchiRuntimeWatcherHandle;
|