Skip to content

Commit 0eb159e

Browse files
authored
fix(internal): Make tracing configurable (#2708)
Signed-off-by: cryptodj413 <shinjirohara2@gmail.com>
1 parent bb8a482 commit 0eb159e

4 files changed

Lines changed: 30 additions & 5 deletions

File tree

dingo.yaml.example

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,19 @@ metricsPort: 12798
161161
# CLI: --debug-port Env: DINGO_DEBUG_PORT
162162
debugPort: 0
163163

164+
# Enable OpenTelemetry tracing. Disabled by default: with no collector
165+
# listening, the OTLP exporter logs noisy connection errors. When enabled,
166+
# spans are sent via OTLP HTTP; configure the destination with the standard
167+
# OTEL_EXPORTER_OTLP_* env vars documented for
168+
# go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp.
169+
# CLI: --tracing Env: DINGO_TRACING_ENABLED
170+
tracing: false
171+
172+
# Export traces to stdout instead of OTLP. Requires tracing to also be
173+
# enabled. Mostly useful for local debugging.
174+
# CLI: --tracing-stdout Env: DINGO_TRACING_STDOUT
175+
tracingStdout: false
176+
164177
# Internal/private address to bind for listening for Ouroboros NtC
165178
privateBindAddr: "127.0.0.1"
166179

internal/config/config.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,17 @@ type Config struct {
382382
DebugPort uint `yaml:"debugPort" envconfig:"DINGO_DEBUG_PORT"`
383383
IntersectTip bool `yaml:"intersectTip" split_words:"true"`
384384
ValidateHistorical bool `yaml:"validateHistorical" split_words:"true"`
385-
RunMode RunMode `yaml:"runMode" envconfig:"DINGO_RUN_MODE"`
386-
StartEra StartEra `yaml:"startEra" envconfig:"DINGO_START_ERA"`
387-
ImmutableDbPath string `yaml:"immutableDbPath" envconfig:"DINGO_IMMUTABLE_DB_PATH"`
385+
// Tracing enables OpenTelemetry tracing. Disabled by default: with no
386+
// collector listening, the OTLP exporter logs noisy connection errors.
387+
// Spans are sent via OTLP HTTP; configure the destination with the
388+
// standard OTEL_EXPORTER_OTLP_* env vars.
389+
Tracing bool `yaml:"tracing" envconfig:"DINGO_TRACING_ENABLED"`
390+
// TracingStdout redirects spans to stdout instead of OTLP. Requires
391+
// Tracing to also be enabled. Mostly useful for local debugging.
392+
TracingStdout bool `yaml:"tracingStdout" envconfig:"DINGO_TRACING_STDOUT"`
393+
RunMode RunMode `yaml:"runMode" envconfig:"DINGO_RUN_MODE"`
394+
StartEra StartEra `yaml:"startEra" envconfig:"DINGO_START_ERA"`
395+
ImmutableDbPath string `yaml:"immutableDbPath" envconfig:"DINGO_IMMUTABLE_DB_PATH"`
388396
// Database worker pool tuning (worker count and task queue size)
389397
DatabaseWorkers int `yaml:"databaseWorkers" envconfig:"DINGO_DATABASE_WORKERS"`
390398
DatabaseQueueSize int `yaml:"databaseQueueSize" envconfig:"DINGO_DATABASE_QUEUE_SIZE"`
@@ -704,6 +712,8 @@ var globalConfig = &Config{
704712
SocketPath: "dingo.socket",
705713
IntersectTip: false,
706714
ValidateHistorical: false,
715+
Tracing: false,
716+
TracingStdout: false,
707717
Network: "preview",
708718
NetworkMagic: 0,
709719
MetricsPort: 12798,

internal/config/flags.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ var flagSpecs = []flagSpec{
6161
stringFlag("ImmutableDbPath", "immutable-db-path", "", "path to ImmutableDB for load mode"),
6262
boolFlag("IntersectTip", "intersect-tip", "start from current tip"),
6363
boolFlag("ValidateHistorical", "validate-historical", "validate historical blocks"),
64+
boolFlag("Tracing", "tracing", "enable OpenTelemetry tracing (configure destination with OTEL_EXPORTER_OTLP_* env vars)"),
65+
boolFlag("TracingStdout", "tracing-stdout", "export traces to stdout instead of OTLP (requires --tracing; for debugging)"),
6466

6567
// Networking
6668
validatedStringFlag("Network", "network", "n", "Cardano network name (e.g. preview, preprod, mainnet)", ValidateNetworkName),

internal/node/node.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,8 @@ func Run(cfg *config.Config, logger *slog.Logger) error {
370370
dingo.WithShutdownTimeout(shutdownTimeout),
371371
// Enable metrics with default prometheus registry
372372
dingo.WithPrometheusRegistry(prometheus.DefaultRegisterer),
373-
// TODO: make this configurable (#387)
374-
// dingo.WithTracing(true),
373+
dingo.WithTracing(cfg.Tracing),
374+
dingo.WithTracingStdout(cfg.TracingStdout),
375375
dingo.WithTopologyConfig(config.GetTopologyConfig()),
376376
dingo.WithDatabaseWorkerPoolConfig(ledger.DatabaseWorkerPoolConfig{
377377
WorkerPoolSize: cfg.DatabaseWorkers,

0 commit comments

Comments
 (0)