@pawells/nestjs-prometheus 2.0.1 → 2.0.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 +14 -14
- package/build/README.md +14 -14
- package/build/package.json +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://github.com/PhillipAWells/nestjs-common/releases)
|
|
4
4
|
[](https://github.com/PhillipAWells/nestjs-common/actions/workflows/ci.yml)
|
|
5
5
|
[](https://www.npmjs.com/package/@pawells/nestjs-prometheus)
|
|
6
|
-
[](https://nodejs.org)
|
|
7
7
|
[](./LICENSE)
|
|
8
8
|
[](https://github.com/sponsors/PhillipAWells)
|
|
9
9
|
|
|
@@ -17,7 +17,7 @@ yarn add @pawells/nestjs-prometheus prom-client
|
|
|
17
17
|
|
|
18
18
|
## Requirements
|
|
19
19
|
|
|
20
|
-
- **Node.js**: >=
|
|
20
|
+
- **Node.js**: >= 22.0.0
|
|
21
21
|
- **NestJS**: >= 10.0.0
|
|
22
22
|
- **prom-client**: >= 15.0.0
|
|
23
23
|
- **@pawells/nestjs-shared**: same version
|
|
@@ -42,7 +42,7 @@ import { Module } from '@nestjs/common';
|
|
|
42
42
|
import { PrometheusModule } from '@pawells/nestjs-prometheus';
|
|
43
43
|
|
|
44
44
|
@Module({
|
|
45
|
-
imports: [PrometheusModule.
|
|
45
|
+
imports: [PrometheusModule.ForRoot()],
|
|
46
46
|
})
|
|
47
47
|
export class AppModule {}
|
|
48
48
|
```
|
|
@@ -153,7 +153,7 @@ import { PrometheusModule } from '@pawells/nestjs-prometheus';
|
|
|
153
153
|
import { HTTPMetricsInterceptor } from '@pawells/nestjs-shared';
|
|
154
154
|
|
|
155
155
|
@Module({
|
|
156
|
-
imports: [PrometheusModule.
|
|
156
|
+
imports: [PrometheusModule.ForRoot()],
|
|
157
157
|
providers: [
|
|
158
158
|
{
|
|
159
159
|
provide: APP_INTERCEPTOR,
|
|
@@ -168,17 +168,17 @@ This automatically tracks:
|
|
|
168
168
|
- **Request count** by method and route
|
|
169
169
|
- **Request duration** (histogram with default buckets)
|
|
170
170
|
- **Response status codes**
|
|
171
|
-
- **Path normalization** (dynamic segments like UUIDs are normalized to `:id`)
|
|
171
|
+
- **Path normalization** (dynamic segments like UUIDs, MongoDB ObjectIDs, and numeric IDs are normalized to `:id` — this is a security measure that prevents unbounded metric cardinality, which could exhaust Prometheus memory if high-entropy path segments were used as label values)
|
|
172
172
|
|
|
173
173
|
## Module API
|
|
174
174
|
|
|
175
|
-
### PrometheusModule.
|
|
175
|
+
### PrometheusModule.ForRoot()
|
|
176
176
|
|
|
177
177
|
Returns a DynamicModule configured as global, enabling single import at the top level:
|
|
178
178
|
|
|
179
179
|
```typescript
|
|
180
180
|
@Module({
|
|
181
|
-
imports: [PrometheusModule.
|
|
181
|
+
imports: [PrometheusModule.ForRoot()],
|
|
182
182
|
})
|
|
183
183
|
export class AppModule {}
|
|
184
184
|
```
|
|
@@ -190,11 +190,11 @@ export class AppModule {}
|
|
|
190
190
|
The main NestJS module. Implements `OnModuleInit` and `OnApplicationShutdown`.
|
|
191
191
|
|
|
192
192
|
**Static Methods:**
|
|
193
|
-
- `
|
|
193
|
+
- `ForRoot()` - Create global module with automatic registration
|
|
194
194
|
|
|
195
195
|
**Lifecycle Methods:**
|
|
196
196
|
- `onModuleInit()` - Registers the exporter with InstrumentationRegistry
|
|
197
|
-
- `onApplicationShutdown()` - Calls
|
|
197
|
+
- `onApplicationShutdown()` - Calls `Exporter.Shutdown()` to clean up resources
|
|
198
198
|
|
|
199
199
|
### PrometheusExporter
|
|
200
200
|
|
|
@@ -205,10 +205,10 @@ Implements `IMetricsExporter` from `@pawells/nestjs-shared`.
|
|
|
205
205
|
- `SupportsPull` - `true` (supports pull-based retrieval)
|
|
206
206
|
|
|
207
207
|
**Methods:**
|
|
208
|
-
- `
|
|
209
|
-
- `
|
|
210
|
-
- `
|
|
211
|
-
- `
|
|
208
|
+
- `OnDescriptorRegistered(descriptor: IMetricDescriptor)` - Called when a metric is registered; creates the appropriate prom-client instrument
|
|
209
|
+
- `OnMetricRecorded(value: IMetricValue)` - Buffers a metric value to be flushed on next pull
|
|
210
|
+
- `GetMetrics(): Promise<string>` - Flushes pending values and returns metrics in Prometheus text format
|
|
211
|
+
- `Shutdown(): Promise<void>` - Clears registry and releases resources
|
|
212
212
|
|
|
213
213
|
**Internals:**
|
|
214
214
|
- Maintains a prom-client `Registry` for instrument management
|
|
@@ -220,7 +220,7 @@ Implements `IMetricsExporter` from `@pawells/nestjs-shared`.
|
|
|
220
220
|
HTTP controller with single endpoint.
|
|
221
221
|
|
|
222
222
|
**Methods:**
|
|
223
|
-
- `
|
|
223
|
+
- `GetMetrics(response: Response): Promise<void>` - GET /metrics, protected by MetricsGuard
|
|
224
224
|
|
|
225
225
|
## Advanced Patterns
|
|
226
226
|
|
package/build/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://github.com/PhillipAWells/nestjs-common/releases)
|
|
4
4
|
[](https://github.com/PhillipAWells/nestjs-common/actions/workflows/ci.yml)
|
|
5
5
|
[](https://www.npmjs.com/package/@pawells/nestjs-prometheus)
|
|
6
|
-
[](https://nodejs.org)
|
|
7
7
|
[](./LICENSE)
|
|
8
8
|
[](https://github.com/sponsors/PhillipAWells)
|
|
9
9
|
|
|
@@ -17,7 +17,7 @@ yarn add @pawells/nestjs-prometheus prom-client
|
|
|
17
17
|
|
|
18
18
|
## Requirements
|
|
19
19
|
|
|
20
|
-
- **Node.js**: >=
|
|
20
|
+
- **Node.js**: >= 22.0.0
|
|
21
21
|
- **NestJS**: >= 10.0.0
|
|
22
22
|
- **prom-client**: >= 15.0.0
|
|
23
23
|
- **@pawells/nestjs-shared**: same version
|
|
@@ -42,7 +42,7 @@ import { Module } from '@nestjs/common';
|
|
|
42
42
|
import { PrometheusModule } from '@pawells/nestjs-prometheus';
|
|
43
43
|
|
|
44
44
|
@Module({
|
|
45
|
-
imports: [PrometheusModule.
|
|
45
|
+
imports: [PrometheusModule.ForRoot()],
|
|
46
46
|
})
|
|
47
47
|
export class AppModule {}
|
|
48
48
|
```
|
|
@@ -153,7 +153,7 @@ import { PrometheusModule } from '@pawells/nestjs-prometheus';
|
|
|
153
153
|
import { HTTPMetricsInterceptor } from '@pawells/nestjs-shared';
|
|
154
154
|
|
|
155
155
|
@Module({
|
|
156
|
-
imports: [PrometheusModule.
|
|
156
|
+
imports: [PrometheusModule.ForRoot()],
|
|
157
157
|
providers: [
|
|
158
158
|
{
|
|
159
159
|
provide: APP_INTERCEPTOR,
|
|
@@ -168,17 +168,17 @@ This automatically tracks:
|
|
|
168
168
|
- **Request count** by method and route
|
|
169
169
|
- **Request duration** (histogram with default buckets)
|
|
170
170
|
- **Response status codes**
|
|
171
|
-
- **Path normalization** (dynamic segments like UUIDs are normalized to `:id`)
|
|
171
|
+
- **Path normalization** (dynamic segments like UUIDs, MongoDB ObjectIDs, and numeric IDs are normalized to `:id` — this is a security measure that prevents unbounded metric cardinality, which could exhaust Prometheus memory if high-entropy path segments were used as label values)
|
|
172
172
|
|
|
173
173
|
## Module API
|
|
174
174
|
|
|
175
|
-
### PrometheusModule.
|
|
175
|
+
### PrometheusModule.ForRoot()
|
|
176
176
|
|
|
177
177
|
Returns a DynamicModule configured as global, enabling single import at the top level:
|
|
178
178
|
|
|
179
179
|
```typescript
|
|
180
180
|
@Module({
|
|
181
|
-
imports: [PrometheusModule.
|
|
181
|
+
imports: [PrometheusModule.ForRoot()],
|
|
182
182
|
})
|
|
183
183
|
export class AppModule {}
|
|
184
184
|
```
|
|
@@ -190,11 +190,11 @@ export class AppModule {}
|
|
|
190
190
|
The main NestJS module. Implements `OnModuleInit` and `OnApplicationShutdown`.
|
|
191
191
|
|
|
192
192
|
**Static Methods:**
|
|
193
|
-
- `
|
|
193
|
+
- `ForRoot()` - Create global module with automatic registration
|
|
194
194
|
|
|
195
195
|
**Lifecycle Methods:**
|
|
196
196
|
- `onModuleInit()` - Registers the exporter with InstrumentationRegistry
|
|
197
|
-
- `onApplicationShutdown()` - Calls
|
|
197
|
+
- `onApplicationShutdown()` - Calls `Exporter.Shutdown()` to clean up resources
|
|
198
198
|
|
|
199
199
|
### PrometheusExporter
|
|
200
200
|
|
|
@@ -205,10 +205,10 @@ Implements `IMetricsExporter` from `@pawells/nestjs-shared`.
|
|
|
205
205
|
- `SupportsPull` - `true` (supports pull-based retrieval)
|
|
206
206
|
|
|
207
207
|
**Methods:**
|
|
208
|
-
- `
|
|
209
|
-
- `
|
|
210
|
-
- `
|
|
211
|
-
- `
|
|
208
|
+
- `OnDescriptorRegistered(descriptor: IMetricDescriptor)` - Called when a metric is registered; creates the appropriate prom-client instrument
|
|
209
|
+
- `OnMetricRecorded(value: IMetricValue)` - Buffers a metric value to be flushed on next pull
|
|
210
|
+
- `GetMetrics(): Promise<string>` - Flushes pending values and returns metrics in Prometheus text format
|
|
211
|
+
- `Shutdown(): Promise<void>` - Clears registry and releases resources
|
|
212
212
|
|
|
213
213
|
**Internals:**
|
|
214
214
|
- Maintains a prom-client `Registry` for instrument management
|
|
@@ -220,7 +220,7 @@ Implements `IMetricsExporter` from `@pawells/nestjs-shared`.
|
|
|
220
220
|
HTTP controller with single endpoint.
|
|
221
221
|
|
|
222
222
|
**Methods:**
|
|
223
|
-
- `
|
|
223
|
+
- `GetMetrics(response: Response): Promise<void>` - GET /metrics, protected by MetricsGuard
|
|
224
224
|
|
|
225
225
|
## Advanced Patterns
|
|
226
226
|
|
package/build/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pawells/nestjs-prometheus",
|
|
3
3
|
"displayName": "@pawells/nestjs-prometheus",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.2",
|
|
5
5
|
"description": "NestJS Prometheus metrics module with endpoint controller",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./build/index.js",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"xss": ">=1.0.0"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@pawells/nestjs-shared": "2.0.
|
|
43
|
+
"@pawells/nestjs-shared": "2.0.2"
|
|
44
44
|
},
|
|
45
45
|
"engines": {
|
|
46
46
|
"node": ">=22.0.0"
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pawells/nestjs-prometheus",
|
|
3
3
|
"displayName": "@pawells/nestjs-prometheus",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.2",
|
|
5
5
|
"description": "NestJS Prometheus metrics module with endpoint controller",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./build/index.js",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"xss": ">=1.0.0"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@pawells/nestjs-shared": "2.0.
|
|
43
|
+
"@pawells/nestjs-shared": "2.0.2"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@nestjs/common": "^11.1.17",
|