@futurewindai/wotchi 0.1.0-beta.5 → 1.0.0-rc.1
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 +84 -29
- package/SECURITY.md +3 -3
- package/dist/cjs/core/admission.js +22 -0
- package/dist/cjs/core/client.js +46 -0
- package/dist/cjs/core/config.js +16 -0
- package/dist/cjs/core/diagnostics.js +4 -0
- package/dist/cjs/core/group-store.js +7 -8
- package/dist/cjs/core/limits.js +5 -1
- package/dist/cjs/core/normalize.js +6 -1
- package/dist/cjs/core/notification-queue.js +77 -8
- package/dist/cjs/core/prometheus.js +129 -0
- package/dist/cjs/core/redact.js +4 -1
- package/dist/cjs/core/runtime-monitor.js +109 -0
- package/dist/cjs/index.js +6 -1
- package/dist/cjs/integrations/express/error-handler.js +24 -6
- package/dist/cjs/integrations/express/state.js +7 -20
- package/dist/cjs/integrations/express/status-observer.js +3 -9
- package/dist/cjs/integrations/nest/capture.js +21 -0
- package/dist/cjs/integrations/nest/exception-filter.js +64 -15
- package/dist/cjs/integrations/nest/filter-wrapper.js +19 -0
- package/dist/cjs/integrations/nest/index.js +6 -1
- package/dist/cjs/integrations/nest/module.js +44 -0
- package/dist/cjs/integrations/nest/register.js +17 -1
- package/dist/cjs/integrations/request-context.js +15 -23
- package/dist/esm/core/admission.js +19 -0
- package/dist/esm/core/client.js +46 -0
- package/dist/esm/core/config.js +17 -1
- package/dist/esm/core/diagnostics.js +4 -0
- package/dist/esm/core/group-store.js +7 -8
- package/dist/esm/core/limits.js +4 -0
- package/dist/esm/core/normalize.js +6 -1
- package/dist/esm/core/notification-queue.js +78 -9
- package/dist/esm/core/prometheus.js +125 -0
- package/dist/esm/core/redact.js +4 -1
- package/dist/esm/core/runtime-monitor.js +106 -0
- package/dist/esm/index.js +3 -1
- package/dist/esm/integrations/express/error-handler.js +23 -5
- package/dist/esm/integrations/express/state.js +7 -20
- package/dist/esm/integrations/express/status-observer.js +3 -9
- package/dist/esm/integrations/nest/capture.js +17 -0
- package/dist/esm/integrations/nest/exception-filter.js +65 -16
- package/dist/esm/integrations/nest/filter-wrapper.js +16 -0
- package/dist/esm/integrations/nest/index.js +2 -0
- package/dist/esm/integrations/nest/module.js +41 -0
- package/dist/esm/integrations/nest/register.js +17 -1
- package/dist/esm/integrations/request-context.js +14 -23
- package/dist/types/core/admission.d.ts +10 -0
- package/dist/types/core/config.d.ts +10 -0
- package/dist/types/core/diagnostics.d.ts +3 -1
- package/dist/types/core/incident-policy.d.ts +1 -1
- package/dist/types/core/limits.d.ts +4 -0
- package/dist/types/core/notification-queue.d.ts +9 -0
- 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 +16 -1
- package/dist/types/index.d.ts +5 -1
- package/dist/types/integrations/express/status-observer.d.ts +1 -1
- package/dist/types/integrations/nest/capture.d.ts +4 -0
- package/dist/types/integrations/nest/exception-filter.d.ts +7 -3
- package/dist/types/integrations/nest/filter-wrapper.d.ts +7 -0
- package/dist/types/integrations/nest/index.d.ts +4 -0
- 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 +1 -0
- package/dist/types-cjs/core/admission.d.cts +10 -0
- package/dist/types-cjs/core/client.d.cts +1 -1
- package/dist/types-cjs/core/config.d.cts +12 -2
- package/dist/types-cjs/core/diagnostics.d.cts +4 -2
- package/dist/types-cjs/core/fingerprint.d.cts +1 -1
- package/dist/types-cjs/core/group-store.d.cts +1 -1
- package/dist/types-cjs/core/incident-builder.d.cts +2 -2
- package/dist/types-cjs/core/incident-policy.d.cts +2 -2
- package/dist/types-cjs/core/limits.d.cts +4 -0
- package/dist/types-cjs/core/notification-queue.d.cts +10 -1
- package/dist/types-cjs/core/process-monitor.d.cts +1 -1
- package/dist/types-cjs/core/prometheus.d.cts +7 -0
- package/dist/types-cjs/core/redact.d.cts +1 -1
- package/dist/types-cjs/core/runtime-monitor.d.cts +15 -0
- package/dist/types-cjs/core/types.d.cts +16 -1
- package/dist/types-cjs/index.d.cts +15 -11
- package/dist/types-cjs/integrations/express/error-handler.d.cts +2 -2
- package/dist/types-cjs/integrations/express/index.d.cts +8 -8
- package/dist/types-cjs/integrations/express/request-context.d.cts +2 -2
- package/dist/types-cjs/integrations/express/status-observer.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 +8 -4
- package/dist/types-cjs/integrations/nest/filter-wrapper.d.cts +7 -0
- package/dist/types-cjs/integrations/nest/index.d.cts +9 -5
- package/dist/types-cjs/integrations/nest/module.d.cts +9 -0
- package/dist/types-cjs/integrations/nest/register.d.cts +7 -4
- package/dist/types-cjs/integrations/nest/request-context.d.cts +2 -2
- package/dist/types-cjs/integrations/request-context.d.cts +2 -1
- package/dist/types-cjs/notifiers/alert-payload.d.cts +2 -2
- package/dist/types-cjs/notifiers/console.d.cts +1 -1
- package/dist/types-cjs/notifiers/telegram-format.d.cts +1 -1
- package/dist/types-cjs/notifiers/telegram.d.cts +2 -2
- package/dist/types-cjs/notifiers/webhook-http.d.cts +1 -1
- package/dist/types-cjs/notifiers/webhook.d.cts +2 -2
- package/package.json +23 -12
package/dist/types/index.d.ts
CHANGED
|
@@ -1,11 +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";
|
|
5
7
|
import { webhookNotifier } from "./notifiers/webhook.js";
|
|
6
8
|
export { WotchiConfigurationError } from "./core/errors.js";
|
|
7
9
|
export type { ProcessMonitorHandle } from "./core/process-monitor.js";
|
|
8
10
|
export type { NormalizedWotchiConfig } from "./core/config.js";
|
|
11
|
+
export type { WotchiPrometheusExporter } from "./core/prometheus.js";
|
|
12
|
+
export type { WotchiRuntimeWatcherHandle, WotchiRuntimeWatcherOptions, } from "./core/runtime-monitor.js";
|
|
9
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";
|
|
10
14
|
export type { WebhookRequestFunction, WebhookRequestOptions, WebhookResponse, } from "./notifiers/webhook-http.js";
|
|
11
|
-
export { consoleNotifier, createWotchi, registerWotchiProcessMonitor, telegramNotifier, webhookNotifier, };
|
|
15
|
+
export { consoleNotifier, createWotchi, createWotchiPrometheusExporter, PROMETHEUS_CONTENT_TYPE, registerWotchiProcessMonitor, registerWotchiRuntimeWatcher, telegramNotifier, webhookNotifier, };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RequestHandler } from "express";
|
|
2
2
|
import type { WotchiClient } from "../../core/types.js";
|
|
3
|
-
import type
|
|
3
|
+
import { type RequestContextOptions } from "../request-context.js";
|
|
4
4
|
export type WotchiStatusClass = "4xx" | "5xx";
|
|
5
5
|
export interface WotchiStatusObserverOptions extends RequestContextOptions {
|
|
6
6
|
statusCodes?: readonly number[];
|
|
@@ -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
|
-
private readonly
|
|
8
|
-
|
|
8
|
+
private readonly previousGlobalFilters;
|
|
9
|
+
private readonly options;
|
|
10
|
+
constructor(client: WotchiClient, applicationRef?: HttpServer, options?: NestWotchiOptions, 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
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
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;
|
|
@@ -5,6 +5,7 @@ export interface RequestContextOptions {
|
|
|
5
5
|
traceContextProperty?: string;
|
|
6
6
|
}
|
|
7
7
|
export declare function normalizeRoutePath(value: unknown): string | undefined;
|
|
8
|
+
export declare function normalizeRequestContextOptions(options?: RequestContextOptions): Readonly<RequestContextOptions>;
|
|
8
9
|
export interface RequestContextInput {
|
|
9
10
|
request?: unknown;
|
|
10
11
|
method?: unknown;
|
|
@@ -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,2 +1,2 @@
|
|
|
1
|
-
import type { WotchiClient, WotchiConfig } from "./types.
|
|
1
|
+
import type { WotchiClient, WotchiConfig } from "./types.cjs";
|
|
2
2
|
export declare function createWotchi(config: WotchiConfig): WotchiClient;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { WotchiConfig, WotchiIncidentRule, WotchiLinkTemplates, WotchiNotifier } from "./types.
|
|
2
|
-
import { WotchiConfigurationError } from "./errors.
|
|
1
|
+
import type { WotchiConfig, WotchiIncidentRule, WotchiLinkTemplates, WotchiNotifier } from "./types.cjs";
|
|
2
|
+
import { WotchiConfigurationError } from "./errors.cjs";
|
|
3
3
|
export { WotchiConfigurationError };
|
|
4
4
|
export interface NormalizedWotchiConfig {
|
|
5
5
|
readonly service: string;
|
|
@@ -22,6 +22,16 @@ export interface NormalizedWotchiConfig {
|
|
|
22
22
|
readonly queue: {
|
|
23
23
|
readonly maxPendingAlerts: number;
|
|
24
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;
|
|
25
35
|
};
|
|
26
36
|
readonly privacy: {
|
|
27
37
|
readonly redactKeys: readonly string[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { WotchiDiagnostics } from "./types.
|
|
1
|
+
import type { WotchiDiagnostics } from "./types.cjs";
|
|
2
2
|
export interface DiagnosticsState {
|
|
3
3
|
capturedEvents: number;
|
|
4
4
|
captureFailures: number;
|
|
@@ -6,6 +6,8 @@ export interface DiagnosticsState {
|
|
|
6
6
|
filterFailures: number;
|
|
7
7
|
beforeSendFailures: number;
|
|
8
8
|
eventsSuppressed: number;
|
|
9
|
+
eventsDroppedOverload: number;
|
|
10
|
+
capturesAfterShutdown: number;
|
|
9
11
|
}
|
|
10
12
|
export declare function createDiagnosticsState(): DiagnosticsState;
|
|
11
|
-
export declare function snapshotDiagnostics(state: DiagnosticsState, values: Omit<WotchiDiagnostics, "capturedEvents" | "captureFailures" | "fingerprintCallbackFailures" | "filterFailures" | "beforeSendFailures" | "eventsSuppressed">): Readonly<WotchiDiagnostics>;
|
|
13
|
+
export declare function snapshotDiagnostics(state: DiagnosticsState, values: Omit<WotchiDiagnostics, "capturedEvents" | "captureFailures" | "fingerprintCallbackFailures" | "filterFailures" | "beforeSendFailures" | "eventsSuppressed" | "eventsDroppedOverload" | "capturesAfterShutdown">): Readonly<WotchiDiagnostics>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { IncidentAlert, IncidentGroup } from "./types.
|
|
2
|
-
import type { IncidentPolicyDecision } from "./incident-policy.
|
|
1
|
+
import type { IncidentAlert, IncidentGroup } from "./types.cjs";
|
|
2
|
+
import type { IncidentPolicyDecision } from "./incident-policy.cjs";
|
|
3
3
|
export declare function buildIncidentAlert(group: IncidentGroup, decision: IncidentPolicyDecision): IncidentAlert;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { IncidentGroup, IncidentSeverity } from "./types.
|
|
2
|
-
export type IncidentEventKind = "error" | "manual" | "process-monitor";
|
|
1
|
+
import type { IncidentGroup, IncidentSeverity } from "./types.cjs";
|
|
2
|
+
export type IncidentEventKind = "error" | "manual" | "process-monitor" | "runtime-monitor";
|
|
3
3
|
export interface IncidentPolicyInput {
|
|
4
4
|
group: IncidentGroup;
|
|
5
5
|
now: number;
|
|
@@ -4,6 +4,10 @@ export declare const MAX_PENDING_ALERTS = 10000;
|
|
|
4
4
|
export declare const MAX_WINDOW_MS: number;
|
|
5
5
|
export declare const MAX_ALERT_THRESHOLD = 1000000;
|
|
6
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;
|
|
7
11
|
export declare const MAX_NORMALIZATION_DEPTH = 20;
|
|
8
12
|
export declare const MAX_NORMALIZATION_KEYS = 10000;
|
|
9
13
|
export declare const MAX_NORMALIZATION_STRING_LENGTH = 32768;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import type { IncidentAlert, WotchiNotifier } from "./types.
|
|
1
|
+
import type { IncidentAlert, WotchiNotifier } from "./types.cjs";
|
|
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
|
}
|
|
7
12
|
export interface NotificationJobResult {
|
|
@@ -11,10 +16,14 @@ export interface NotificationJobResult {
|
|
|
11
16
|
export interface NotificationQueue {
|
|
12
17
|
enqueue(alert: IncidentAlert, notifiers: readonly WotchiNotifier[], onComplete?: (result: NotificationJobResult) => void): boolean;
|
|
13
18
|
flush(timeoutMs?: number): Promise<void>;
|
|
19
|
+
close(timeoutMs?: number): Promise<void>;
|
|
20
|
+
isClosed(): boolean;
|
|
14
21
|
pending(): number;
|
|
15
22
|
alertsQueued(): number;
|
|
16
23
|
alertsDropped(): number;
|
|
17
24
|
alertsSent(): number;
|
|
18
25
|
notifierFailures(): number;
|
|
26
|
+
notifierTimeouts(): number;
|
|
27
|
+
notifierCircuitOpenSkips(): number;
|
|
19
28
|
}
|
|
20
29
|
export declare function createNotificationQueue(options: NotificationQueueOptions): NotificationQueue;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { WotchiClient } from "./types.cjs";
|
|
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;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NormalizedError, SafeNormalizedValue } from "./normalize.
|
|
1
|
+
import type { NormalizedError, SafeNormalizedValue } from "./normalize.cjs";
|
|
2
2
|
export declare const REDACTED = "[REDACTED]";
|
|
3
3
|
export interface RedactionOptions {
|
|
4
4
|
redactKeys?: readonly string[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { WotchiClient } from "./types.cjs";
|
|
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;
|
|
@@ -1,5 +1,5 @@
|
|
|
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
3
|
export interface WotchiTraceContext {
|
|
4
4
|
traceId?: string;
|
|
5
5
|
spanId?: string;
|
|
@@ -160,6 +160,16 @@ export interface WotchiConfig {
|
|
|
160
160
|
queue?: {
|
|
161
161
|
maxPendingAlerts?: number;
|
|
162
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;
|
|
163
173
|
};
|
|
164
174
|
privacy?: {
|
|
165
175
|
redactKeys?: string[];
|
|
@@ -182,8 +192,12 @@ export interface WotchiDiagnostics {
|
|
|
182
192
|
filterFailures: number;
|
|
183
193
|
beforeSendFailures: number;
|
|
184
194
|
eventsSuppressed: number;
|
|
195
|
+
eventsDroppedOverload: number;
|
|
196
|
+
capturesAfterShutdown: number;
|
|
185
197
|
activeGroups: number;
|
|
186
198
|
pendingAlerts: number;
|
|
199
|
+
notifierTimeouts: number;
|
|
200
|
+
notifierCircuitOpenSkips: number;
|
|
187
201
|
}
|
|
188
202
|
export type WotchiTestAlertStatus = "sent" | "queue-full" | "timeout" | "notifier-failed";
|
|
189
203
|
export interface WotchiTestAlertResult {
|
|
@@ -201,5 +215,6 @@ export interface WotchiClient {
|
|
|
201
215
|
captureEvent(event: WotchiEventInput): void;
|
|
202
216
|
testAlert(): Promise<WotchiTestAlertResult>;
|
|
203
217
|
flush(timeoutMs?: number): Promise<void>;
|
|
218
|
+
shutdown(timeoutMs?: number): Promise<void>;
|
|
204
219
|
getDiagnostics(): Readonly<WotchiDiagnostics>;
|
|
205
220
|
}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { createWotchi } from "./core/client.
|
|
2
|
-
import { registerWotchiProcessMonitor } from "./core/process-monitor.
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export
|
|
9
|
-
export type {
|
|
10
|
-
export type {
|
|
11
|
-
export {
|
|
1
|
+
import { createWotchi } from "./core/client.cjs";
|
|
2
|
+
import { registerWotchiProcessMonitor } from "./core/process-monitor.cjs";
|
|
3
|
+
import { createWotchiPrometheusExporter, PROMETHEUS_CONTENT_TYPE } from "./core/prometheus.cjs";
|
|
4
|
+
import { registerWotchiRuntimeWatcher } from "./core/runtime-monitor.cjs";
|
|
5
|
+
import { consoleNotifier } from "./notifiers/console.cjs";
|
|
6
|
+
import { telegramNotifier } from "./notifiers/telegram.cjs";
|
|
7
|
+
import { webhookNotifier } from "./notifiers/webhook.cjs";
|
|
8
|
+
export { WotchiConfigurationError } from "./core/errors.cjs";
|
|
9
|
+
export type { ProcessMonitorHandle } from "./core/process-monitor.cjs";
|
|
10
|
+
export type { NormalizedWotchiConfig } from "./core/config.cjs";
|
|
11
|
+
export type { WotchiPrometheusExporter } from "./core/prometheus.cjs";
|
|
12
|
+
export type { WotchiRuntimeWatcherHandle, WotchiRuntimeWatcherOptions, } from "./core/runtime-monitor.cjs";
|
|
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.cjs";
|
|
14
|
+
export type { WebhookRequestFunction, WebhookRequestOptions, WebhookResponse, } from "./notifiers/webhook-http.cjs";
|
|
15
|
+
export { consoleNotifier, createWotchi, createWotchiPrometheusExporter, PROMETHEUS_CONTENT_TYPE, registerWotchiProcessMonitor, registerWotchiRuntimeWatcher, telegramNotifier, webhookNotifier, };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ErrorRequestHandler } from "express";
|
|
2
|
-
import type { WotchiClient } from "../../core/types.
|
|
3
|
-
import { type ExpressWotchiOptions } from "./request-context.
|
|
2
|
+
import type { WotchiClient } from "../../core/types.cjs";
|
|
3
|
+
import { type ExpressWotchiOptions } from "./request-context.cjs";
|
|
4
4
|
export declare function createExpressErrorHandler(client: WotchiClient, options?: ExpressWotchiOptions): ErrorRequestHandler;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { WotchiClient } from "../../core/types.
|
|
2
|
-
import { createExpressErrorHandler } from "./error-handler.
|
|
3
|
-
import type { ExpressWotchiOptions } from "./request-context.
|
|
4
|
-
export { consoleNotifier, createWotchi, telegramNotifier, webhookNotifier } from "../../index.
|
|
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.
|
|
6
|
-
export type { ExpressWotchiOptions } from "./request-context.
|
|
7
|
-
export type { WotchiStatusClass, WotchiStatusObserverOptions } from "./status-observer.
|
|
8
|
-
export { wotchiStatusObserver } from "./status-observer.
|
|
1
|
+
import type { WotchiClient } from "../../core/types.cjs";
|
|
2
|
+
import { createExpressErrorHandler } from "./error-handler.cjs";
|
|
3
|
+
import type { ExpressWotchiOptions } from "./request-context.cjs";
|
|
4
|
+
export { consoleNotifier, createWotchi, telegramNotifier, webhookNotifier } from "../../index.cjs";
|
|
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.cjs";
|
|
6
|
+
export type { ExpressWotchiOptions } from "./request-context.cjs";
|
|
7
|
+
export type { WotchiStatusClass, WotchiStatusObserverOptions } from "./status-observer.cjs";
|
|
8
|
+
export { wotchiStatusObserver } from "./status-observer.cjs";
|
|
9
9
|
export declare function wotchiErrorHandler(client: WotchiClient, options?: ExpressWotchiOptions): ReturnType<typeof createExpressErrorHandler>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Request, Response } from "express";
|
|
2
|
-
import { type RequestContextOptions } from "../request-context.
|
|
3
|
-
import type { WotchiRequestContext } from "../../core/types.
|
|
2
|
+
import { type RequestContextOptions } from "../request-context.cjs";
|
|
3
|
+
import type { WotchiRequestContext } from "../../core/types.cjs";
|
|
4
4
|
export type ExpressWotchiOptions = RequestContextOptions;
|
|
5
5
|
export declare function getExpressRequestContext(request: Request, response: Response, options?: ExpressWotchiOptions): WotchiRequestContext | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RequestHandler } from "express";
|
|
2
|
-
import type { WotchiClient } from "../../core/types.
|
|
3
|
-
import type
|
|
2
|
+
import type { WotchiClient } from "../../core/types.cjs";
|
|
3
|
+
import { type RequestContextOptions } from "../request-context.cjs";
|
|
4
4
|
export type WotchiStatusClass = "4xx" | "5xx";
|
|
5
5
|
export interface WotchiStatusObserverOptions extends RequestContextOptions {
|
|
6
6
|
statusCodes?: readonly number[];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ArgumentsHost } from "@nestjs/common";
|
|
2
|
+
import type { WotchiClient } from "../../core/types.cjs";
|
|
3
|
+
import { type NestWotchiOptions } from "./request-context.cjs";
|
|
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
|
-
import type { WotchiClient } from "../../core/types.
|
|
4
|
-
import {
|
|
3
|
+
import type { WotchiClient } from "../../core/types.cjs";
|
|
4
|
+
import type { NestExceptionFilterLike } from "./filter-wrapper.cjs";
|
|
5
|
+
import type { NestWotchiOptions } from "./request-context.cjs";
|
|
5
6
|
export declare class WotchiNestExceptionFilter extends BaseExceptionFilter<unknown> {
|
|
6
7
|
private readonly client;
|
|
7
|
-
private readonly
|
|
8
|
-
|
|
8
|
+
private readonly previousGlobalFilters;
|
|
9
|
+
private readonly options;
|
|
10
|
+
constructor(client: WotchiClient, applicationRef?: HttpServer, options?: NestWotchiOptions, 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.cjs";
|
|
3
|
+
import type { NestWotchiOptions } from "./request-context.cjs";
|
|
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, webhookNotifier } from "../../index.
|
|
2
|
-
export {
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export type {
|
|
1
|
+
export { consoleNotifier, createWotchi, telegramNotifier, webhookNotifier } from "../../index.cjs";
|
|
2
|
+
export { withWotchiNestFilter } from "./filter-wrapper.cjs";
|
|
3
|
+
export { WotchiModule, WOTCHI_CLIENT } from "./module.cjs";
|
|
4
|
+
export { registerWotchiNest, registerWotchiNestStatusObserver } from "./register.cjs";
|
|
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.cjs";
|
|
6
|
+
export type { NestWotchiApplication, NestWotchiOptions } from "./register.cjs";
|
|
7
|
+
export type { NestExceptionFilterLike } from "./filter-wrapper.cjs";
|
|
8
|
+
export type { WotchiNestModuleOptions } from "./module.cjs";
|
|
9
|
+
export type { WotchiStatusClass, WotchiStatusObserverOptions } from "../express/status-observer.cjs";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type DynamicModule } from "@nestjs/common";
|
|
2
|
+
import type { WotchiConfig } from "../../core/types.cjs";
|
|
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
|
+
}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { HttpAdapterHost } from "@nestjs/core";
|
|
2
|
-
import type { WotchiClient } from "../../core/types.
|
|
3
|
-
import type { NestWotchiOptions } from "./request-context.
|
|
4
|
-
import type { WotchiStatusObserverOptions } from "../express/status-observer.
|
|
5
|
-
export type { NestWotchiOptions } from "./request-context.
|
|
2
|
+
import type { WotchiClient } from "../../core/types.cjs";
|
|
3
|
+
import type { NestWotchiOptions } from "./request-context.cjs";
|
|
4
|
+
import type { WotchiStatusObserverOptions } from "../express/status-observer.cjs";
|
|
5
|
+
export type { NestWotchiOptions } from "./request-context.cjs";
|
|
6
6
|
export interface NestWotchiApplication {
|
|
7
7
|
get(token: typeof HttpAdapterHost): InstanceType<typeof HttpAdapterHost>;
|
|
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,5 +1,5 @@
|
|
|
1
1
|
import type { ArgumentsHost } from "@nestjs/common";
|
|
2
|
-
import { type RequestContextOptions } from "../request-context.
|
|
3
|
-
import type { WotchiRequestContext } from "../../core/types.
|
|
2
|
+
import { type RequestContextOptions } from "../request-context.cjs";
|
|
3
|
+
import type { WotchiRequestContext } from "../../core/types.cjs";
|
|
4
4
|
export type NestWotchiOptions = RequestContextOptions;
|
|
5
5
|
export declare function getNestRequestContext(host: ArgumentsHost, exception: unknown, options?: NestWotchiOptions): WotchiRequestContext | undefined;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type { WotchiRequestContext } from "../core/types.
|
|
1
|
+
import type { WotchiRequestContext } from "../core/types.cjs";
|
|
2
2
|
export interface RequestContextOptions {
|
|
3
3
|
requestIdProperty?: string;
|
|
4
4
|
correlationIdProperty?: string;
|
|
5
5
|
traceContextProperty?: string;
|
|
6
6
|
}
|
|
7
7
|
export declare function normalizeRoutePath(value: unknown): string | undefined;
|
|
8
|
+
export declare function normalizeRequestContextOptions(options?: RequestContextOptions): Readonly<RequestContextOptions>;
|
|
8
9
|
export interface RequestContextInput {
|
|
9
10
|
request?: unknown;
|
|
10
11
|
method?: unknown;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { SafeNormalizedValue } from "../core/normalize.
|
|
2
|
-
import type { IncidentAlert } from "../core/types.
|
|
1
|
+
import type { SafeNormalizedValue } from "../core/normalize.cjs";
|
|
2
|
+
import type { IncidentAlert } from "../core/types.cjs";
|
|
3
3
|
export type BoundedAlertPayload = Record<string, SafeNormalizedValue>;
|
|
4
4
|
export declare function toBoundedPayload(value: unknown): BoundedAlertPayload;
|
|
5
5
|
export declare function toBoundedAlertPayload(alert: IncidentAlert): BoundedAlertPayload;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { ConsoleNotifierOptions, IncidentAlert, WotchiNotifier } from "../core/types.
|
|
1
|
+
import type { ConsoleNotifierOptions, IncidentAlert, WotchiNotifier } from "../core/types.cjs";
|
|
2
2
|
export declare function formatConsoleAlert(alert: IncidentAlert, format?: "text" | "json"): string;
|
|
3
3
|
export declare function consoleNotifier(options?: ConsoleNotifierOptions): WotchiNotifier;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { IncidentAlert } from "../core/types.
|
|
1
|
+
import type { IncidentAlert } from "../core/types.cjs";
|
|
2
2
|
export declare function formatTelegramAlert(alert: IncidentAlert): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TelegramNotifierOptions, WotchiNotifier } from "../core/types.
|
|
2
|
-
import { type TelegramRequestFunction } from "./telegram-http.
|
|
1
|
+
import type { TelegramNotifierOptions, WotchiNotifier } from "../core/types.cjs";
|
|
2
|
+
import { type TelegramRequestFunction } from "./telegram-http.cjs";
|
|
3
3
|
export declare function createTelegramNotifier(options: TelegramNotifierOptions, request?: TelegramRequestFunction): WotchiNotifier;
|
|
4
4
|
export declare function telegramNotifier(options: TelegramNotifierOptions): WotchiNotifier;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { WebhookNotifierOptions, WotchiNotifier } from "../core/types.
|
|
2
|
-
import { type WebhookRequestFunction } from "./webhook-http.
|
|
1
|
+
import type { WebhookNotifierOptions, WotchiNotifier } from "../core/types.cjs";
|
|
2
|
+
import { type WebhookRequestFunction } from "./webhook-http.cjs";
|
|
3
3
|
export declare function createWebhookNotifier(options: WebhookNotifierOptions, request?: WebhookRequestFunction): WotchiNotifier;
|
|
4
4
|
export declare function webhookNotifier(options: WebhookNotifierOptions): WotchiNotifier;
|