Skip to content

Commit 462d32d

Browse files
feat: enable conditional debug logging for k8s sidecar healthcheck container
1 parent 1f7362d commit 462d32d

4 files changed

Lines changed: 6 additions & 1 deletion

File tree

images/go_chains_hc/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ On each `/readyz` request, the sidecar runs a configurable set of checks against
2323
| `NODE_PASS` | no || RPC auth password |
2424
| `CHECKS` | no | `blockdownload` | Comma-separated list of checks to run (`blockdownload, txindex, connectioncount`) |
2525
| `MIN_CONNECTIONS` | no | `8` | Minimum peer connections required for the `connectioncount` check |
26+
| `DEBUG` | no | `false` | Enable debug logs |
2627

2728

2829
### Running Locally

images/go_chains_hc/checks.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ func doRPC(ctx context.Context, client *http.Client, cfg Config, method string)
5959
return nil, fmt.Errorf("read response: %w", err)
6060
}
6161

62-
logger.Debug("rpc response", "method", method, "body", string(data))
62+
if cfg.Debug {
63+
logger.Debug("rpc response", "method", method, "body", string(data))
64+
}
6365

6466
var envelope struct {
6567
Result json.RawMessage `json:"result"`

images/go_chains_hc/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ type Config struct {
1818
Checks []string
1919
Addr string
2020
MinConnections int
21+
Debug bool
2122
}
2223

2324
const MIN_CONNECTIONS = 8
@@ -57,6 +58,7 @@ func configFromEnv() (Config, error) {
5758
Checks: checks,
5859
Addr: ":8080",
5960
MinConnections: minConns,
61+
Debug: os.Getenv("DEBUG") == "true",
6062
}, nil
6163
}
6264

-8.55 MB
Binary file not shown.

0 commit comments

Comments
 (0)