@dex-monit/observability-sdk-node 1.0.13 → 1.0.15
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 +302 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/lib/console-capture.d.ts +1 -1
- package/dist/lib/console-capture.d.ts.map +1 -1
- package/dist/lib/console-capture.js +8 -3
- package/dist/lib/dex-logger.service.d.ts +1 -1
- package/dist/lib/dex-logger.service.d.ts.map +1 -1
- package/dist/lib/dex-logger.service.js +12 -9
- package/dist/lib/error-capture.interceptor.d.ts +1 -1
- package/dist/lib/error-capture.interceptor.d.ts.map +1 -1
- package/dist/lib/error-capture.interceptor.js +14 -11
- package/dist/lib/global-exception.filter.d.ts +1 -1
- package/dist/lib/global-exception.filter.d.ts.map +1 -1
- package/dist/lib/global-exception.filter.js +13 -10
- package/dist/lib/http-interceptor.d.ts +1 -1
- package/dist/lib/http-interceptor.d.ts.map +1 -1
- package/dist/lib/http-interceptor.js +29 -21
- package/dist/lib/monitoring-client.js +34 -23
- package/dist/lib/nest-logger-capture.d.ts +1 -1
- package/dist/lib/nest-logger-capture.d.ts.map +1 -1
- package/dist/lib/nest-logger-capture.js +23 -18
- package/dist/lib/remote-logger.d.ts +1 -1
- package/dist/lib/remote-logger.d.ts.map +1 -1
- package/dist/lib/remote-logger.js +8 -3
- package/dist/lib/request-id.middleware.js +18 -15
- package/dist/lib/sdk-node.d.ts +10 -10
- package/dist/lib/sdk-node.d.ts.map +1 -1
- package/dist/lib/sdk-node.js +13 -10
- package/dist/lib/sdk-node.module.d.ts +1 -1
- package/dist/lib/sdk-node.module.d.ts.map +1 -1
- package/dist/lib/sdk-node.module.js +54 -52
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +2 -4
package/README.md
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
# @dex-monit/observability-sdk-node
|
|
2
|
+
|
|
3
|
+
NestJS SDK for Dex Monitoring - Automatic error tracking, log management, and HTTP tracing.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @dex-monit/observability-sdk-node
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- ✅ **Automatic Error Capture** - Catches all unhandled exceptions
|
|
14
|
+
- ✅ **Console Capture** - Intercepts `console.log`, `console.warn`, `console.error`
|
|
15
|
+
- ✅ **NestJS Logger Capture** - Intercepts native `Logger.log`, `Logger.warn`, `Logger.error`
|
|
16
|
+
- ✅ **HTTP Request Tracing** - Records all incoming HTTP requests with timing
|
|
17
|
+
- ✅ **Request Context** - Automatic `requestId` propagation
|
|
18
|
+
- ✅ **Breadcrumbs** - Track events leading up to errors
|
|
19
|
+
- ✅ **Source Code Context** - Displays code snippets around errors
|
|
20
|
+
- ✅ **Zero Configuration** - Works out of the box
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
### 1. Import the Module
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
// app.module.ts
|
|
28
|
+
import { Module } from '@nestjs/common';
|
|
29
|
+
import { SdkNodeModule } from '@dex-monit/observability-sdk-node';
|
|
30
|
+
|
|
31
|
+
@Module({
|
|
32
|
+
imports: [
|
|
33
|
+
SdkNodeModule.forRoot({
|
|
34
|
+
logger: {
|
|
35
|
+
serviceName: 'my-api',
|
|
36
|
+
environment: process.env.NODE_ENV || 'development',
|
|
37
|
+
},
|
|
38
|
+
monitoring: {
|
|
39
|
+
apiKey: process.env.DEX_MONITORING_API_KEY,
|
|
40
|
+
apiUrl: process.env.DEX_MONITORING_API_URL || 'https://monit-api.example.com/api',
|
|
41
|
+
project: 'my-project',
|
|
42
|
+
environment: process.env.NODE_ENV || 'development',
|
|
43
|
+
},
|
|
44
|
+
}),
|
|
45
|
+
// ... other modules
|
|
46
|
+
],
|
|
47
|
+
})
|
|
48
|
+
export class AppModule {}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 2. That's It! 🎉
|
|
52
|
+
|
|
53
|
+
The SDK automatically:
|
|
54
|
+
- Captures all unhandled errors
|
|
55
|
+
- Captures all console logs
|
|
56
|
+
- Captures all NestJS Logger calls
|
|
57
|
+
- Records HTTP request traces
|
|
58
|
+
- Generates unique request IDs
|
|
59
|
+
|
|
60
|
+
## Configuration
|
|
61
|
+
|
|
62
|
+
### Full Configuration Options
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
SdkNodeModule.forRoot({
|
|
66
|
+
// Logger configuration
|
|
67
|
+
logger: {
|
|
68
|
+
serviceName: 'my-api', // Required: Your service name
|
|
69
|
+
environment: 'production', // Required: Environment
|
|
70
|
+
level: 'info', // Optional: Minimum log level (default: 'info')
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
// Monitoring client configuration
|
|
74
|
+
monitoring: {
|
|
75
|
+
apiKey: 'your-api-key', // Required: API key from Dex Monitoring
|
|
76
|
+
apiUrl: 'https://api.example.com/api', // Required: Monitoring API URL
|
|
77
|
+
project: 'my-project', // Required: Project identifier
|
|
78
|
+
environment: 'production', // Required: Environment
|
|
79
|
+
release: '1.0.0', // Optional: Release/version
|
|
80
|
+
serverName: 'api-server-1', // Optional: Server identifier
|
|
81
|
+
debug: false, // Optional: Enable debug mode
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
// Optional settings
|
|
85
|
+
remoteLogLevel: 'info', // Minimum level to send remotely (default: 'debug')
|
|
86
|
+
captureConsole: true, // Capture console.* calls (default: true)
|
|
87
|
+
captureNestLogger: true, // Capture NestJS Logger (default: true)
|
|
88
|
+
captureHttpRequests: true, // Record HTTP traces (default: true)
|
|
89
|
+
});
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Using the Logger
|
|
93
|
+
|
|
94
|
+
### Option 1: DexLoggerService (Recommended)
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
import { Injectable } from '@nestjs/common';
|
|
98
|
+
import { DexLoggerService, DEX_LOGGER_TOKEN } from '@dex-monit/observability-sdk-node';
|
|
99
|
+
|
|
100
|
+
@Injectable()
|
|
101
|
+
export class MyService {
|
|
102
|
+
constructor(
|
|
103
|
+
@Inject(DEX_LOGGER_TOKEN) private readonly logger: DexLoggerService,
|
|
104
|
+
) {}
|
|
105
|
+
|
|
106
|
+
doSomething() {
|
|
107
|
+
this.logger.log('Processing started', 'MyService');
|
|
108
|
+
this.logger.debug('Debug info', 'MyService');
|
|
109
|
+
this.logger.warn('Warning message', 'MyService');
|
|
110
|
+
this.logger.error('Error occurred', 'stack trace', 'MyService');
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Option 2: Native NestJS Logger (Auto-captured)
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
import { Injectable, Logger } from '@nestjs/common';
|
|
119
|
+
|
|
120
|
+
@Injectable()
|
|
121
|
+
export class MyService {
|
|
122
|
+
private readonly logger = new Logger(MyService.name);
|
|
123
|
+
|
|
124
|
+
doSomething() {
|
|
125
|
+
// These are automatically captured and sent to monitoring
|
|
126
|
+
this.logger.log('Processing started');
|
|
127
|
+
this.logger.warn('Warning message');
|
|
128
|
+
this.logger.error('Error occurred');
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Option 3: Console (Auto-captured)
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
// These are automatically captured and sent to monitoring
|
|
137
|
+
console.log('Info message');
|
|
138
|
+
console.warn('Warning message');
|
|
139
|
+
console.error('Error message');
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Manual Error Capture
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
import { Injectable, Inject } from '@nestjs/common';
|
|
146
|
+
import { MonitoringClient, MONITORING_CLIENT_TOKEN } from '@dex-monit/observability-sdk-node';
|
|
147
|
+
|
|
148
|
+
@Injectable()
|
|
149
|
+
export class MyService {
|
|
150
|
+
constructor(
|
|
151
|
+
@Inject(MONITORING_CLIENT_TOKEN) private readonly monitoring: MonitoringClient,
|
|
152
|
+
) {}
|
|
153
|
+
|
|
154
|
+
async processPayment() {
|
|
155
|
+
try {
|
|
156
|
+
await this.paymentGateway.charge();
|
|
157
|
+
} catch (error) {
|
|
158
|
+
// Manually capture with extra context
|
|
159
|
+
this.monitoring.captureException(error, {
|
|
160
|
+
user: { id: 'user-123', email: 'user@example.com' },
|
|
161
|
+
tags: { component: 'payment', gateway: 'stripe' },
|
|
162
|
+
extra: { orderId: 'order-456', amount: 99.99 },
|
|
163
|
+
});
|
|
164
|
+
throw error;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Breadcrumbs
|
|
171
|
+
|
|
172
|
+
Track events leading up to errors:
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
import { addBreadcrumb } from '@dex-monit/observability-sdk-node';
|
|
176
|
+
|
|
177
|
+
// Add a breadcrumb
|
|
178
|
+
addBreadcrumb({
|
|
179
|
+
category: 'user.action',
|
|
180
|
+
message: 'User clicked checkout button',
|
|
181
|
+
level: 'info',
|
|
182
|
+
data: { cartItems: 3 },
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
// HTTP breadcrumbs are added automatically for HTTP traces
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## User Context
|
|
189
|
+
|
|
190
|
+
Set user information for error tracking:
|
|
191
|
+
|
|
192
|
+
```typescript
|
|
193
|
+
import { Injectable, Inject } from '@nestjs/common';
|
|
194
|
+
import { MonitoringClient, MONITORING_CLIENT_TOKEN } from '@dex-monit/observability-sdk-node';
|
|
195
|
+
|
|
196
|
+
@Injectable()
|
|
197
|
+
export class AuthService {
|
|
198
|
+
constructor(
|
|
199
|
+
@Inject(MONITORING_CLIENT_TOKEN) private readonly monitoring: MonitoringClient,
|
|
200
|
+
) {}
|
|
201
|
+
|
|
202
|
+
onLogin(user: User) {
|
|
203
|
+
this.monitoring.setUser({
|
|
204
|
+
id: user.id,
|
|
205
|
+
email: user.email,
|
|
206
|
+
username: user.username,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## HTTP Tracing
|
|
213
|
+
|
|
214
|
+
HTTP requests are automatically traced with:
|
|
215
|
+
- Request method, URL, path
|
|
216
|
+
- Response status code
|
|
217
|
+
- Duration (ms)
|
|
218
|
+
- Client IP address
|
|
219
|
+
- User agent
|
|
220
|
+
- Headers (sensitive data scrubbed)
|
|
221
|
+
- Query parameters
|
|
222
|
+
- Request/response sizes
|
|
223
|
+
|
|
224
|
+
View traces in the Dex Monitoring dashboard under **Traces**.
|
|
225
|
+
|
|
226
|
+
## Request ID Propagation
|
|
227
|
+
|
|
228
|
+
The SDK automatically:
|
|
229
|
+
1. Generates a unique `requestId` for each request
|
|
230
|
+
2. Reads incoming `x-request-id` header (for distributed tracing)
|
|
231
|
+
3. Sets `x-request-id` on the response
|
|
232
|
+
4. Includes `requestId` in all logs and errors
|
|
233
|
+
|
|
234
|
+
## What Gets Captured
|
|
235
|
+
|
|
236
|
+
### Automatic Capture
|
|
237
|
+
| Type | Captured | Sent to |
|
|
238
|
+
|------|----------|---------|
|
|
239
|
+
| Unhandled exceptions | ✅ | Errors |
|
|
240
|
+
| Promise rejections | ✅ | Errors |
|
|
241
|
+
| `console.log/warn/error` | ✅ | Logs |
|
|
242
|
+
| `Logger.log/warn/error` | ✅ | Logs |
|
|
243
|
+
| HTTP requests | ✅ | Traces |
|
|
244
|
+
|
|
245
|
+
### Error Context
|
|
246
|
+
Each captured error includes:
|
|
247
|
+
- Full stack trace with source code context
|
|
248
|
+
- Request details (URL, method, headers, body)
|
|
249
|
+
- User information (if set)
|
|
250
|
+
- Breadcrumbs (recent events)
|
|
251
|
+
- Runtime info (Node.js version, memory)
|
|
252
|
+
- OS info (platform, version)
|
|
253
|
+
- Custom tags and extra data
|
|
254
|
+
|
|
255
|
+
## Environment Variables
|
|
256
|
+
|
|
257
|
+
```env
|
|
258
|
+
# Required
|
|
259
|
+
DEX_MONITORING_API_KEY=your-api-key
|
|
260
|
+
DEX_MONITORING_API_URL=https://monit-api.example.com/api
|
|
261
|
+
|
|
262
|
+
# Optional
|
|
263
|
+
NODE_ENV=production
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
## Disabling Features
|
|
267
|
+
|
|
268
|
+
```typescript
|
|
269
|
+
SdkNodeModule.forRoot({
|
|
270
|
+
logger: { serviceName: 'my-api', environment: 'production' },
|
|
271
|
+
monitoring: { /* ... */ },
|
|
272
|
+
|
|
273
|
+
// Disable specific features
|
|
274
|
+
captureConsole: false, // Don't capture console.*
|
|
275
|
+
captureNestLogger: false, // Don't capture NestJS Logger
|
|
276
|
+
captureHttpRequests: false, // Don't record HTTP traces
|
|
277
|
+
remoteLogLevel: 'error', // Only send errors remotely
|
|
278
|
+
});
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
## Dependencies
|
|
282
|
+
|
|
283
|
+
This SDK includes:
|
|
284
|
+
- `@dex-monit/observability-contracts` - TypeScript interfaces
|
|
285
|
+
- `@dex-monit/observability-logger` - Pino-based logger
|
|
286
|
+
- `@dex-monit/observability-request-context` - Request context
|
|
287
|
+
- `@dex-monit/observability-scrubber` - Sensitive data scrubbing
|
|
288
|
+
|
|
289
|
+
## Peer Dependencies
|
|
290
|
+
|
|
291
|
+
```json
|
|
292
|
+
{
|
|
293
|
+
"@nestjs/common": "^10.0.0 || ^11.0.0",
|
|
294
|
+
"@nestjs/core": "^10.0.0 || ^11.0.0",
|
|
295
|
+
"rxjs": "^7.0.0 || ^8.0.0",
|
|
296
|
+
"uuid": "^9.0.0 - ^13.0.0"
|
|
297
|
+
}
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
## License
|
|
301
|
+
|
|
302
|
+
MIT
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './lib/sdk-node
|
|
1
|
+
export * from './lib/sdk-node';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"console-capture.d.ts","sourceRoot":"","sources":["../../src/lib/console-capture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"console-capture.d.ts","sourceRoot":"","sources":["../../src/lib/console-capture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAyBvD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,gBAAgB,EAAE,gBAAgB,EAClC,OAAO,GAAE;IAAE,cAAc,CAAC,EAAE,OAAO,CAAA;CAAO,GACzC,IAAI,CA2CN;AAyCD;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAczC;AAqBD;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,OAAO,CAEhD"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.startConsoleCapture = startConsoleCapture;
|
|
4
|
+
exports.stopConsoleCapture = stopConsoleCapture;
|
|
5
|
+
exports.isConsoleCaptureActive = isConsoleCaptureActive;
|
|
1
6
|
const CONSOLE_TO_SEVERITY = {
|
|
2
7
|
debug: 'debug',
|
|
3
8
|
log: 'info',
|
|
@@ -14,7 +19,7 @@ let skipNestLogs = false;
|
|
|
14
19
|
* @param options - Options for console capture
|
|
15
20
|
* @param options.skipNestJsLogs - Skip logs that appear to come from NestJS Logger (to avoid duplicates)
|
|
16
21
|
*/
|
|
17
|
-
|
|
22
|
+
function startConsoleCapture(monitoringClient, options = {}) {
|
|
18
23
|
if (isCapturing) {
|
|
19
24
|
return;
|
|
20
25
|
}
|
|
@@ -87,7 +92,7 @@ function shouldSkipLog(message) {
|
|
|
87
92
|
/**
|
|
88
93
|
* Stop capturing console output
|
|
89
94
|
*/
|
|
90
|
-
|
|
95
|
+
function stopConsoleCapture() {
|
|
91
96
|
if (!isCapturing || !originalMethods) {
|
|
92
97
|
return;
|
|
93
98
|
}
|
|
@@ -122,6 +127,6 @@ function formatConsoleArgs(args) {
|
|
|
122
127
|
/**
|
|
123
128
|
* Check if console capture is active
|
|
124
129
|
*/
|
|
125
|
-
|
|
130
|
+
function isConsoleCaptureActive() {
|
|
126
131
|
return isCapturing;
|
|
127
132
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dex-logger.service.d.ts","sourceRoot":"","sources":["../../src/lib/dex-logger.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,aAAa,EAAS,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"dex-logger.service.d.ts","sourceRoot":"","sources":["../../src/lib/dex-logger.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,aAAa,EAAS,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAIvD;;GAEG;AACH,eAAO,MAAM,gBAAgB,uBAAuB,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBACa,gBAAiB,YAAW,aAAa;IACpD,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,OAAO,CAAC,gBAA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;IAM1D;;OAEG;IACH,OAAO,CAAC,QAAQ;IAsChB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAgBxB;;OAEG;IACH,OAAO,CAAC,cAAc;IAQtB;;OAEG;IACH,OAAO,CAAC,kBAAkB;CA4B3B"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DexLoggerService = exports.DEX_LOGGER_TOKEN = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const observability_request_context_1 = require("@dex-monit/observability-request-context");
|
|
4
7
|
/**
|
|
5
8
|
* Token for injecting DexLoggerService
|
|
6
9
|
*/
|
|
7
|
-
|
|
10
|
+
exports.DEX_LOGGER_TOKEN = 'DEX_LOGGER_SERVICE';
|
|
8
11
|
/**
|
|
9
12
|
* DexLoggerService - NestJS compatible logger that sends logs to monitoring
|
|
10
13
|
*
|
|
@@ -29,7 +32,7 @@ export const DEX_LOGGER_TOKEN = 'DEX_LOGGER_SERVICE';
|
|
|
29
32
|
* ```
|
|
30
33
|
*/
|
|
31
34
|
let DexLoggerService = (() => {
|
|
32
|
-
let _classDecorators = [Injectable({ scope: Scope.TRANSIENT })];
|
|
35
|
+
let _classDecorators = [(0, common_1.Injectable)({ scope: common_1.Scope.TRANSIENT })];
|
|
33
36
|
let _classDescriptor;
|
|
34
37
|
let _classExtraInitializers = [];
|
|
35
38
|
let _classThis;
|
|
@@ -37,10 +40,10 @@ let DexLoggerService = (() => {
|
|
|
37
40
|
static { _classThis = this; }
|
|
38
41
|
static {
|
|
39
42
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
40
|
-
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
43
|
+
tslib_1.__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
41
44
|
DexLoggerService = _classThis = _classDescriptor.value;
|
|
42
45
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
43
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
|
46
|
+
tslib_1.__runInitializers(_classThis, _classExtraInitializers);
|
|
44
47
|
}
|
|
45
48
|
context;
|
|
46
49
|
monitoringClient;
|
|
@@ -86,7 +89,7 @@ let DexLoggerService = (() => {
|
|
|
86
89
|
*/
|
|
87
90
|
writeLog(level, message, context, extra) {
|
|
88
91
|
const ctx = context || this.context || 'Application';
|
|
89
|
-
const requestContext = RequestContextService.get();
|
|
92
|
+
const requestContext = observability_request_context_1.RequestContextService.get();
|
|
90
93
|
const timestamp = new Date().toISOString();
|
|
91
94
|
// Format for console output
|
|
92
95
|
const logData = {
|
|
@@ -169,4 +172,4 @@ let DexLoggerService = (() => {
|
|
|
169
172
|
};
|
|
170
173
|
return DexLoggerService = _classThis;
|
|
171
174
|
})();
|
|
172
|
-
|
|
175
|
+
exports.DexLoggerService = DexLoggerService;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
|
-
import { MonitoringClient } from './monitoring-client
|
|
3
|
+
import { MonitoringClient } from './monitoring-client';
|
|
4
4
|
/**
|
|
5
5
|
* Error Capture Interceptor
|
|
6
6
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-capture.interceptor.d.ts","sourceRoot":"","sources":["../../src/lib/error-capture.interceptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EACf,gBAAgB,EAChB,WAAW,EACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAc,MAAM,MAAM,CAAC;AAI9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"error-capture.interceptor.d.ts","sourceRoot":"","sources":["../../src/lib/error-capture.interceptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EACf,gBAAgB,EAChB,WAAW,EACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAc,MAAM,MAAM,CAAC;AAI9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;;;GAMG;AACH,qBACa,uBAAwB,YAAW,eAAe;IAE3D,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC;gBAAjB,gBAAgB,CAAC,EAAE,gBAAgB,YAAA;IAGtD,SAAS,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,WAAW,GAAG,UAAU,CAAC,OAAO,CAAC;IAY5E,OAAO,CAAC,YAAY;IAkEpB,OAAO,CAAC,UAAU;IAQlB,OAAO,CAAC,eAAe;IAevB,OAAO,CAAC,YAAY;IAiBpB,OAAO,CAAC,eAAe;CASxB"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ErrorCaptureInterceptor = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const rxjs_1 = require("rxjs");
|
|
7
|
+
const operators_1 = require("rxjs/operators");
|
|
8
|
+
const os = tslib_1.__importStar(require("os"));
|
|
6
9
|
/**
|
|
7
10
|
* Error Capture Interceptor
|
|
8
11
|
*
|
|
@@ -11,7 +14,7 @@ import * as os from 'os';
|
|
|
11
14
|
* so this will capture errors even if another filter handles them.
|
|
12
15
|
*/
|
|
13
16
|
let ErrorCaptureInterceptor = (() => {
|
|
14
|
-
let _classDecorators = [Injectable()];
|
|
17
|
+
let _classDecorators = [(0, common_1.Injectable)()];
|
|
15
18
|
let _classDescriptor;
|
|
16
19
|
let _classExtraInitializers = [];
|
|
17
20
|
let _classThis;
|
|
@@ -19,21 +22,21 @@ let ErrorCaptureInterceptor = (() => {
|
|
|
19
22
|
static { _classThis = this; }
|
|
20
23
|
static {
|
|
21
24
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
22
|
-
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
25
|
+
tslib_1.__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
23
26
|
ErrorCaptureInterceptor = _classThis = _classDescriptor.value;
|
|
24
27
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
25
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
|
28
|
+
tslib_1.__runInitializers(_classThis, _classExtraInitializers);
|
|
26
29
|
}
|
|
27
30
|
monitoringClient;
|
|
28
31
|
constructor(monitoringClient) {
|
|
29
32
|
this.monitoringClient = monitoringClient;
|
|
30
33
|
}
|
|
31
34
|
intercept(context, next) {
|
|
32
|
-
return next.handle().pipe(catchError((error) => {
|
|
35
|
+
return next.handle().pipe((0, operators_1.catchError)((error) => {
|
|
33
36
|
// Capture the error
|
|
34
37
|
this.captureError(error, context);
|
|
35
38
|
// Re-throw so other handlers can process it
|
|
36
|
-
return throwError(() => error);
|
|
39
|
+
return (0, rxjs_1.throwError)(() => error);
|
|
37
40
|
}));
|
|
38
41
|
}
|
|
39
42
|
captureError(error, context) {
|
|
@@ -146,4 +149,4 @@ let ErrorCaptureInterceptor = (() => {
|
|
|
146
149
|
};
|
|
147
150
|
return ErrorCaptureInterceptor = _classThis;
|
|
148
151
|
})();
|
|
149
|
-
|
|
152
|
+
exports.ErrorCaptureInterceptor = ErrorCaptureInterceptor;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ExceptionFilter, ArgumentsHost } from '@nestjs/common';
|
|
2
2
|
import { Logger } from '@dex-monit/observability-logger';
|
|
3
|
-
import { MonitoringClient } from './monitoring-client
|
|
3
|
+
import { MonitoringClient } from './monitoring-client';
|
|
4
4
|
/**
|
|
5
5
|
* Global Exception Filter
|
|
6
6
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global-exception.filter.d.ts","sourceRoot":"","sources":["../../src/lib/global-exception.filter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAEf,aAAa,EAId,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"global-exception.filter.d.ts","sourceRoot":"","sources":["../../src/lib/global-exception.filter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAEf,aAAa,EAId,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAavD;;;;;GAKG;AACH,qBAEa,qBAAsB,YAAW,eAAe;IAEzD,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC;gBADjB,MAAM,EAAE,MAAM,EACd,gBAAgB,CAAC,EAAE,gBAAgB,YAAA;IAGtD,KAAK,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,GAAG,IAAI;IAiFpD;;OAEG;IACH,OAAO,CAAC,eAAe;CAcxB"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GlobalExceptionFilter = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const observability_request_context_1 = require("@dex-monit/observability-request-context");
|
|
4
7
|
/**
|
|
5
8
|
* Global Exception Filter
|
|
6
9
|
*
|
|
@@ -8,7 +11,7 @@ import { RequestContextService } from '@dex-monit/observability-request-context'
|
|
|
8
11
|
* Returns a standardized error response with request ID for correlation.
|
|
9
12
|
*/
|
|
10
13
|
let GlobalExceptionFilter = (() => {
|
|
11
|
-
let _classDecorators = [Catch(), Injectable()];
|
|
14
|
+
let _classDecorators = [(0, common_1.Catch)(), (0, common_1.Injectable)()];
|
|
12
15
|
let _classDescriptor;
|
|
13
16
|
let _classExtraInitializers = [];
|
|
14
17
|
let _classThis;
|
|
@@ -16,10 +19,10 @@ let GlobalExceptionFilter = (() => {
|
|
|
16
19
|
static { _classThis = this; }
|
|
17
20
|
static {
|
|
18
21
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
19
|
-
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
22
|
+
tslib_1.__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
20
23
|
GlobalExceptionFilter = _classThis = _classDescriptor.value;
|
|
21
24
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
22
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
|
25
|
+
tslib_1.__runInitializers(_classThis, _classExtraInitializers);
|
|
23
26
|
}
|
|
24
27
|
logger;
|
|
25
28
|
monitoringClient;
|
|
@@ -33,14 +36,14 @@ let GlobalExceptionFilter = (() => {
|
|
|
33
36
|
const response = ctx.getResponse();
|
|
34
37
|
const request = ctx.getRequest();
|
|
35
38
|
// Get request context
|
|
36
|
-
const requestContext = RequestContextService.get();
|
|
39
|
+
const requestContext = observability_request_context_1.RequestContextService.get();
|
|
37
40
|
const requestId = requestContext?.requestId;
|
|
38
41
|
// Determine status code and error details
|
|
39
|
-
let statusCode = HttpStatus.INTERNAL_SERVER_ERROR;
|
|
42
|
+
let statusCode = common_1.HttpStatus.INTERNAL_SERVER_ERROR;
|
|
40
43
|
let message = 'Internal server error';
|
|
41
44
|
let errorName = 'InternalServerError';
|
|
42
45
|
let stack;
|
|
43
|
-
if (exception instanceof HttpException) {
|
|
46
|
+
if (exception instanceof common_1.HttpException) {
|
|
44
47
|
statusCode = exception.getStatus();
|
|
45
48
|
const exceptionResponse = exception.getResponse();
|
|
46
49
|
if (typeof exceptionResponse === 'string') {
|
|
@@ -118,4 +121,4 @@ let GlobalExceptionFilter = (() => {
|
|
|
118
121
|
};
|
|
119
122
|
return GlobalExceptionFilter = _classThis;
|
|
120
123
|
})();
|
|
121
|
-
|
|
124
|
+
exports.GlobalExceptionFilter = GlobalExceptionFilter;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { Request, Response } from 'express';
|
|
4
|
-
import { MonitoringClient } from './monitoring-client
|
|
4
|
+
import { MonitoringClient } from './monitoring-client';
|
|
5
5
|
export declare const HTTP_TRACE_MONITORING_TOKEN = "HTTP_TRACE_MONITORING_CLIENT";
|
|
6
6
|
export interface HttpTrace {
|
|
7
7
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-interceptor.d.ts","sourceRoot":"","sources":["../../src/lib/http-interceptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EACf,gBAAgB,EAChB,WAAW,EACZ,MAAM,gBAAgB,CAAC;AACx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