File tree Expand file tree Collapse file tree 3 files changed +50
-0
lines changed Expand file tree Collapse file tree 3 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ require (
10
10
github.com/onsi/ginkgo v1.14.1
11
11
github.com/onsi/gomega v1.10.2
12
12
github.com/operator-framework/operator-lib v0.3.0
13
+ github.com/prometheus/client_golang v1.7.1
13
14
github.com/sirupsen/logrus v1.7.0
14
15
github.com/spf13/afero v1.2.2
15
16
github.com/spf13/cobra v1.1.1
Original file line number Diff line number Diff line change @@ -29,7 +29,9 @@ import (
29
29
"sigs.k8s.io/controller-runtime/pkg/healthz"
30
30
logf "sigs.k8s.io/controller-runtime/pkg/log"
31
31
zapl "sigs.k8s.io/controller-runtime/pkg/log/zap"
32
+ crmetrics "sigs.k8s.io/controller-runtime/pkg/metrics"
32
33
34
+ "github.com/joelanford/helm-operator/internal/metrics"
33
35
"github.com/joelanford/helm-operator/internal/version"
34
36
"github.com/joelanford/helm-operator/pkg/annotation"
35
37
"github.com/joelanford/helm-operator/pkg/manager"
@@ -96,6 +98,8 @@ func printVersion() {
96
98
func (r * run ) run (cmd * cobra.Command ) {
97
99
printVersion ()
98
100
101
+ metrics .RegisterBuildInfo (crmetrics .Registry )
102
+
99
103
// Deprecated: OPERATOR_NAME environment variable is an artifact of the legacy operator-sdk project scaffolding.
100
104
// Flag `--leader-election-id` should be used instead.
101
105
if operatorName , found := os .LookupEnv ("OPERATOR_NAME" ); found {
Original file line number Diff line number Diff line change
1
+ // Copyright 2021 The Operator-SDK Authors
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ package metrics
16
+
17
+ import (
18
+ "github.com/prometheus/client_golang/prometheus"
19
+
20
+ helmVersion "github.com/joelanford/helm-operator/internal/version"
21
+ )
22
+
23
+ const (
24
+ subsystem = "helm_operator"
25
+ )
26
+
27
+ var (
28
+ buildInfo = prometheus .NewGauge (
29
+ prometheus.GaugeOpts {
30
+ Subsystem : subsystem ,
31
+ Name : "build_info" ,
32
+ Help : "Build information for the helm-operator binary" ,
33
+ ConstLabels : map [string ]string {
34
+ "commit" : helmVersion .GitCommit ,
35
+ "version" : helmVersion .GitVersion ,
36
+ },
37
+ },
38
+ )
39
+ )
40
+
41
+ //RegisterBuildInfo registers buildInfo Collector to be included in metrics collection
42
+ func RegisterBuildInfo (r prometheus.Registerer ) {
43
+ buildInfo .Set (1 )
44
+ r .MustRegister (buildInfo )
45
+ }
You can’t perform that action at this time.
0 commit comments