Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add diagnostics endpoint for flags #7417

Merged
merged 4 commits into from
May 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cmd/utils/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ func (s *DirectoryString) Set(value string) error {
return nil
}

func (s *DirectoryString) Get() any {
return s.String()
}

var (
_ cli.Flag = (*DirectoryFlag)(nil)
_ cli.RequiredFlag = (*DirectoryFlag)(nil)
Expand Down
23 changes: 23 additions & 0 deletions diagnostics/CHANGELOG.md
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)
23 changes: 23 additions & 0 deletions diagnostics/flags.go
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))
}
}
2 changes: 1 addition & 1 deletion diagnostics/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/ledgerwatch/erigon/params"
)

const Version = 1
const Version = 2

func SetupVersionAccess() {
http.HandleFunc("/debug/metrics/version", func(w http.ResponseWriter, r *http.Request) {
Expand Down
1 change: 1 addition & 0 deletions turbo/debug/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ func Setup(ctx *cli.Context) error {
diagnostics.SetupLogsAccess(ctx)
diagnostics.SetupDbAccess(ctx)
diagnostics.SetupCmdLineAccess()
diagnostics.SetupFlagsAccess(ctx)
diagnostics.SetupVersionAccess()
diagnostics.SetupBlockBodyDownload()
}
Expand Down