File tree Expand file tree Collapse file tree 5 files changed +77
-0
lines changed Expand file tree Collapse file tree 5 files changed +77
-0
lines changed Original file line number Diff line number Diff line change
1
+ entries :
2
+ - description : >
3
+ In Ansible-based operators, added the `ansible_operator_build_info`
4
+ metric to instrument commit and version information.
5
+ kind: "addition"
6
+ - description : >
7
+ In Helm-based operators, added the `helm_operator_build_info`
8
+ metric to instrument commit and version information.
9
+ kind: "addition"
Original file line number Diff line number Diff line change @@ -20,13 +20,26 @@ import (
20
20
"github.com/prometheus/client_golang/prometheus"
21
21
logf "sigs.k8s.io/controller-runtime/pkg/log"
22
22
"sigs.k8s.io/controller-runtime/pkg/metrics"
23
+
24
+ sdkVersion "github.com/operator-framework/operator-sdk/internal/version"
23
25
)
24
26
25
27
const (
26
28
subsystem = "ansible_operator"
27
29
)
28
30
29
31
var (
32
+ buildInfo = prometheus .NewGauge (
33
+ prometheus.GaugeOpts {
34
+ Subsystem : subsystem ,
35
+ Name : "build_info" ,
36
+ Help : "Build information for the ansible-operator binary" ,
37
+ ConstLabels : map [string ]string {
38
+ "commit" : sdkVersion .GitCommit ,
39
+ "version" : sdkVersion .Version ,
40
+ },
41
+ })
42
+
30
43
reconcileResults = prometheus .NewGaugeVec (
31
44
prometheus.GaugeOpts {
32
45
Subsystem : subsystem ,
@@ -64,6 +77,11 @@ func recoverMetricPanic() {
64
77
}
65
78
}
66
79
80
+ func RegisterBuildInfo (r prometheus.Registerer ) {
81
+ buildInfo .Set (1 )
82
+ r .MustRegister (buildInfo )
83
+ }
84
+
67
85
func ReconcileSucceeded (gvk string ) {
68
86
defer recoverMetricPanic ()
69
87
reconcileResults .WithLabelValues (gvk , "succeeded" ).Inc ()
Original file line number Diff line number Diff line change @@ -33,9 +33,11 @@ import (
33
33
zapf "sigs.k8s.io/controller-runtime/pkg/log/zap"
34
34
"sigs.k8s.io/controller-runtime/pkg/manager"
35
35
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
36
+ crmetrics "sigs.k8s.io/controller-runtime/pkg/metrics"
36
37
37
38
"github.com/operator-framework/operator-sdk/internal/ansible/controller"
38
39
"github.com/operator-framework/operator-sdk/internal/ansible/flags"
40
+ "github.com/operator-framework/operator-sdk/internal/ansible/metrics"
39
41
"github.com/operator-framework/operator-sdk/internal/ansible/proxy"
40
42
"github.com/operator-framework/operator-sdk/internal/ansible/proxy/controllermap"
41
43
"github.com/operator-framework/operator-sdk/internal/ansible/runner"
@@ -81,6 +83,7 @@ func NewCmd() *cobra.Command {
81
83
82
84
func run (cmd * cobra.Command , f * flags.Flags ) {
83
85
printVersion ()
86
+ metrics .RegisterBuildInfo (crmetrics .Registry )
84
87
85
88
cfg , err := config .GetConfig ()
86
89
if err != nil {
Original file line number Diff line number Diff line change @@ -31,9 +31,11 @@ import (
31
31
zapf "sigs.k8s.io/controller-runtime/pkg/log/zap"
32
32
"sigs.k8s.io/controller-runtime/pkg/manager"
33
33
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
34
+ crmetrics "sigs.k8s.io/controller-runtime/pkg/metrics"
34
35
35
36
"github.com/operator-framework/operator-sdk/internal/helm/controller"
36
37
"github.com/operator-framework/operator-sdk/internal/helm/flags"
38
+ "github.com/operator-framework/operator-sdk/internal/helm/metrics"
37
39
"github.com/operator-framework/operator-sdk/internal/helm/release"
38
40
"github.com/operator-framework/operator-sdk/internal/helm/watches"
39
41
"github.com/operator-framework/operator-sdk/internal/util/k8sutil"
@@ -73,6 +75,7 @@ func NewCmd() *cobra.Command {
73
75
74
76
func run (cmd * cobra.Command , f * flags.Flags ) {
75
77
printVersion ()
78
+ metrics .RegisterBuildInfo (crmetrics .Registry )
76
79
77
80
cfg , err := config .GetConfig ()
78
81
if err != nil {
Original file line number Diff line number Diff line change
1
+ // Copyright 2020 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
+ sdkVersion "github.com/operator-framework/operator-sdk/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" : sdkVersion .GitCommit ,
35
+ "version" : sdkVersion .Version ,
36
+ },
37
+ },
38
+ )
39
+ )
40
+
41
+ func RegisterBuildInfo (r prometheus.Registerer ) {
42
+ buildInfo .Set (1 )
43
+ r .MustRegister (buildInfo )
44
+ }
You can’t perform that action at this time.
0 commit comments