Skip to content

Commit

Permalink
algod: Async telemetry start
Browse files Browse the repository at this point in the history
  • Loading branch information
urtho committed Dec 2, 2024
1 parent e7e3e9e commit 5053e2d
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions cmd/algod/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Check warning on line 238 in cmd/algod/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/algod/main.go#L237-L238

Added lines #L237 - L238 were not covered by tests
// Try to enable remote telemetry now when URI is defined. Skip for DNS based telemetry.
err := log.EnableTelemetry(telemetryConfig)

Check warning on line 240 in cmd/algod/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/algod/main.go#L240

Added line #L240 was not covered by tests
// Error occurs only if URI is defined and we need to retry later
if err == nil {

Check warning on line 242 in cmd/algod/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/algod/main.go#L242

Added line #L242 was not covered by tests
// Remote telemetry enabled or empty static URI, stop retrying
return

Check warning on line 244 in cmd/algod/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/algod/main.go#L244

Added line #L244 was not covered by tests
}
}()
}
fmt.Fprintln(os.Stdout, "error creating telemetry hook", err)

Check warning on line 246 in cmd/algod/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/algod/main.go#L246

Added line #L246 was not covered by tests
// Try to reenable every minute
time.Sleep(time.Minute)

Check warning on line 248 in cmd/algod/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/algod/main.go#L248

Added line #L248 was not covered by tests
}
}()
}
}

Expand Down

0 comments on commit 5053e2d

Please sign in to comment.