Skip to content

Commit

Permalink
Changed scrape method to collect
Browse files Browse the repository at this point in the history
  • Loading branch information
naueramant committed Sep 17, 2020
1 parent d454063 commit b5b1a20
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import * as prom from "socket.io-prometheus-metrics";
const server = http.createServer();
const io = io(server);

prom.scrape(io);
prom.collect(io);

server.listen(3000);
```
Expand All @@ -32,23 +32,21 @@ Metrics is then available at `localhost:9090/metrics`.
Prometheus default metrics can also be enabled by setting the `collectDefaultMetrics` option to `true`

```ts
prom.scrape(io, {
prom.collect(io, {
collectDefaultMetrics: true,
});
```

If you wish to serve the metrics yourself the `createServer` options can be set to `false` and metrics can be collected from the register

```ts
const scraper = prom.scrape(io, {
const collector = prom.collect(io, {
createServer: false,
});

const metrics = scraper.getMetrics();
const metrics = collector.getMetrics();
```

If `createServer: false` then `scraper.server` is `null`.

## Options

| Option | Default | Description |
Expand Down Expand Up @@ -90,7 +88,7 @@ You can disable this functionality by providing `checkForNewNamespaces` option w
For example:

```ts
prometheus.metrics(io, {
prom.collect(io, {
checkForNewNamespaces: false,
});
```
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as prom from "prom-client";

import { Metrics } from "./metrics";

export function metrics(
export function collect(
ioServer: io.Server,
options?: IMetricsOptions
): SocketIOMetrics {
Expand Down

0 comments on commit b5b1a20

Please sign in to comment.