Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into block-consensus-met…
Browse files Browse the repository at this point in the history
…hods-refactoring
  • Loading branch information
acolytec3 committed Aug 13, 2024
2 parents be12a25 + 699cde2 commit ad688cd
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 ad688cd

Please sign in to comment.