forked from DataDog/datadog-agent
-
Notifications
You must be signed in to change notification settings - Fork 2
/
loader.go
63 lines (51 loc) · 2.23 KB
/
loader.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.
package common
import (
"context"
"path/filepath"
"github.com/StackVista/stackstate-agent/pkg/autodiscovery/scheduler"
"github.com/StackVista/stackstate-agent/pkg/collector"
lsched "github.com/StackVista/stackstate-agent/pkg/logs/scheduler"
lstatus "github.com/StackVista/stackstate-agent/pkg/logs/status"
"github.com/StackVista/stackstate-agent/pkg/tagger"
"github.com/StackVista/stackstate-agent/pkg/tagger/collectors"
"github.com/StackVista/stackstate-agent/pkg/tagger/local"
"github.com/StackVista/stackstate-agent/pkg/util/log"
"github.com/StackVista/stackstate-agent/pkg/workloadmeta"
// register all workloadmeta collectors
_ "github.com/StackVista/stackstate-agent/pkg/workloadmeta/collectors"
)
// LoadComponents configures several common Agent components:
// tagger, collector, scheduler and autodiscovery
func LoadComponents(confdPath string) {
workloadmeta.GetGlobalStore().Start(context.Background())
// start the tagger. must be done before autodiscovery, as it needs to
// be the first subscribed to metadata store to avoid race conditions.
tagger.SetDefaultTagger(local.NewTagger(collectors.DefaultCatalog))
if err := tagger.Init(); err != nil {
log.Errorf("failed to start the tagger: %s", err)
}
// create the Collector instance and start all the components
// NOTICE: this will also setup the Python environment, if available
Coll = collector.NewCollector(GetPythonPaths()...)
// creating the meta scheduler
metaScheduler := scheduler.NewMetaScheduler()
// registering the check scheduler
metaScheduler.Register("check", collector.InitCheckScheduler(Coll))
// registering the logs scheduler
if lstatus.Get().IsRunning {
metaScheduler.Register("logs", lsched.GetScheduler())
}
// setup autodiscovery
confSearchPaths := []string{
confdPath,
filepath.Join(GetDistPath(), "conf.d"),
"",
}
// setup autodiscovery. must be done after the tagger is initialized
// because of subscription to metadata store.
AC = setupAutoDiscovery(confSearchPaths, metaScheduler)
}