forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Heartbeat] Reimplement Scheduler / Fix recurring tasks with limit (e…
…lastic#14569) Fixes elastic#14567 Took the opportunity to re-implement the heartbeat scheduler with an eye toward clarity as the original code was tricky to debug. While there are more LOC here, there are also additional tests and some additional features that made sense to include as well. The net result IMHO is a reduction in complexity. This changes the behavior to start monitors using the @every X syntax immediately, rather than waiting X duration. So, we'll call this both an enhancement and a bugfix. Structurally the code now relies more heavily on the go runtime scheduler, in combination with a new throttler package which helps constrain the maximum number of executing goroutines run by the scheduler in an efficient way. There may be another way to build the throttler using buffered go routines, but I'm on the fence whether reworking it is worth it in any way.
- Loading branch information
Showing
16 changed files
with
658 additions
and
405 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Licensed to Elasticsearch B.V. under one or more contributor | ||
// license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright | ||
// ownership. Elasticsearch B.V. licenses this file to you under | ||
// the Apache License, Version 2.0 (the "License"); you may | ||
// not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package hbregistry | ||
|
||
import "github.com/elastic/beats/libbeat/monitoring" | ||
|
||
// StatsRegistry contains a singleton instance of the heartbeat stats registry | ||
var StatsRegistry = monitoring.Default.NewRegistry("heartbeat") | ||
|
||
// SchedulerRegistry holds scheduler stats | ||
var SchedulerRegistry = StatsRegistry.NewRegistry("scheduler") | ||
|
||
// TelemetryRegistry contains a singleton instance of the heartbeat telemetry registry | ||
var TelemetryRegistry = monitoring.GetNamespace("state").GetRegistry().NewRegistry("heartbeat") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.