Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aos
GitHub Repository: aos/grafana-agent
Path: blob/main/component/otelcol/internal/featuregate/install.go
4096 views
1
// Package featuregate automatically enables upstream feature gates that
2
// otelcol components require. The package must be imported for the feature
3
// gates to be enabled.
4
package featuregate
5
6
import (
7
"os"
8
9
"go.opentelemetry.io/collector/featuregate"
10
11
_ "go.opentelemetry.io/collector/obsreport" // telemetry.useOtelForInternalMetrics
12
)
13
14
// TODO(rfratto): this package should be updated occasionally to remove feature
15
// gates which no longer exist.
16
//
17
// Once all feature gates are removed, this package can be removed as well.
18
19
func init() {
20
_ = enableFeatureGates(featuregate.GetRegistry())
21
}
22
23
func enableFeatureGates(reg *featuregate.Registry) error {
24
// TODO(marctc): temporary workaround to fix issue with traces' metrics not
25
// being collected even flow is not enabled.
26
return reg.Apply(map[string]bool{
27
"telemetry.useOtelForInternalMetrics": isFlowRunning(),
28
})
29
}
30
31
func isFlowRunning() bool {
32
key, _ := os.LookupEnv("AGENT_MODE")
33
34
switch key {
35
case "flow":
36
return true
37
default:
38
return false
39
}
40
}
41
42