-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add diagnostics endpoint for flags (#7417)
To expose context flags through diagnostic endpoint `/debug/metrics/flags`. The current `/debug/metrics/cmdline` only provides the command run by user. In the case when user runs Erigon using config file, `cmdline`’s info does not truly reflect the ‘launch setting' and flags set that Erigon is running on. ## Example ### Command ``` erigon --datadir /tmp/data --config test.yaml ``` ### Pseudo config file (in yaml) ``` datadir : '/tmp/data' chain : "sepolia" http : true metrics: true private.api.addr : "localhost:9090" http.api : ["eth","debug","net"] ``` ### Output ``` SUCCESS chain=sepolia config=test.yaml datadir=/tmp/data http=true http.api=eth,debug,net metrics=true private.api.addr=localhost:9090 ```
- Loading branch information
Showing
5 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Changelog | ||
|
||
All notable changes to `diagnostics` will be documented in this file. | ||
|
||
## Version 2 | ||
|
||
### Added | ||
|
||
- Introduce `flags` endpoint (#7417) | ||
|
||
### Changed | ||
|
||
- Increment diagnostic version to 2 in `version.go` (#7417) | ||
|
||
## Version 1 | ||
|
||
### Added | ||
|
||
- Introduce diagnostics versioning via `version` endpoint (#7300) | ||
- Introduce `logs/list` and `logs/read` endpoint (#6930) | ||
- Introduce `db/list`, `db/tables` and `db/read` endpoint (#6930) | ||
- Introduce `cmdline` (#7271) | ||
- Introduce `block_body_download` (#7373) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package diagnostics | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"net/http" | ||
|
||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
func SetupFlagsAccess(ctx *cli.Context) { | ||
http.HandleFunc("/debug/metrics/flags", func(w http.ResponseWriter, r *http.Request) { | ||
w.Header().Set("Access-Control-Allow-Origin", "*") | ||
writeFlags(w, ctx) | ||
}) | ||
} | ||
|
||
func writeFlags(w io.Writer, ctx *cli.Context) { | ||
fmt.Fprintf(w, "SUCCESS\n") | ||
for _, flagName := range ctx.FlagNames() { | ||
fmt.Fprintf(w, "%s=%v\n", flagName, ctx.Value(flagName)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters