Skip to content

Commit 25fb49c

Browse files
committed
feat: disable default metrics
1 parent 517f20a commit 25fb49c

File tree

2 files changed

+44
-9
lines changed

2 files changed

+44
-9
lines changed

README.md

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ ReporterService.counter('api_requests_total', { endpoint: '/users' });
4040
## Why Choose `nestjs-metrics-client`?
4141

4242
🚀 **No Dependency Injection**
43-
Unlike [@willsoto/nestjs-prometheus](https://github.com/willsoto/nestjs-prometheus), `nestjs-metrics-client` removes the need for cumbersome dependency injection, making your code cleaner and more portable.
43+
Unlike [@willsoto/nestjs-prometheus](https://github.com/willsoto/nestjs-prometheus), `nestjs-metrics-client` removes the need for cumbersome dependency injection, making your code cleaner and more portable.
4444

4545
🌟 **Effortless Integration**
46-
With minimal setup, you can start tracking metrics immediately. No need to configure a service in every file—just use the global `ReporterService`.
46+
With minimal setup, you can start tracking metrics immediately. No need to configure a service in every file—just use the global `ReporterService`.
4747

4848
🎯 **Focus on Simplicity**
49-
Designed for developers who want powerful metrics without the complexity of managing dependencies or boilerplate code.
49+
Designed for developers who want powerful metrics without the complexity of managing dependencies or boilerplate code.
5050

5151
---
5252

@@ -63,6 +63,7 @@ import { ReporterModule } from 'nestjs-metrics-client';
6363
@Module({
6464
imports: [
6565
ReporterModule.forRoot({
66+
// Default metrics are disabled by default, set to true to enable.
6667
defaultMetricsEnabled: true,
6768
defaultLabels: {
6869
app: 'my-app',
@@ -86,7 +87,7 @@ async function bootstrap() {
8687
const app = await NestFactory.create(AppModule);
8788

8889
// Initialize the global reporter
89-
ReporterService.init(app.get(MetricsService) );
90+
ReporterService.init(app.get(MetricsService));
9091

9192
await app.listen(3000);
9293
}
@@ -126,7 +127,7 @@ The global static service for reporting metrics:
126127
|--------------|-----------------------------|-------------------------------------------------------------|
127128
| `init()` | Initialize the reporter | `metricsService: MetricsService` |
128129
| `counter()` | Increment a counter metric | `key: string, labels?: Record<string, string | number>` |
129-
| `gauge()` | Set a gauge value | `key: string, value: number, labels?: Record<string, string | number>` |
130+
| `gauge()` | Set a gauge value | `key: string, value: number, labels?: Record<string, string | number>` |
130131
| `histogram()`| Record a histogram value | `key: string, value: number, labels?: Record<string, string | number>, buckets?: number[]` |
131132
| `summary()` | Record a summary value | `key: string, value: number, labels?: Record<string, string | number>, percentiles?: number[]` |
132133

@@ -136,7 +137,7 @@ The global static service for reporting metrics:
136137

137138
| Option | Type | Default | Description |
138139
|-------------------------|----------------------------|------------|-----------------------------------------------|
139-
| `defaultMetricsEnabled` | `boolean` | `true` | Enable collection of default metrics |
140+
| `defaultMetricsEnabled` | `boolean` | `false` | Enable collection of default metrics |
140141
| `defaultLabels` | `Record<string, string>` | `{}` | Labels automatically added to all metrics |
141142

142143
#### `ReporterModule.forRootAsync(options)`
@@ -156,6 +157,40 @@ ReporterModule.forRootAsync({
156157

157158
---
158159

160+
## Release
161+
162+
This package uses semantic versioning via commit messages:
163+
164+
### Version Bumping Commits
165+
```bash
166+
# Patch Release (1.0.X)
167+
fix: message # Bug fixes
168+
perf: message # Performance improvements
169+
170+
# Minor Release (1.X.0)
171+
feat: message # New features
172+
173+
# Major Release (X.0.0)
174+
feat!: message # Breaking change
175+
fix!: message # Breaking change
176+
BREAKING CHANGE: message # Breaking change anywhere in the commit body
177+
```
178+
179+
### Non-Version Bumping Commits
180+
Only these specific types are allowed:
181+
```bash
182+
build: message # Changes to build system or dependencies
183+
chore: message # Maintenance tasks
184+
ci: message # CI configuration files and scripts
185+
docs: message # Documentation only
186+
refactor: message # Neither fixes a bug nor adds a feature
187+
style: message # Code style (formatting, semicolons, etc)
188+
test: message # Adding or correcting tests
189+
```
190+
191+
Any other prefix will cause the commit to be ignored by semantic-release and won't appear anywhere in release notes.
192+
193+
---
159194
## Contributing
160195

161196
Contributions are welcome! Please check out our [Contributing Guide](CONTRIBUTING.md) to get started.
@@ -166,4 +201,4 @@ Contributions are welcome! Please check out our [Contributing Guide](CONTRIBUTIN
166201

167202
This project is licensed under the Apache License, Version 2.0 - see the [LICENSE](LICENSE) file for details.
168203

169-
---
204+
---

src/reporter/reporter.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class ReporterModule {
1515
registry.setDefaultLabels( config.defaultLabels );
1616
}
1717

18-
if ( config.defaultMetricsEnabled !== false ) {
18+
if ( config.defaultMetricsEnabled === true ) {
1919
collectDefaultMetrics( { register: registry } );
2020
}
2121

@@ -57,7 +57,7 @@ export class ReporterModule {
5757
registry.setDefaultLabels( config.defaultLabels );
5858
}
5959

60-
if ( config.defaultMetricsEnabled !== false ) {
60+
if ( config.defaultMetricsEnabled === true ) {
6161
collectDefaultMetrics( { register: registry } );
6262
}
6363

0 commit comments

Comments
 (0)