go-ethereum/node
Barnabas Busa da34eb59fd
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Keeper Build (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run
node: default OpenTelemetry SampleRatio to 1.0 (#34948)
## Summary

The `--rpc.telemetry.sample-ratio` flag declares `Value: 1.0` and `geth
--help` advertises `(default: 1)`. In practice, however, omitting the
flag produces a sample ratio of `0`, causing
`sdktrace.TraceIDRatioBased(0)` to drop 100% of spans. Users who enable
`--rpc.telemetry` see the `OpenTelemetry trace export enabled` log line
and a clean startup, but no traces ever leave the process.

The root cause is the interaction between two pieces of code:

1. `cmd/utils/flags.go:setOpenTelemetry` (added in #34062) only copies
the flag value when `ctx.IsSet(...)` returns true:

   ```go
   if ctx.IsSet(RPCTelemetrySampleRatioFlag.Name) {
       tcfg.SampleRatio = ctx.Float64(RPCTelemetrySampleRatioFlag.Name)
   }
   ```

That is the right pattern for "don't clobber a config-file value with
the CLI default," but it implies that something else must initialise the
field when neither source sets it.

2. `node/defaults.go:DefaultConfig` never initialises
`OpenTelemetry.SampleRatio`, leaving it at the float64 zero value.

The result for the common CLI-only user (no TOML config) is `SampleRatio
= 0` → every span is silently dropped, despite the documented default of
1.

## Change

Seed `OpenTelemetry: OpenTelemetryConfig{SampleRatio: 1.0}` in
`node.DefaultConfig` so the documented default matches runtime behavior
and the `ctx.IsSet` guard in `setOpenTelemetry` continues to do what it
was designed to do.
2026-05-13 14:08:21 -05:00
..
api.go node: fix vhosts for adminAPI (#32488) 2025-08-25 09:52:54 +08:00
api_test.go build: update to golangci-lint 1.61.0 (#30587) 2024-10-14 19:25:22 +02:00
config.go cmd/geth, internal/telemetry: wire OpenTelemetry tracing via CLI flags (#33484) 2026-02-14 01:02:10 +01:00
config_test.go build: replace tenv linter with usetesting (#31172) 2025-02-21 13:36:18 +01:00
database.go node: do not double-wrap KV stores (#32089) 2025-06-27 15:27:52 +08:00
defaults.go node: default OpenTelemetry SampleRatio to 1.0 (#34948) 2026-05-13 14:08:21 -05:00
doc.go build: upgrade to go 1.19 (#25726) 2022-09-10 13:25:40 +02:00
endpoints.go node, rpc: add ReadHeaderTimeout config option (#25338) 2022-08-03 16:50:12 +02:00
errors.go node: remove unused err var (#32398) 2025-08-13 15:08:23 +08:00
jwt_auth.go node, rpc: add JWT auth support in client (#24911) 2022-09-02 17:40:41 +02:00
jwt_handler.go node: change JWT error status to 401 Unauthorized (#25629) 2022-08-30 15:25:02 +02:00
lifecycle.go node: refactor package node (#21105) 2020-08-03 19:40:46 +02:00
node.go eth,node: replace the deprecated TypeMux with Feed (#32585) 2026-05-08 10:12:46 +08:00
node_auth_test.go all: replace path.Join with filepath.Join (#29479) 2024-04-08 12:29:49 +03:00
node_example_test.go build: upgrade to go 1.19 (#25726) 2022-09-10 13:25:40 +02:00
node_test.go build: update to golangci-lint 1.61.0 (#30587) 2024-10-14 19:25:22 +02:00
rpcstack.go node: disable http2 for auth API (#33922) 2026-03-03 00:02:44 +01:00
rpcstack_test.go node: http2 for JSON-RPC API (#33812) 2026-02-12 10:33:12 +01:00
utils_test.go all: remove version field from rpc.API 2022-06-27 12:39:46 +02:00