Skip to content

Commit bc90699

Browse files
committed
document error handling
1 parent aedbd65 commit bc90699

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,13 @@ const metricsConsumer = new PrometheusConsumer({ client: promClient });
5252

5353
### Step 2.
5454

55-
Pipe the metrics output stream directly into our consumer
55+
Pipe the metrics output stream directly into our consumer making sure to add an error handler to avoid uncaught exceptions.
5656

5757
```js
5858
const client = new MetricsClient();
5959

60+
metricsConsumer.on('error', err => console.error(err));
61+
6062
client.pipe(metricsConsumer);
6163
```
6264

@@ -84,12 +86,18 @@ app.get('/metrics', (req, res) => {
8486

8587
Create a new metrics consumer instance ready to have metrics piped into it.
8688

87-
_Example_
89+
_Examples_
8890

8991
```js
9092
const consumer = new PrometheusConsumer({ client: promClient });
9193
```
9294

95+
remember to add an error handler to the consumer to avoid uncaught exception errors.
96+
97+
```js
98+
consumer.on('error', err => console.error(err));
99+
```
100+
93101
#### options
94102

95103
| name | description | type | default |

0 commit comments

Comments
 (0)