File tree Expand file tree Collapse file tree 3 files changed +21
-9
lines changed Expand file tree Collapse file tree 3 files changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -8,11 +8,13 @@ import (
8
8
"strings"
9
9
"time"
10
10
11
+ "github.com/prometheus/client_golang/prometheus/promhttp"
11
12
log "github.com/sirupsen/logrus"
12
13
v1 "k8s.io/api/core/v1"
13
14
14
15
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/catalog"
15
16
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/signals"
17
+ "github.com/operator-framework/operator-lifecycle-manager/pkg/metrics"
16
18
olmversion "github.com/operator-framework/operator-lifecycle-manager/pkg/version"
17
19
)
18
20
45
47
version = flag .Bool ("version" , false , "displays olm version" )
46
48
)
47
49
50
+ func init () {
51
+ metrics .RegisterCatalog ()
52
+ }
53
+
48
54
func main () {
49
55
stopCh := signals .SetupSignalHandler ()
50
56
@@ -87,6 +93,10 @@ func main() {
87
93
log .Panicf ("error configuring operator: %s" , err .Error ())
88
94
}
89
95
96
+ http .Handle ("/metrics" , promhttp .Handler ())
97
+ go http .ListenAndServe (":8081" , nil )
98
+
90
99
_ , done := catalogOperator .Run (stopCh )
91
100
<- done
92
101
}
102
+
Original file line number Diff line number Diff line change 8
8
"strings"
9
9
"time"
10
10
11
- "github.com/prometheus/client_golang/prometheus"
11
+ "github.com/prometheus/client_golang/prometheus/promhttp "
12
12
log "github.com/sirupsen/logrus"
13
13
v1 "k8s.io/api/core/v1"
14
14
45
45
)
46
46
47
47
func init () {
48
- metrics .Register ()
48
+ metrics .RegisterOLM ()
49
49
}
50
50
51
51
// main function - entrypoint to OLM operator
@@ -100,12 +100,11 @@ func main() {
100
100
http .HandleFunc ("/healthz" , func (w http.ResponseWriter , r * http.Request ) {
101
101
w .WriteHeader (http .StatusOK )
102
102
})
103
- // TODO: both of the following require vendor updates (add k8s.io/apiserver and update prometheus)
104
- //healthz.InstallHandler(mux) //(less code)
105
- //mux.Handle("/metrics", promhttp.Handler()) //other form is deprecated
106
- http .Handle ("/metrics" , prometheus .Handler ())
107
103
go http .ListenAndServe (":8080" , nil )
108
104
105
+ http .Handle ("/metrics" , promhttp .Handler ())
106
+ go http .ListenAndServe (":8081" , nil )
107
+
109
108
_ , done := operator .Run (stopCh )
110
109
<- done
111
110
}
Original file line number Diff line number Diff line change @@ -129,15 +129,18 @@ var (
129
129
CSVUpgradeCount = prometheus .NewCounter (
130
130
prometheus.CounterOpts {
131
131
Name : "csv_upgrade_count" ,
132
- Help : "Monotonic count of catalog sources " ,
132
+ Help : "Monotonic count of CSV upgrades " ,
133
133
},
134
134
)
135
135
)
136
136
137
- func Register () {
137
+ func RegisterOLM () {
138
138
prometheus .MustRegister (csvCount )
139
+ prometheus .MustRegister (CSVUpgradeCount )
140
+ }
141
+
142
+ func RegisterCatalog () {
139
143
prometheus .MustRegister (installPlanCount )
140
144
prometheus .MustRegister (subscriptionCount )
141
145
prometheus .MustRegister (catalogSourceCount )
142
- prometheus .MustRegister (CSVUpgradeCount )
143
146
}
You can’t perform that action at this time.
0 commit comments