-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
cell.go
53 lines (42 loc) · 1.45 KB
/
cell.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
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Cilium
package metrics
import (
"github.com/spf13/pflag"
"github.com/cilium/cilium/pkg/hive/cell"
)
const (
// OperatorPrometheusServeAddr IP:Port on which to serve prometheus metrics
// (pass ":<port>" to bind on all interfaces).
OperatorPrometheusServeAddr = "operator-prometheus-serve-addr"
)
// Cell provides the modular metrics registry, metric HTTP server and
// legacy metrics cell for the operator.
var Cell = cell.Module(
"operator-metrics",
"Operator Metrics",
cell.Config(defaultConfig),
cell.Invoke(registerMetricsManager),
)
// Config contains the configuration for the operator-metrics cell.
type Config struct {
OperatorPrometheusServeAddr string
}
var defaultConfig = Config{
// default server address for operator metrics
OperatorPrometheusServeAddr: ":9963",
}
func (def Config) Flags(flags *pflag.FlagSet) {
flags.String(OperatorPrometheusServeAddr, def.OperatorPrometheusServeAddr, "Address to serve Prometheus metrics")
}
// SharedConfig contains the configuration that is shared between
// this module and others.
// Metrics cell needs to know if GatewayAPI is enabled in order to use
// the same Registry as controller-runtime and avoid to expose
// multiple metrics endpoints or servers.
type SharedConfig struct {
// EnableMetrics is set to true if operator metrics are enabled
EnableMetrics bool
// EnableGatewayAPI enables support of Gateway API
EnableGatewayAPI bool
}