Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion cmd/algod/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,17 @@ func run() int {

// Send a heartbeat event every 10 minutes as a sign of life
go func() {
ticker := time.NewTicker(10 * time.Minute)
var interval time.Duration
defaultIntervalSecs := config.GetDefaultLocal().HeartbeatUpdateInterval
switch {
case cfg.HeartbeatUpdateInterval <= 0: // use default
interval = time.Second * time.Duration(defaultIntervalSecs)
case cfg.HeartbeatUpdateInterval < 60: // min frequency 1 minute
interval = time.Minute
Comment on lines +352 to +353
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be an error instead? Might be easier than having to document / explain why the units change depending on how big the number is.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, the units could be minutes, that way 1 is just the smallest non-disabled value.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the units don't change ... they are still seconds..?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

being converted into a time.Duration

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes thats more reasonable. I read that as time.Minute * interval

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could still be confusing. I'm imagining a local test where I set it to 5 to get some more information, then have to switch tasks to figure out why the events aren't being sent out.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am assuming no one wants to set it lower than a minute, that it is more valuable to prevent this type of usage, and that user would use the /metrics endpoint instead

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think changing units to minutes would be a slightly better option than changing the config at runtime

Copy link
Copy Markdown
Contributor Author

@cce cce Jan 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only chose it to match the telemetry update interval configuration units that were already being used:

	// PeerConnectionsUpdateInterval defines the interval at which the peer connections information is being sent to the
	// telemetry ( when enabled ). Defined in seconds.
	PeerConnectionsUpdateInterval int `version[5]:"3600"`

default:
interval = time.Second * time.Duration(cfg.HeartbeatUpdateInterval)
}
ticker := time.NewTicker(interval)
defer ticker.Stop()

sendHeartbeat := func() {
Expand Down
4 changes: 4 additions & 0 deletions config/localTemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ type Local struct {
// telemetry ( when enabled ). Defined in seconds.
PeerConnectionsUpdateInterval int `version[5]:"3600"`

// HeartbeatUpdateInterval defines the interval at which the heartbeat information is being sent to the
// telemetry ( when enabled ). Defined in seconds. Minimum value is 60.
HeartbeatUpdateInterval int `version[27]:"600"`

// EnableProfiler enables the go pprof endpoints, should be false if
// the algod api will be exposed to untrusted individuals
EnableProfiler bool `version[0]:"false"`
Expand Down
1 change: 1 addition & 0 deletions config/local_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ var defaultLocal = Local{
ForceFetchTransactions: false,
ForceRelayMessages: false,
GossipFanout: 4,
HeartbeatUpdateInterval: 600,
IncomingConnectionsLimit: 800,
IncomingMessageFilterBucketCount: 5,
IncomingMessageFilterBucketSize: 512,
Expand Down
1 change: 1 addition & 0 deletions installer/config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"ForceFetchTransactions": false,
"ForceRelayMessages": false,
"GossipFanout": 4,
"HeartbeatUpdateInterval": 600,
"IncomingConnectionsLimit": 800,
"IncomingMessageFilterBucketCount": 5,
"IncomingMessageFilterBucketSize": 512,
Expand Down
1 change: 1 addition & 0 deletions test/testdata/configs/config-v27.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"ForceFetchTransactions": false,
"ForceRelayMessages": false,
"GossipFanout": 4,
"HeartbeatUpdateInterval": 600,
"IncomingConnectionsLimit": 800,
"IncomingMessageFilterBucketCount": 5,
"IncomingMessageFilterBucketSize": 512,
Expand Down