Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add required comments to heartbeat monitors #8316

Merged
merged 1 commit into from
Sep 19, 2018
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
3 changes: 3 additions & 0 deletions heartbeat/monitors/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ func (m *Monitor) makeWatchTasks(monitorPlugin pluginBuilder) error {
return nil
}

// Start starts the monitor's execution using its configured scheduler.
func (m *Monitor) Start() {
m.internalsMtx.Lock()
defer m.internalsMtx.Unlock()
Expand All @@ -228,6 +229,8 @@ func (m *Monitor) Start() {
}
}

// Stop stops the Monitor's execution in its configured scheduler.
// This is safe to call even if the Monitor was never started.
func (m *Monitor) Stop() {
m.internalsMtx.Lock()
defer m.internalsMtx.Unlock()
Expand Down
12 changes: 4 additions & 8 deletions heartbeat/monitors/pluginconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,15 @@
package monitors

import (
"fmt"

"github.com/pkg/errors"

"github.com/elastic/beats/libbeat/common"
)

type PluginDisabledError struct{}

func (e PluginDisabledError) Error() string {
return fmt.Sprintf("Monitor not loaded, plugin is disabled")
}
// ErrPluginDisabled is returned when the monitor plugin is marked as disabled.
var ErrPluginDisabled = errors.New("Monitor not loaded, plugin is disabled")

// MonitorPluginInfo represents the generic configuration options around a monitor plugin.
type MonitorPluginInfo struct {
Type string `config:"type" validate:"required"`
Enabled bool `config:"enabled"`
Expand All @@ -44,7 +40,7 @@ func pluginInfo(config *common.Config) (MonitorPluginInfo, error) {
}

if !mpi.Enabled {
return mpi, PluginDisabledError{}
return mpi, ErrPluginDisabled
}

return mpi, nil
Expand Down