Skip to content

Commit 63aa1e1

Browse files
Merge pull request #637 from jpeeler/metrics-fix
fix(metrics): remove resources that aren't updated
2 parents 4748249 + cc26f47 commit 63aa1e1

File tree

13 files changed

+1506
-23
lines changed

13 files changed

+1506
-23
lines changed

cmd/catalog/main.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ import (
88
"strings"
99
"time"
1010

11+
"github.com/prometheus/client_golang/prometheus/promhttp"
1112
log "github.com/sirupsen/logrus"
1213
v1 "k8s.io/api/core/v1"
1314

1415
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/catalog"
1516
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/signals"
17+
"github.com/operator-framework/operator-lifecycle-manager/pkg/metrics"
1618
olmversion "github.com/operator-framework/operator-lifecycle-manager/pkg/version"
1719
)
1820

@@ -45,6 +47,10 @@ var (
4547
version = flag.Bool("version", false, "displays olm version")
4648
)
4749

50+
func init() {
51+
metrics.RegisterCatalog()
52+
}
53+
4854
func main() {
4955
stopCh := signals.SetupSignalHandler()
5056

@@ -87,6 +93,10 @@ func main() {
8793
log.Panicf("error configuring operator: %s", err.Error())
8894
}
8995

96+
http.Handle("/metrics", promhttp.Handler())
97+
go http.ListenAndServe(":8081", nil)
98+
9099
_, done := catalogOperator.Run(stopCh)
91100
<-done
92101
}
102+

cmd/olm/main.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"strings"
99
"time"
1010

11-
"github.com/prometheus/client_golang/prometheus"
11+
"github.com/prometheus/client_golang/prometheus/promhttp"
1212
log "github.com/sirupsen/logrus"
1313
v1 "k8s.io/api/core/v1"
1414

@@ -45,7 +45,7 @@ var (
4545
)
4646

4747
func init() {
48-
metrics.Register()
48+
metrics.RegisterOLM()
4949
}
5050

5151
// main function - entrypoint to OLM operator
@@ -100,12 +100,11 @@ func main() {
100100
http.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
101101
w.WriteHeader(http.StatusOK)
102102
})
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())
107103
go http.ListenAndServe(":8080", nil)
108104

105+
http.Handle("/metrics", promhttp.Handler())
106+
go http.ListenAndServe(":8081", nil)
107+
109108
_, done := operator.Run(stopCh)
110109
<-done
111110
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,5 @@ require (
5353
k8s.io/klog v0.1.0 // indirect
5454
k8s.io/kube-aggregator v0.0.0-20181204002017-122bac39d429
5555
k8s.io/kube-openapi v0.0.0-20181031203759-72693cb1fadd
56-
k8s.io/kubernetes v1.11.7-beta.0.0.20190108024450-5a0d4e5b8d31
56+
k8s.io/kubernetes v1.11.7-beta.0.0.20190112090204-23cf8fe78f62
5757
)

go.sum

Lines changed: 50 additions & 3 deletions
Large diffs are not rendered by default.

pkg/metrics/metrics.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,18 @@ var (
129129
CSVUpgradeCount = prometheus.NewCounter(
130130
prometheus.CounterOpts{
131131
Name: "csv_upgrade_count",
132-
Help: "Monotonic count of catalog sources",
132+
Help: "Monotonic count of CSV upgrades",
133133
},
134134
)
135135
)
136136

137-
func Register() {
137+
func RegisterOLM() {
138138
prometheus.MustRegister(csvCount)
139+
prometheus.MustRegister(CSVUpgradeCount)
140+
}
141+
142+
func RegisterCatalog() {
139143
prometheus.MustRegister(installPlanCount)
140144
prometheus.MustRegister(subscriptionCount)
141145
prometheus.MustRegister(catalogSourceCount)
142-
prometheus.MustRegister(CSVUpgradeCount)
143146
}

vendor/github.com/prometheus/client_golang/prometheus/promhttp/delegator.go

Lines changed: 199 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)