From e7e3e9ea68dcdbb2496f8ac21dc484a53fa889f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pier=C5=9Bcionek?= Date: Thu, 28 Nov 2024 14:57:27 +0100 Subject: [PATCH 1/2] algod: Add static EnableTelemetry retry --- cmd/algod/main.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cmd/algod/main.go b/cmd/algod/main.go index 306435ad94..57e670b8bc 100644 --- a/cmd/algod/main.go +++ b/cmd/algod/main.go @@ -232,9 +232,23 @@ func run() int { telemetryConfig.SessionGUID = *sessionGUID } } + // Try to enable remote telemetry now when URI is defined. Skip for DNS based telemetry. err = log.EnableTelemetry(telemetryConfig) if err != nil { fmt.Fprintln(os.Stdout, "error creating telemetry hook", err) + // Error occurs only if URI is defined and we need to retry later + go func() { + for { + // Try to reenable every minute + time.Sleep(time.Minute) + err := log.EnableTelemetry(telemetryConfig) + if err == nil { + // Remote telemetry enabled, stop retrying + return + } + fmt.Fprintln(os.Stdout, "error creating telemetry hook", err) + } + }() } } } From 5053e2d937f13295d196bca7f2753ae51eb53490 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pier=C5=9Bcionek?= Date: Mon, 2 Dec 2024 20:50:00 +0100 Subject: [PATCH 2/2] algod: Async telemetry start --- cmd/algod/main.go | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/cmd/algod/main.go b/cmd/algod/main.go index 57e670b8bc..ff197b91df 100644 --- a/cmd/algod/main.go +++ b/cmd/algod/main.go @@ -232,24 +232,22 @@ func run() int { telemetryConfig.SessionGUID = *sessionGUID } } - // Try to enable remote telemetry now when URI is defined. Skip for DNS based telemetry. - err = log.EnableTelemetry(telemetryConfig) - if err != nil { - fmt.Fprintln(os.Stdout, "error creating telemetry hook", err) - // Error occurs only if URI is defined and we need to retry later - go func() { - for { - // Try to reenable every minute - time.Sleep(time.Minute) - err := log.EnableTelemetry(telemetryConfig) - if err == nil { - // Remote telemetry enabled, stop retrying - return - } - fmt.Fprintln(os.Stdout, "error creating telemetry hook", err) + + // Remote telemetry init loop + go func() { + for { + // Try to enable remote telemetry now when URI is defined. Skip for DNS based telemetry. + err := log.EnableTelemetry(telemetryConfig) + // Error occurs only if URI is defined and we need to retry later + if err == nil { + // Remote telemetry enabled or empty static URI, stop retrying + return } - }() - } + fmt.Fprintln(os.Stdout, "error creating telemetry hook", err) + // Try to reenable every minute + time.Sleep(time.Minute) + } + }() } }