Skip to content

Commit

Permalink
Merge branch 'master' into remove-3074
Browse files Browse the repository at this point in the history
  • Loading branch information
holgerd77 committed Aug 13, 2024
2 parents 527784e + 699cde2 commit 018064d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
4 changes: 1 addition & 3 deletions packages/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ dist/bin/cli.js --d
## Metrics
The client can optionally collect metrics using the Prometheus metrics platform and expose them via an HTTP endpoint with the following CLI flags.
The current metrics that are reported by the client can be found [here](./src/util//metrics.ts).
The current metrics that are reported by the client can be found at the default port and route: `localhost:8000/metrics`.
```sh
# npm installation
Expand All @@ -318,8 +318,6 @@ ethereumjs --prometheus
npm run client:start:ts -- --prometheus --prometheusPort=9123
```
Note: The Prometheus endpoint runs on port 8000 by default
## API
[API Reference](./docs/README.md)
Expand Down
14 changes: 10 additions & 4 deletions packages/client/bin/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1122,10 +1122,16 @@ async function run() {
const reqUrl = new url.URL(req.url, `http://${req.headers.host}`)
const route = reqUrl.pathname

if (route === '/metrics') {
// Return all metrics in the Prometheus exposition format
res.setHeader('Content-Type', register.contentType)
res.end(await register.metrics())
switch (route) {
case '/metrics':
// Return all metrics in the Prometheus exposition format
res.setHeader('Content-Type', register.contentType)
res.end(await register.metrics())
break
default:
res.statusCode = 404
res.end('Not found')
return
}
})
// Start the HTTP server which exposes the metrics on http://localhost:${args.prometheusPort}/metrics
Expand Down

0 comments on commit 018064d

Please sign in to comment.