@takentrade/takentrade-libs 4.1.1 → 4.1.2
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 +6 -57
- package/dist/auth/guards/index.d.ts +1 -0
- package/dist/auth/guards/index.js +1 -0
- package/dist/auth/guards/tnt-base-auth.guard.d.ts +15 -0
- package/dist/auth/guards/tnt-base-auth.guard.js +54 -0
- package/dist/bullmq/config/bull.config.js +1 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +15 -21
- package/dist/metrics/circuit-breaker-metrics.service.d.ts +0 -61
- package/dist/metrics/circuit-breaker-metrics.service.js +0 -149
- package/dist/metrics/index.d.ts +0 -5
- package/dist/metrics/index.js +0 -21
- package/dist/metrics/metrics-registry.d.ts +0 -50
- package/dist/metrics/metrics-registry.js +0 -156
- package/dist/metrics/metrics-updater.d.ts +0 -32
- package/dist/metrics/metrics-updater.js +0 -102
- package/dist/metrics/metrics.controller.d.ts +0 -11
- package/dist/metrics/metrics.controller.js +0 -32
- package/dist/metrics/metrics.interface.d.ts +0 -53
- package/dist/metrics/metrics.interface.js +0 -23
- package/dist/metrics/metrics.module.d.ts +0 -11
- package/dist/metrics/metrics.module.js +0 -39
- package/dist/metrics/metrics.service.d.ts +0 -50
- package/dist/metrics/metrics.service.js +0 -165
- package/dist/monitoring/alerting.service.d.ts +0 -82
- package/dist/monitoring/alerting.service.js +0 -290
- package/dist/monitoring/index.d.ts +0 -5
- package/dist/monitoring/index.js +0 -21
- package/dist/monitoring/monitoring.interface.d.ts +0 -102
- package/dist/monitoring/monitoring.interface.js +0 -10
- package/dist/monitoring/monitoring.module.d.ts +0 -8
- package/dist/monitoring/monitoring.module.js +0 -44
- package/dist/monitoring/sentry.service.d.ts +0 -65
- package/dist/monitoring/sentry.service.js +0 -218
- package/dist/monitoring/uptime.service.d.ts +0 -59
- package/dist/monitoring/uptime.service.js +0 -213
- package/dist/resilience/circuit-breaker-event-handler.d.ts +0 -16
- package/dist/resilience/circuit-breaker-event-handler.js +0 -70
- package/dist/resilience/circuit-breaker-factory.d.ts +0 -19
- package/dist/resilience/circuit-breaker-factory.js +0 -51
- package/dist/resilience/circuit-breaker-stats.service.d.ts +0 -37
- package/dist/resilience/circuit-breaker-stats.service.js +0 -69
- package/dist/resilience/circuit-breaker.interface.d.ts +0 -59
- package/dist/resilience/circuit-breaker.interface.js +0 -25
- package/dist/resilience/circuit-breaker.module.d.ts +0 -2
- package/dist/resilience/circuit-breaker.module.js +0 -21
- package/dist/resilience/circuit-breaker.service.d.ts +0 -119
- package/dist/resilience/circuit-breaker.service.js +0 -234
- package/dist/resilience/index.d.ts +0 -3
- package/dist/resilience/index.js +0 -19
|
@@ -1,32 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.MetricsController = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
let MetricsController = class MetricsController {
|
|
12
|
-
metricsService;
|
|
13
|
-
constructor(metricsService) {
|
|
14
|
-
this.metricsService = metricsService;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Get all metrics in Prometheus format
|
|
18
|
-
*
|
|
19
|
-
* @returns Metrics in Prometheus exposition format
|
|
20
|
-
*/
|
|
21
|
-
async getMetrics() {
|
|
22
|
-
return this.metricsService.getMetrics();
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
exports.MetricsController = MetricsController;
|
|
26
|
-
__decorate([
|
|
27
|
-
(0, common_1.Get)(),
|
|
28
|
-
(0, common_1.Header)('Content-Type', 'text/plain; version=0.0.4; charset=utf-8')
|
|
29
|
-
], MetricsController.prototype, "getMetrics", null);
|
|
30
|
-
exports.MetricsController = MetricsController = __decorate([
|
|
31
|
-
(0, common_1.Controller)('metrics')
|
|
32
|
-
], MetricsController);
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { Counter, Gauge, Histogram, Summary, CounterConfiguration, GaugeConfiguration, HistogramConfiguration, SummaryConfiguration } from 'prom-client';
|
|
2
|
-
export declare enum MetricType {
|
|
3
|
-
COUNTER = "counter",
|
|
4
|
-
GAUGE = "gauge",
|
|
5
|
-
HISTOGRAM = "histogram",
|
|
6
|
-
SUMMARY = "summary"
|
|
7
|
-
}
|
|
8
|
-
export interface MetricsModuleOptions {
|
|
9
|
-
defaultMetrics?: boolean;
|
|
10
|
-
prefix?: string;
|
|
11
|
-
defaultLabels?: Record<string, string>;
|
|
12
|
-
defaultMetricsInterval?: number;
|
|
13
|
-
circuitBreakerMetrics?: boolean;
|
|
14
|
-
}
|
|
15
|
-
export interface CounterConfig extends Omit<CounterConfiguration<string>, 'registers'> {
|
|
16
|
-
name: string;
|
|
17
|
-
help: string;
|
|
18
|
-
labelNames?: string[];
|
|
19
|
-
}
|
|
20
|
-
export interface GaugeConfig extends Omit<GaugeConfiguration<string>, 'registers'> {
|
|
21
|
-
name: string;
|
|
22
|
-
help: string;
|
|
23
|
-
labelNames?: string[];
|
|
24
|
-
}
|
|
25
|
-
export interface HistogramConfig extends Omit<HistogramConfiguration<string>, 'registers'> {
|
|
26
|
-
name: string;
|
|
27
|
-
help: string;
|
|
28
|
-
labelNames?: string[];
|
|
29
|
-
buckets?: number[];
|
|
30
|
-
}
|
|
31
|
-
export interface SummaryConfig extends Omit<SummaryConfiguration<string>, 'registers'> {
|
|
32
|
-
name: string;
|
|
33
|
-
help: string;
|
|
34
|
-
labelNames?: string[];
|
|
35
|
-
percentiles?: number[];
|
|
36
|
-
}
|
|
37
|
-
export type MetricInstance = Counter<string> | Gauge<string> | Histogram<string> | Summary<string>;
|
|
38
|
-
export interface MetricEntry {
|
|
39
|
-
type: MetricType;
|
|
40
|
-
metric: MetricInstance;
|
|
41
|
-
config: CounterConfig | GaugeConfig | HistogramConfig | SummaryConfig;
|
|
42
|
-
}
|
|
43
|
-
export declare const CIRCUIT_BREAKER_METRICS: {
|
|
44
|
-
readonly STATE: "circuit_breaker_state";
|
|
45
|
-
readonly CALLS_TOTAL: "circuit_breaker_calls_total";
|
|
46
|
-
readonly LATENCY_SECONDS: "circuit_breaker_latency_seconds";
|
|
47
|
-
readonly FAILURES_TOTAL: "circuit_breaker_failures_total";
|
|
48
|
-
readonly SUCCESSES_TOTAL: "circuit_breaker_successes_total";
|
|
49
|
-
readonly REJECTS_TOTAL: "circuit_breaker_rejects_total";
|
|
50
|
-
readonly TIMEOUTS_TOTAL: "circuit_breaker_timeouts_total";
|
|
51
|
-
};
|
|
52
|
-
export declare const DEFAULT_LATENCY_BUCKETS: number[];
|
|
53
|
-
export declare const DEFAULT_PERCENTILES: number[];
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_PERCENTILES = exports.DEFAULT_LATENCY_BUCKETS = exports.CIRCUIT_BREAKER_METRICS = exports.MetricType = void 0;
|
|
4
|
-
var MetricType;
|
|
5
|
-
(function (MetricType) {
|
|
6
|
-
MetricType["COUNTER"] = "counter";
|
|
7
|
-
MetricType["GAUGE"] = "gauge";
|
|
8
|
-
MetricType["HISTOGRAM"] = "histogram";
|
|
9
|
-
MetricType["SUMMARY"] = "summary";
|
|
10
|
-
})(MetricType || (exports.MetricType = MetricType = {}));
|
|
11
|
-
exports.CIRCUIT_BREAKER_METRICS = {
|
|
12
|
-
STATE: 'circuit_breaker_state',
|
|
13
|
-
CALLS_TOTAL: 'circuit_breaker_calls_total',
|
|
14
|
-
LATENCY_SECONDS: 'circuit_breaker_latency_seconds',
|
|
15
|
-
FAILURES_TOTAL: 'circuit_breaker_failures_total',
|
|
16
|
-
SUCCESSES_TOTAL: 'circuit_breaker_successes_total',
|
|
17
|
-
REJECTS_TOTAL: 'circuit_breaker_rejects_total',
|
|
18
|
-
TIMEOUTS_TOTAL: 'circuit_breaker_timeouts_total',
|
|
19
|
-
};
|
|
20
|
-
exports.DEFAULT_LATENCY_BUCKETS = [
|
|
21
|
-
0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10,
|
|
22
|
-
];
|
|
23
|
-
exports.DEFAULT_PERCENTILES = [0.5, 0.9, 0.95, 0.99];
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { DynamicModule } from '@nestjs/common';
|
|
2
|
-
import { MetricsModuleOptions } from './metrics.interface';
|
|
3
|
-
export declare class MetricsModule {
|
|
4
|
-
/**
|
|
5
|
-
* Register the metrics module with options
|
|
6
|
-
*
|
|
7
|
-
* @param options - Module configuration options
|
|
8
|
-
* @returns Dynamic module
|
|
9
|
-
*/
|
|
10
|
-
static register(options?: MetricsModuleOptions): DynamicModule;
|
|
11
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
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 MetricsModule_1;
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.MetricsModule = void 0;
|
|
11
|
-
const common_1 = require("@nestjs/common");
|
|
12
|
-
const metrics_service_1 = require("./metrics.service");
|
|
13
|
-
const metrics_controller_1 = require("./metrics.controller");
|
|
14
|
-
let MetricsModule = MetricsModule_1 = class MetricsModule {
|
|
15
|
-
/**
|
|
16
|
-
* Register the metrics module with options
|
|
17
|
-
*
|
|
18
|
-
* @param options - Module configuration options
|
|
19
|
-
* @returns Dynamic module
|
|
20
|
-
*/
|
|
21
|
-
static register(options = {}) {
|
|
22
|
-
return {
|
|
23
|
-
module: MetricsModule_1,
|
|
24
|
-
providers: [
|
|
25
|
-
{
|
|
26
|
-
provide: metrics_service_1.MetricsService,
|
|
27
|
-
useValue: new metrics_service_1.MetricsService(options),
|
|
28
|
-
},
|
|
29
|
-
],
|
|
30
|
-
controllers: [metrics_controller_1.MetricsController],
|
|
31
|
-
exports: [metrics_service_1.MetricsService],
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
exports.MetricsModule = MetricsModule;
|
|
36
|
-
exports.MetricsModule = MetricsModule = MetricsModule_1 = __decorate([
|
|
37
|
-
(0, common_1.Global)(),
|
|
38
|
-
(0, common_1.Module)({})
|
|
39
|
-
], MetricsModule);
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { OnModuleDestroy } from '@nestjs/common';
|
|
2
|
-
import { Registry } from 'prom-client';
|
|
3
|
-
import { CounterConfig, GaugeConfig, HistogramConfig, SummaryConfig, MetricsModuleOptions } from './metrics.interface';
|
|
4
|
-
/**
|
|
5
|
-
* Prometheus Metrics Service
|
|
6
|
-
*
|
|
7
|
-
* Provides comprehensive metrics collection and exposure for monitoring
|
|
8
|
-
* and observability using Prometheus.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* // Register a counter
|
|
13
|
-
* this.metricsService.registerCounter({
|
|
14
|
-
* name: 'api_requests_total',
|
|
15
|
-
* help: 'Total API requests',
|
|
16
|
-
* labelNames: ['method', 'endpoint'],
|
|
17
|
-
* });
|
|
18
|
-
*
|
|
19
|
-
* // Increment counter
|
|
20
|
-
* this.metricsService.incrementCounter('api_requests_total', { method: 'GET', endpoint: '/users' });
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export declare class MetricsService implements OnModuleDestroy {
|
|
24
|
-
private readonly logger;
|
|
25
|
-
private readonly registry;
|
|
26
|
-
private readonly metricsRegistry;
|
|
27
|
-
private readonly metricsUpdater;
|
|
28
|
-
private defaultMetricsInterval?;
|
|
29
|
-
private options;
|
|
30
|
-
constructor(options?: MetricsModuleOptions);
|
|
31
|
-
registerCounter(config: CounterConfig): import("prom-client").Counter<string>;
|
|
32
|
-
registerGauge(config: GaugeConfig): import("prom-client").Gauge<string>;
|
|
33
|
-
registerHistogram(config: HistogramConfig): import("prom-client").Histogram<string>;
|
|
34
|
-
registerSummary(config: SummaryConfig): import("prom-client").Summary<string>;
|
|
35
|
-
incrementCounter(name: string, labels?: Record<string, string | number>, value?: number): void;
|
|
36
|
-
setGauge(name: string, value: number, labels?: Record<string, string | number>): void;
|
|
37
|
-
incrementGauge(name: string, labels?: Record<string, string | number>, value?: number): void;
|
|
38
|
-
decrementGauge(name: string, labels?: Record<string, string | number>, value?: number): void;
|
|
39
|
-
observeHistogram(name: string, value: number, labels?: Record<string, string | number>): void;
|
|
40
|
-
observeSummary(name: string, value: number, labels?: Record<string, string | number>): void;
|
|
41
|
-
getMetric(name: string): import("./metrics.interface").MetricEntry | undefined;
|
|
42
|
-
getMetrics(): Promise<string>;
|
|
43
|
-
getContentType(): string;
|
|
44
|
-
getRegistry(): Registry;
|
|
45
|
-
getMetricNames(): string[];
|
|
46
|
-
hasMetric(name: string): boolean;
|
|
47
|
-
resetMetrics(): void;
|
|
48
|
-
clearMetrics(): void;
|
|
49
|
-
onModuleDestroy(): Promise<void>;
|
|
50
|
-
}
|
|
@@ -1,165 +0,0 @@
|
|
|
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 MetricsService_1;
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.MetricsService = void 0;
|
|
11
|
-
const common_1 = require("@nestjs/common");
|
|
12
|
-
const prom_client_1 = require("prom-client");
|
|
13
|
-
const metrics_registry_1 = require("./metrics-registry");
|
|
14
|
-
const metrics_updater_1 = require("./metrics-updater");
|
|
15
|
-
/**
|
|
16
|
-
* Prometheus Metrics Service
|
|
17
|
-
*
|
|
18
|
-
* Provides comprehensive metrics collection and exposure for monitoring
|
|
19
|
-
* and observability using Prometheus.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```typescript
|
|
23
|
-
* // Register a counter
|
|
24
|
-
* this.metricsService.registerCounter({
|
|
25
|
-
* name: 'api_requests_total',
|
|
26
|
-
* help: 'Total API requests',
|
|
27
|
-
* labelNames: ['method', 'endpoint'],
|
|
28
|
-
* });
|
|
29
|
-
*
|
|
30
|
-
* // Increment counter
|
|
31
|
-
* this.metricsService.incrementCounter('api_requests_total', { method: 'GET', endpoint: '/users' });
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
let MetricsService = MetricsService_1 = class MetricsService {
|
|
35
|
-
logger = new common_1.Logger(MetricsService_1.name);
|
|
36
|
-
registry;
|
|
37
|
-
metricsRegistry;
|
|
38
|
-
metricsUpdater;
|
|
39
|
-
defaultMetricsInterval;
|
|
40
|
-
options;
|
|
41
|
-
constructor(options = {}) {
|
|
42
|
-
this.options = {
|
|
43
|
-
defaultMetrics: true,
|
|
44
|
-
prefix: '',
|
|
45
|
-
defaultLabels: {},
|
|
46
|
-
defaultMetricsInterval: 10000,
|
|
47
|
-
circuitBreakerMetrics: true,
|
|
48
|
-
...options,
|
|
49
|
-
};
|
|
50
|
-
this.registry = new prom_client_1.Registry();
|
|
51
|
-
this.metricsRegistry = new metrics_registry_1.MetricsRegistry(this.registry, this.options.prefix);
|
|
52
|
-
this.metricsUpdater = new metrics_updater_1.MetricsUpdater();
|
|
53
|
-
// Set default labels
|
|
54
|
-
if (this.options.defaultLabels) {
|
|
55
|
-
this.registry.setDefaultLabels(this.options.defaultLabels);
|
|
56
|
-
}
|
|
57
|
-
// Collect default metrics
|
|
58
|
-
if (this.options.defaultMetrics) {
|
|
59
|
-
this.defaultMetricsInterval = (0, prom_client_1.collectDefaultMetrics)({
|
|
60
|
-
register: this.registry,
|
|
61
|
-
prefix: this.options.prefix,
|
|
62
|
-
});
|
|
63
|
-
this.logger.log('Default metrics collection enabled');
|
|
64
|
-
}
|
|
65
|
-
this.logger.log('Metrics service initialized');
|
|
66
|
-
}
|
|
67
|
-
// ==================== Registration Methods ====================
|
|
68
|
-
registerCounter(config) {
|
|
69
|
-
return this.metricsRegistry.registerCounter(config);
|
|
70
|
-
}
|
|
71
|
-
registerGauge(config) {
|
|
72
|
-
return this.metricsRegistry.registerGauge(config);
|
|
73
|
-
}
|
|
74
|
-
registerHistogram(config) {
|
|
75
|
-
return this.metricsRegistry.registerHistogram(config);
|
|
76
|
-
}
|
|
77
|
-
registerSummary(config) {
|
|
78
|
-
return this.metricsRegistry.registerSummary(config);
|
|
79
|
-
}
|
|
80
|
-
// ==================== Update Methods ====================
|
|
81
|
-
incrementCounter(name, labels, value = 1) {
|
|
82
|
-
const entry = this.metricsRegistry.getMetric(name);
|
|
83
|
-
if (!entry) {
|
|
84
|
-
throw new Error(`Counter '${name}' not found`);
|
|
85
|
-
}
|
|
86
|
-
this.metricsUpdater.incrementCounter(entry, labels, value);
|
|
87
|
-
}
|
|
88
|
-
setGauge(name, value, labels) {
|
|
89
|
-
const entry = this.metricsRegistry.getMetric(name);
|
|
90
|
-
if (!entry) {
|
|
91
|
-
throw new Error(`Gauge '${name}' not found`);
|
|
92
|
-
}
|
|
93
|
-
this.metricsUpdater.setGauge(entry, value, labels);
|
|
94
|
-
}
|
|
95
|
-
incrementGauge(name, labels, value = 1) {
|
|
96
|
-
const entry = this.metricsRegistry.getMetric(name);
|
|
97
|
-
if (!entry) {
|
|
98
|
-
throw new Error(`Gauge '${name}' not found`);
|
|
99
|
-
}
|
|
100
|
-
this.metricsUpdater.incrementGauge(entry, labels, value);
|
|
101
|
-
}
|
|
102
|
-
decrementGauge(name, labels, value = 1) {
|
|
103
|
-
const entry = this.metricsRegistry.getMetric(name);
|
|
104
|
-
if (!entry) {
|
|
105
|
-
throw new Error(`Gauge '${name}' not found`);
|
|
106
|
-
}
|
|
107
|
-
this.metricsUpdater.decrementGauge(entry, labels, value);
|
|
108
|
-
}
|
|
109
|
-
observeHistogram(name, value, labels) {
|
|
110
|
-
const entry = this.metricsRegistry.getMetric(name);
|
|
111
|
-
if (!entry) {
|
|
112
|
-
throw new Error(`Histogram '${name}' not found`);
|
|
113
|
-
}
|
|
114
|
-
this.metricsUpdater.observeHistogram(entry, value, labels);
|
|
115
|
-
}
|
|
116
|
-
observeSummary(name, value, labels) {
|
|
117
|
-
const entry = this.metricsRegistry.getMetric(name);
|
|
118
|
-
if (!entry) {
|
|
119
|
-
throw new Error(`Summary '${name}' not found`);
|
|
120
|
-
}
|
|
121
|
-
this.metricsUpdater.observeSummary(entry, value, labels);
|
|
122
|
-
}
|
|
123
|
-
// ==================== Query Methods ====================
|
|
124
|
-
getMetric(name) {
|
|
125
|
-
return this.metricsRegistry.getMetric(name);
|
|
126
|
-
}
|
|
127
|
-
async getMetrics() {
|
|
128
|
-
return this.registry.metrics();
|
|
129
|
-
}
|
|
130
|
-
getContentType() {
|
|
131
|
-
return this.registry.contentType;
|
|
132
|
-
}
|
|
133
|
-
getRegistry() {
|
|
134
|
-
return this.registry;
|
|
135
|
-
}
|
|
136
|
-
getMetricNames() {
|
|
137
|
-
return this.metricsRegistry.getMetricNames();
|
|
138
|
-
}
|
|
139
|
-
hasMetric(name) {
|
|
140
|
-
return this.metricsRegistry.hasMetric(name);
|
|
141
|
-
}
|
|
142
|
-
// ==================== Management Methods ====================
|
|
143
|
-
resetMetrics() {
|
|
144
|
-
this.registry.resetMetrics();
|
|
145
|
-
this.logger.log('All metrics reset');
|
|
146
|
-
}
|
|
147
|
-
clearMetrics() {
|
|
148
|
-
this.registry.clear();
|
|
149
|
-
this.metricsRegistry.clear();
|
|
150
|
-
this.logger.log('All metrics cleared');
|
|
151
|
-
}
|
|
152
|
-
// ==================== Lifecycle ====================
|
|
153
|
-
async onModuleDestroy() {
|
|
154
|
-
this.logger.log('Shutting down metrics service...');
|
|
155
|
-
if (this.defaultMetricsInterval) {
|
|
156
|
-
clearInterval(this.defaultMetricsInterval);
|
|
157
|
-
}
|
|
158
|
-
this.clearMetrics();
|
|
159
|
-
this.logger.log('Metrics service shut down');
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
exports.MetricsService = MetricsService;
|
|
163
|
-
exports.MetricsService = MetricsService = MetricsService_1 = __decorate([
|
|
164
|
-
(0, common_1.Injectable)()
|
|
165
|
-
], MetricsService);
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { Alert, AlertRule, AlertingConfig } from './monitoring.interface';
|
|
2
|
-
/**
|
|
3
|
-
* Alerting Service
|
|
4
|
-
*
|
|
5
|
-
* Provides multi-channel alerting with rule engine and deduplication
|
|
6
|
-
*/
|
|
7
|
-
export declare class AlertingService {
|
|
8
|
-
private readonly logger;
|
|
9
|
-
private channels;
|
|
10
|
-
private rules;
|
|
11
|
-
private alertHistory;
|
|
12
|
-
private config;
|
|
13
|
-
constructor(config?: AlertingConfig);
|
|
14
|
-
/**
|
|
15
|
-
* Initialize alert channels
|
|
16
|
-
*/
|
|
17
|
-
private initializeChannels;
|
|
18
|
-
/**
|
|
19
|
-
* Initialize alert rules
|
|
20
|
-
*/
|
|
21
|
-
private initializeRules;
|
|
22
|
-
/**
|
|
23
|
-
* Register an alert rule
|
|
24
|
-
*/
|
|
25
|
-
registerRule(rule: AlertRule): void;
|
|
26
|
-
/**
|
|
27
|
-
* Send an alert
|
|
28
|
-
*/
|
|
29
|
-
sendAlert(alert: Alert): Promise<void>;
|
|
30
|
-
/**
|
|
31
|
-
* Evaluate alert rules
|
|
32
|
-
*/
|
|
33
|
-
evaluateRules(metrics: any): Promise<void>;
|
|
34
|
-
/**
|
|
35
|
-
* Send alert to specific channel
|
|
36
|
-
*/
|
|
37
|
-
private sendToChannel;
|
|
38
|
-
/**
|
|
39
|
-
* Send alert to Slack
|
|
40
|
-
*/
|
|
41
|
-
private sendToSlack;
|
|
42
|
-
/**
|
|
43
|
-
* Send alert to email
|
|
44
|
-
*/
|
|
45
|
-
private sendToEmail;
|
|
46
|
-
/**
|
|
47
|
-
* Send alert to webhook
|
|
48
|
-
*/
|
|
49
|
-
private sendToWebhook;
|
|
50
|
-
/**
|
|
51
|
-
* Send alert to PagerDuty
|
|
52
|
-
*/
|
|
53
|
-
private sendToPagerDuty;
|
|
54
|
-
/**
|
|
55
|
-
* Evaluate alert condition
|
|
56
|
-
*/
|
|
57
|
-
private evaluateCondition;
|
|
58
|
-
/**
|
|
59
|
-
* Interpolate message template
|
|
60
|
-
*/
|
|
61
|
-
private interpolateMessage;
|
|
62
|
-
/**
|
|
63
|
-
* Check if alert is throttled
|
|
64
|
-
*/
|
|
65
|
-
private isThrottled;
|
|
66
|
-
/**
|
|
67
|
-
* Generate alert ID
|
|
68
|
-
*/
|
|
69
|
-
private generateAlertId;
|
|
70
|
-
/**
|
|
71
|
-
* Get severity color for Slack
|
|
72
|
-
*/
|
|
73
|
-
private getSeverityColor;
|
|
74
|
-
/**
|
|
75
|
-
* Get alert history
|
|
76
|
-
*/
|
|
77
|
-
getAlertHistory(): Map<string, Date>;
|
|
78
|
-
/**
|
|
79
|
-
* Clear alert history
|
|
80
|
-
*/
|
|
81
|
-
clearAlertHistory(): void;
|
|
82
|
-
}
|