From e4af3ab17520c71cab191d735c6293abe5782bf9 Mon Sep 17 00:00:00 2001 From: Cem Mergenci Date: Tue, 23 Apr 2024 12:29:20 +0300 Subject: [PATCH] Introduce MR metrics. Signed-off-by: Cem Mergenci --- cmd/provider/main.go | 25 +++++++++++++++---- go.mod | 5 ++++ go.sum | 10 +++++--- .../member/zz_controller.go | 9 +++++++ .../administrativeunits/unit/zz_controller.go | 9 +++++++ .../app/roleassignment/zz_controller.go | 9 +++++++ .../applications/application/zz_controller.go | 9 +++++++ .../applications/certificate/zz_controller.go | 9 +++++++ .../zz_controller.go | 9 +++++++ .../applications/password/zz_controller.go | 9 +++++++ .../preauthorized/zz_controller.go | 9 +++++++ .../accesspolicy/zz_controller.go | 9 +++++++ .../location/zz_controller.go | 9 +++++++ .../customdirectoryrole/zz_controller.go | 9 +++++++ .../directoryroles/role/zz_controller.go | 9 +++++++ .../roleassignment/zz_controller.go | 9 +++++++ .../controller/groups/group/zz_controller.go | 9 +++++++ .../controller/groups/member/zz_controller.go | 9 +++++++ .../invitations/invitation/zz_controller.go | 9 +++++++ .../claimsmappingpolicy/zz_controller.go | 9 +++++++ .../permissiongrant/zz_controller.go | 9 +++++++ .../certificate/zz_controller.go | 9 +++++++ .../zz_controller.go | 9 +++++++ .../password/zz_controller.go | 9 +++++++ .../principal/zz_controller.go | 9 +++++++ .../tokensigningcertificate/zz_controller.go | 9 +++++++ .../synchronization/job/zz_controller.go | 9 +++++++ .../synchronization/secret/zz_controller.go | 9 +++++++ .../controller/users/user/zz_controller.go | 9 +++++++ 29 files changed, 265 insertions(+), 9 deletions(-) diff --git a/cmd/provider/main.go b/cmd/provider/main.go index d24e03bc..9d555324 100644 --- a/cmd/provider/main.go +++ b/cmd/provider/main.go @@ -19,7 +19,9 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/feature" "github.com/crossplane/crossplane-runtime/pkg/logging" "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" + "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/crossplane/crossplane-runtime/pkg/statemetrics" tjcontroller "github.com/crossplane/upjet/pkg/controller" "gopkg.in/alecthomas/kingpin.v2" kerrors "k8s.io/apimachinery/pkg/api/errors" @@ -28,6 +30,7 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/cache" "sigs.k8s.io/controller-runtime/pkg/log/zap" + "sigs.k8s.io/controller-runtime/pkg/metrics" "github.com/upbound/provider-azuread/apis" "github.com/upbound/provider-azuread/apis/v1alpha1" @@ -47,11 +50,12 @@ func main() { return nil } } - debug = app.Flag("debug", "Run with debug logging.").Short('d').Bool() - syncPeriod = app.Flag("sync", "Controller manager sync period such as 300ms, 1.5h, or 2h45m").Short('s').Default("1h").Duration() - pollInterval = app.Flag("poll", "Poll interval controls how often an individual resource should be checked for drift.").Default("10m").Duration() - leaderElection = app.Flag("leader-election", "Use leader election for the controller manager.").Short('l').Default("false").OverrideDefaultFromEnvar("LEADER_ELECTION").Bool() - maxReconcileRate = app.Flag("max-reconcile-rate", "The global maximum rate per second at which resources may checked for drift from the desired state.").Default("10").Int() + debug = app.Flag("debug", "Run with debug logging.").Short('d').Bool() + syncPeriod = app.Flag("sync", "Controller manager sync period such as 300ms, 1.5h, or 2h45m").Short('s').Default("1h").Duration() + pollInterval = app.Flag("poll", "Poll interval controls how often an individual resource should be checked for drift.").Default("10m").Duration() + pollStateMetricInterval = app.Flag("poll-state-metric", "State metric recording interval").Default("5s").Duration() + leaderElection = app.Flag("leader-election", "Use leader election for the controller manager.").Short('l').Default("false").OverrideDefaultFromEnvar("LEADER_ELECTION").Bool() + maxReconcileRate = app.Flag("max-reconcile-rate", "The global maximum rate per second at which resources may checked for drift from the desired state.").Default("10").Int() // now deprecated command-line arguments with the Terraform SDK-based upjet architecture _ = app.Flag("terraform-version", "[DEPRECATED: This option is no longer used and it will be removed in a future release.] Terraform version.").Envar("TERRAFORM_VERSION").Hidden().Action(deprecationAction("terraform-version")).String() _ = app.Flag("terraform-provider-version", "[DEPRECATED: This option is no longer used and it will be removed in a future release.] Terraform provider version.").Envar("TERRAFORM_PROVIDER_VERSION").Hidden().Action(deprecationAction("terraform-provider-version")).String() @@ -99,6 +103,12 @@ func main() { kingpin.FatalIfError(err, "Cannot create controller manager") kingpin.FatalIfError(apis.AddToScheme(mgr.GetScheme()), "Cannot add Azuread APIs to scheme") + metricRecorder := managed.NewMRMetricRecorder() + stateMetrics := statemetrics.NewMRStateMetrics() + + metrics.Registry.MustRegister(metricRecorder) + metrics.Registry.MustRegister(stateMetrics) + ctx := context.Background() provider, err := config.GetProvider(ctx, false) kingpin.FatalIfError(err, "Cannot initialize the provider configuration") @@ -109,6 +119,11 @@ func main() { PollInterval: *pollInterval, MaxConcurrentReconciles: *maxReconcileRate, Features: &feature.Flags{}, + MetricOptions: &xpcontroller.MetricOptions{ + PollStateMetricInterval: *pollStateMetricInterval, + MRMetrics: metricRecorder, + MRStateMetrics: stateMetrics, + }, }, Provider: provider, SetupFn: clients.TerraformSetupBuilder(provider.TerraformProvider), diff --git a/go.mod b/go.mod index 2b49a428..6826d97e 100644 --- a/go.mod +++ b/go.mod @@ -33,6 +33,7 @@ require ( github.com/antchfx/xpath v1.2.0 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/beorn7/perks v1.0.1 // indirect + github.com/blang/semver/v4 v4.0.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cloudflare/circl v1.3.7 // indirect github.com/dave/jennifer v1.4.1 // indirect @@ -150,3 +151,7 @@ require ( replace github.com/hashicorp/terraform-provider-azuread => github.com/upbound/terraform-provider-azuread v0.0.0-20240311141618-ce1f46c21020 replace github.com/hashicorp/terraform-plugin-sdk/v2 => github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0 + +replace github.com/crossplane/crossplane-runtime => github.com/ezgidemirel/crossplane-runtime v0.17.0-rc.0.0.20240418112612-39473aa83bfb + +replace github.com/crossplane/upjet => github.com/mergenci/upjet v0.0.0-20240422143518-d568822a5a97 diff --git a/go.sum b/go.sum index 876433b1..a488f0d6 100644 --- a/go.sum +++ b/go.sum @@ -659,6 +659,8 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkY github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= +github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8= @@ -694,12 +696,8 @@ github.com/cncf/xds/go v0.0.0-20230105202645-06c439db220b/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/crossplane/crossplane-runtime v1.15.1 h1:g1h75tNYOQT152IUNxs8ZgSsRFQKrZN9z69KefMujXs= -github.com/crossplane/crossplane-runtime v1.15.1/go.mod h1:kRcJjJQmBFrR2n/KhwL8wYS7xNfq3D8eK4JliEScOHI= github.com/crossplane/crossplane-tools v0.0.0-20230925130601-628280f8bf79 h1:HigXs5tEQxWz0fcj8hzbU2UAZgEM7wPe0XRFOsrtF8Y= github.com/crossplane/crossplane-tools v0.0.0-20230925130601-628280f8bf79/go.mod h1:+e4OaFlOcmr0JvINHl/yvEYBrZawzTgj6pQumOH1SS0= -github.com/crossplane/upjet v1.3.0-rc.0.0.20240319124750-50919febc5ab h1:MUCxcv3CzQyDxT6GNPaPCMZhGKYbnxRnUiLiOwTldE8= -github.com/crossplane/upjet v1.3.0-rc.0.0.20240319124750-50919febc5ab/go.mod h1:0bHLtnejZ9bDeyXuBb9MSOQLvKo3+aoTeUBO8N0dGSA= github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/dave/jennifer v1.4.1 h1:XyqG6cn5RQsTj3qlWQTKlRGAyrTcsk1kUmWdZBzRjDw= @@ -734,6 +732,8 @@ github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCv github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch/v5 v5.8.0 h1:lRj6N9Nci7MvzrXuX6HFzU8XjmhPiXPlsKEy1u0KQro= github.com/evanphx/json-patch/v5 v5.8.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ= +github.com/ezgidemirel/crossplane-runtime v0.17.0-rc.0.0.20240418112612-39473aa83bfb h1:G39BgKE9qDraFtxxid+CAwT0t8bved5uZXqaeSFSLpo= +github.com/ezgidemirel/crossplane-runtime v0.17.0-rc.0.0.20240418112612-39473aa83bfb/go.mod h1:wbmdYNAJxOIl3WuRZccdYA0Yxi2KBBGTwFk7Y0eedVc= github.com/fatih/camelcase v1.0.0 h1:hxNvNX/xYBp0ovncs8WyWZrOrpBNub/JfaMvbURyft8= github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= @@ -1060,6 +1060,8 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D github.com/mattn/go-sqlite3 v1.14.14/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg= github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k= +github.com/mergenci/upjet v0.0.0-20240422143518-d568822a5a97 h1:08ICEGzg05uymensWm0N3nUsrCwifiB25fNLbHNplqk= +github.com/mergenci/upjet v0.0.0-20240422143518-d568822a5a97/go.mod h1:QIOo20dAd/qj6TO3gdOqYtP+aU31DWvzD/z9VIRZ5Us= github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8/go.mod h1:mC1jAcsrzbxHt8iiaC+zU4b1ylILSosueou12R++wfY= github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3/go.mod h1:RagcQ7I8IeTMnF8JTXieKnO4Z6JCsikNEzj0DwauVzE= github.com/mitchellh/cli v1.1.5/go.mod h1:v8+iFts2sPIKUV1ltktPXMCC8fumSKFItNcD2cLtRR4= diff --git a/internal/controller/administrativeunits/member/zz_controller.go b/internal/controller/administrativeunits/member/zz_controller.go index 2dec7cc4..87cfb117 100755 --- a/internal/controller/administrativeunits/member/zz_controller.go +++ b/internal/controller/administrativeunits/member/zz_controller.go @@ -14,6 +14,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/crossplane/crossplane-runtime/pkg/statemetrics" tjcontroller "github.com/crossplane/upjet/pkg/controller" "github.com/crossplane/upjet/pkg/controller/handler" "github.com/crossplane/upjet/pkg/metrics" @@ -49,6 +50,7 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { managed.WithInitializers(initializers), managed.WithConnectionPublishers(cps...), managed.WithPollInterval(o.PollInterval), + managed.WithMetricRecorder(o.MetricOptions.MRMetrics), } if o.PollJitter != 0 { opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) @@ -67,6 +69,13 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { } } + stateMetricsRecorder := statemetrics.NewMRStateRecorder( + mgr.GetClient(), o.Logger, o.MetricOptions.MRStateMetrics, &v1beta1.MemberList{}, o.MetricOptions.PollStateMetricInterval, + ) + if err := mgr.Add(stateMetricsRecorder); err != nil { + return err + } + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1beta1.Member_GroupVersionKind), opts...) return ctrl.NewControllerManagedBy(mgr). diff --git a/internal/controller/administrativeunits/unit/zz_controller.go b/internal/controller/administrativeunits/unit/zz_controller.go index 6625cbbe..fd6cecf7 100755 --- a/internal/controller/administrativeunits/unit/zz_controller.go +++ b/internal/controller/administrativeunits/unit/zz_controller.go @@ -14,6 +14,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/crossplane/crossplane-runtime/pkg/statemetrics" tjcontroller "github.com/crossplane/upjet/pkg/controller" "github.com/crossplane/upjet/pkg/controller/handler" "github.com/crossplane/upjet/pkg/metrics" @@ -49,6 +50,7 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { managed.WithInitializers(initializers), managed.WithConnectionPublishers(cps...), managed.WithPollInterval(o.PollInterval), + managed.WithMetricRecorder(o.MetricOptions.MRMetrics), } if o.PollJitter != 0 { opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) @@ -67,6 +69,13 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { } } + stateMetricsRecorder := statemetrics.NewMRStateRecorder( + mgr.GetClient(), o.Logger, o.MetricOptions.MRStateMetrics, &v1beta1.UnitList{}, o.MetricOptions.PollStateMetricInterval, + ) + if err := mgr.Add(stateMetricsRecorder); err != nil { + return err + } + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1beta1.Unit_GroupVersionKind), opts...) return ctrl.NewControllerManagedBy(mgr). diff --git a/internal/controller/app/roleassignment/zz_controller.go b/internal/controller/app/roleassignment/zz_controller.go index a3621060..7465dc9b 100755 --- a/internal/controller/app/roleassignment/zz_controller.go +++ b/internal/controller/app/roleassignment/zz_controller.go @@ -14,6 +14,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/crossplane/crossplane-runtime/pkg/statemetrics" tjcontroller "github.com/crossplane/upjet/pkg/controller" "github.com/crossplane/upjet/pkg/controller/handler" "github.com/crossplane/upjet/pkg/metrics" @@ -49,6 +50,7 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { managed.WithInitializers(initializers), managed.WithConnectionPublishers(cps...), managed.WithPollInterval(o.PollInterval), + managed.WithMetricRecorder(o.MetricOptions.MRMetrics), } if o.PollJitter != 0 { opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) @@ -67,6 +69,13 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { } } + stateMetricsRecorder := statemetrics.NewMRStateRecorder( + mgr.GetClient(), o.Logger, o.MetricOptions.MRStateMetrics, &v1beta1.RoleAssignmentList{}, o.MetricOptions.PollStateMetricInterval, + ) + if err := mgr.Add(stateMetricsRecorder); err != nil { + return err + } + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1beta1.RoleAssignment_GroupVersionKind), opts...) return ctrl.NewControllerManagedBy(mgr). diff --git a/internal/controller/applications/application/zz_controller.go b/internal/controller/applications/application/zz_controller.go index fd0e0af5..0349c2d3 100755 --- a/internal/controller/applications/application/zz_controller.go +++ b/internal/controller/applications/application/zz_controller.go @@ -14,6 +14,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/crossplane/crossplane-runtime/pkg/statemetrics" tjcontroller "github.com/crossplane/upjet/pkg/controller" "github.com/crossplane/upjet/pkg/controller/handler" "github.com/crossplane/upjet/pkg/metrics" @@ -49,6 +50,7 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { managed.WithInitializers(initializers), managed.WithConnectionPublishers(cps...), managed.WithPollInterval(o.PollInterval), + managed.WithMetricRecorder(o.MetricOptions.MRMetrics), } if o.PollJitter != 0 { opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) @@ -67,6 +69,13 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { } } + stateMetricsRecorder := statemetrics.NewMRStateRecorder( + mgr.GetClient(), o.Logger, o.MetricOptions.MRStateMetrics, &v1beta1.ApplicationList{}, o.MetricOptions.PollStateMetricInterval, + ) + if err := mgr.Add(stateMetricsRecorder); err != nil { + return err + } + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1beta1.Application_GroupVersionKind), opts...) return ctrl.NewControllerManagedBy(mgr). diff --git a/internal/controller/applications/certificate/zz_controller.go b/internal/controller/applications/certificate/zz_controller.go index 00630121..1cf8fa02 100755 --- a/internal/controller/applications/certificate/zz_controller.go +++ b/internal/controller/applications/certificate/zz_controller.go @@ -14,6 +14,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/crossplane/crossplane-runtime/pkg/statemetrics" tjcontroller "github.com/crossplane/upjet/pkg/controller" "github.com/crossplane/upjet/pkg/controller/handler" "github.com/crossplane/upjet/pkg/metrics" @@ -49,6 +50,7 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { managed.WithInitializers(initializers), managed.WithConnectionPublishers(cps...), managed.WithPollInterval(o.PollInterval), + managed.WithMetricRecorder(o.MetricOptions.MRMetrics), } if o.PollJitter != 0 { opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) @@ -67,6 +69,13 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { } } + stateMetricsRecorder := statemetrics.NewMRStateRecorder( + mgr.GetClient(), o.Logger, o.MetricOptions.MRStateMetrics, &v1beta1.CertificateList{}, o.MetricOptions.PollStateMetricInterval, + ) + if err := mgr.Add(stateMetricsRecorder); err != nil { + return err + } + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1beta1.Certificate_GroupVersionKind), opts...) return ctrl.NewControllerManagedBy(mgr). diff --git a/internal/controller/applications/federatedidentitycredential/zz_controller.go b/internal/controller/applications/federatedidentitycredential/zz_controller.go index 7cb80034..088d015d 100755 --- a/internal/controller/applications/federatedidentitycredential/zz_controller.go +++ b/internal/controller/applications/federatedidentitycredential/zz_controller.go @@ -14,6 +14,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/crossplane/crossplane-runtime/pkg/statemetrics" tjcontroller "github.com/crossplane/upjet/pkg/controller" "github.com/crossplane/upjet/pkg/controller/handler" "github.com/crossplane/upjet/pkg/metrics" @@ -49,6 +50,7 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { managed.WithInitializers(initializers), managed.WithConnectionPublishers(cps...), managed.WithPollInterval(o.PollInterval), + managed.WithMetricRecorder(o.MetricOptions.MRMetrics), } if o.PollJitter != 0 { opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) @@ -67,6 +69,13 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { } } + stateMetricsRecorder := statemetrics.NewMRStateRecorder( + mgr.GetClient(), o.Logger, o.MetricOptions.MRStateMetrics, &v1beta1.FederatedIdentityCredentialList{}, o.MetricOptions.PollStateMetricInterval, + ) + if err := mgr.Add(stateMetricsRecorder); err != nil { + return err + } + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1beta1.FederatedIdentityCredential_GroupVersionKind), opts...) return ctrl.NewControllerManagedBy(mgr). diff --git a/internal/controller/applications/password/zz_controller.go b/internal/controller/applications/password/zz_controller.go index 49f73707..1e969236 100755 --- a/internal/controller/applications/password/zz_controller.go +++ b/internal/controller/applications/password/zz_controller.go @@ -14,6 +14,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/crossplane/crossplane-runtime/pkg/statemetrics" tjcontroller "github.com/crossplane/upjet/pkg/controller" "github.com/crossplane/upjet/pkg/controller/handler" "github.com/crossplane/upjet/pkg/metrics" @@ -49,6 +50,7 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { managed.WithInitializers(initializers), managed.WithConnectionPublishers(cps...), managed.WithPollInterval(o.PollInterval), + managed.WithMetricRecorder(o.MetricOptions.MRMetrics), } if o.PollJitter != 0 { opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) @@ -67,6 +69,13 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { } } + stateMetricsRecorder := statemetrics.NewMRStateRecorder( + mgr.GetClient(), o.Logger, o.MetricOptions.MRStateMetrics, &v1beta1.PasswordList{}, o.MetricOptions.PollStateMetricInterval, + ) + if err := mgr.Add(stateMetricsRecorder); err != nil { + return err + } + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1beta1.Password_GroupVersionKind), opts...) return ctrl.NewControllerManagedBy(mgr). diff --git a/internal/controller/applications/preauthorized/zz_controller.go b/internal/controller/applications/preauthorized/zz_controller.go index 082d9c47..1b0ab719 100755 --- a/internal/controller/applications/preauthorized/zz_controller.go +++ b/internal/controller/applications/preauthorized/zz_controller.go @@ -14,6 +14,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/crossplane/crossplane-runtime/pkg/statemetrics" tjcontroller "github.com/crossplane/upjet/pkg/controller" "github.com/crossplane/upjet/pkg/controller/handler" "github.com/crossplane/upjet/pkg/metrics" @@ -49,6 +50,7 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { managed.WithInitializers(initializers), managed.WithConnectionPublishers(cps...), managed.WithPollInterval(o.PollInterval), + managed.WithMetricRecorder(o.MetricOptions.MRMetrics), } if o.PollJitter != 0 { opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) @@ -67,6 +69,13 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { } } + stateMetricsRecorder := statemetrics.NewMRStateRecorder( + mgr.GetClient(), o.Logger, o.MetricOptions.MRStateMetrics, &v1beta1.PreAuthorizedList{}, o.MetricOptions.PollStateMetricInterval, + ) + if err := mgr.Add(stateMetricsRecorder); err != nil { + return err + } + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1beta1.PreAuthorized_GroupVersionKind), opts...) return ctrl.NewControllerManagedBy(mgr). diff --git a/internal/controller/conditionalaccess/accesspolicy/zz_controller.go b/internal/controller/conditionalaccess/accesspolicy/zz_controller.go index 16e4341b..e53c06e2 100755 --- a/internal/controller/conditionalaccess/accesspolicy/zz_controller.go +++ b/internal/controller/conditionalaccess/accesspolicy/zz_controller.go @@ -14,6 +14,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/crossplane/crossplane-runtime/pkg/statemetrics" tjcontroller "github.com/crossplane/upjet/pkg/controller" "github.com/crossplane/upjet/pkg/controller/handler" "github.com/crossplane/upjet/pkg/metrics" @@ -49,6 +50,7 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { managed.WithInitializers(initializers), managed.WithConnectionPublishers(cps...), managed.WithPollInterval(o.PollInterval), + managed.WithMetricRecorder(o.MetricOptions.MRMetrics), } if o.PollJitter != 0 { opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) @@ -67,6 +69,13 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { } } + stateMetricsRecorder := statemetrics.NewMRStateRecorder( + mgr.GetClient(), o.Logger, o.MetricOptions.MRStateMetrics, &v1beta1.AccessPolicyList{}, o.MetricOptions.PollStateMetricInterval, + ) + if err := mgr.Add(stateMetricsRecorder); err != nil { + return err + } + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1beta1.AccessPolicy_GroupVersionKind), opts...) return ctrl.NewControllerManagedBy(mgr). diff --git a/internal/controller/conditionalaccess/location/zz_controller.go b/internal/controller/conditionalaccess/location/zz_controller.go index f0debf7d..3a5b5645 100755 --- a/internal/controller/conditionalaccess/location/zz_controller.go +++ b/internal/controller/conditionalaccess/location/zz_controller.go @@ -14,6 +14,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/crossplane/crossplane-runtime/pkg/statemetrics" tjcontroller "github.com/crossplane/upjet/pkg/controller" "github.com/crossplane/upjet/pkg/controller/handler" "github.com/crossplane/upjet/pkg/metrics" @@ -49,6 +50,7 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { managed.WithInitializers(initializers), managed.WithConnectionPublishers(cps...), managed.WithPollInterval(o.PollInterval), + managed.WithMetricRecorder(o.MetricOptions.MRMetrics), } if o.PollJitter != 0 { opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) @@ -67,6 +69,13 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { } } + stateMetricsRecorder := statemetrics.NewMRStateRecorder( + mgr.GetClient(), o.Logger, o.MetricOptions.MRStateMetrics, &v1beta1.LocationList{}, o.MetricOptions.PollStateMetricInterval, + ) + if err := mgr.Add(stateMetricsRecorder); err != nil { + return err + } + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1beta1.Location_GroupVersionKind), opts...) return ctrl.NewControllerManagedBy(mgr). diff --git a/internal/controller/directoryroles/customdirectoryrole/zz_controller.go b/internal/controller/directoryroles/customdirectoryrole/zz_controller.go index 567b40db..b7f12a8d 100755 --- a/internal/controller/directoryroles/customdirectoryrole/zz_controller.go +++ b/internal/controller/directoryroles/customdirectoryrole/zz_controller.go @@ -14,6 +14,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/crossplane/crossplane-runtime/pkg/statemetrics" tjcontroller "github.com/crossplane/upjet/pkg/controller" "github.com/crossplane/upjet/pkg/controller/handler" "github.com/crossplane/upjet/pkg/metrics" @@ -49,6 +50,7 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { managed.WithInitializers(initializers), managed.WithConnectionPublishers(cps...), managed.WithPollInterval(o.PollInterval), + managed.WithMetricRecorder(o.MetricOptions.MRMetrics), } if o.PollJitter != 0 { opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) @@ -67,6 +69,13 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { } } + stateMetricsRecorder := statemetrics.NewMRStateRecorder( + mgr.GetClient(), o.Logger, o.MetricOptions.MRStateMetrics, &v1beta1.CustomDirectoryRoleList{}, o.MetricOptions.PollStateMetricInterval, + ) + if err := mgr.Add(stateMetricsRecorder); err != nil { + return err + } + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1beta1.CustomDirectoryRole_GroupVersionKind), opts...) return ctrl.NewControllerManagedBy(mgr). diff --git a/internal/controller/directoryroles/role/zz_controller.go b/internal/controller/directoryroles/role/zz_controller.go index 06a0cee8..6f884147 100755 --- a/internal/controller/directoryroles/role/zz_controller.go +++ b/internal/controller/directoryroles/role/zz_controller.go @@ -14,6 +14,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/crossplane/crossplane-runtime/pkg/statemetrics" tjcontroller "github.com/crossplane/upjet/pkg/controller" "github.com/crossplane/upjet/pkg/controller/handler" "github.com/crossplane/upjet/pkg/metrics" @@ -49,6 +50,7 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { managed.WithInitializers(initializers), managed.WithConnectionPublishers(cps...), managed.WithPollInterval(o.PollInterval), + managed.WithMetricRecorder(o.MetricOptions.MRMetrics), } if o.PollJitter != 0 { opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) @@ -67,6 +69,13 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { } } + stateMetricsRecorder := statemetrics.NewMRStateRecorder( + mgr.GetClient(), o.Logger, o.MetricOptions.MRStateMetrics, &v1beta1.RoleList{}, o.MetricOptions.PollStateMetricInterval, + ) + if err := mgr.Add(stateMetricsRecorder); err != nil { + return err + } + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1beta1.Role_GroupVersionKind), opts...) return ctrl.NewControllerManagedBy(mgr). diff --git a/internal/controller/directoryroles/roleassignment/zz_controller.go b/internal/controller/directoryroles/roleassignment/zz_controller.go index fa51b6ab..a60b3105 100755 --- a/internal/controller/directoryroles/roleassignment/zz_controller.go +++ b/internal/controller/directoryroles/roleassignment/zz_controller.go @@ -14,6 +14,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/crossplane/crossplane-runtime/pkg/statemetrics" tjcontroller "github.com/crossplane/upjet/pkg/controller" "github.com/crossplane/upjet/pkg/controller/handler" "github.com/crossplane/upjet/pkg/metrics" @@ -49,6 +50,7 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { managed.WithInitializers(initializers), managed.WithConnectionPublishers(cps...), managed.WithPollInterval(o.PollInterval), + managed.WithMetricRecorder(o.MetricOptions.MRMetrics), } if o.PollJitter != 0 { opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) @@ -67,6 +69,13 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { } } + stateMetricsRecorder := statemetrics.NewMRStateRecorder( + mgr.GetClient(), o.Logger, o.MetricOptions.MRStateMetrics, &v1beta1.RoleAssignmentList{}, o.MetricOptions.PollStateMetricInterval, + ) + if err := mgr.Add(stateMetricsRecorder); err != nil { + return err + } + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1beta1.RoleAssignment_GroupVersionKind), opts...) return ctrl.NewControllerManagedBy(mgr). diff --git a/internal/controller/groups/group/zz_controller.go b/internal/controller/groups/group/zz_controller.go index 93c9b452..72779c6a 100755 --- a/internal/controller/groups/group/zz_controller.go +++ b/internal/controller/groups/group/zz_controller.go @@ -14,6 +14,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/crossplane/crossplane-runtime/pkg/statemetrics" tjcontroller "github.com/crossplane/upjet/pkg/controller" "github.com/crossplane/upjet/pkg/controller/handler" "github.com/crossplane/upjet/pkg/metrics" @@ -49,6 +50,7 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { managed.WithInitializers(initializers), managed.WithConnectionPublishers(cps...), managed.WithPollInterval(o.PollInterval), + managed.WithMetricRecorder(o.MetricOptions.MRMetrics), } if o.PollJitter != 0 { opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) @@ -67,6 +69,13 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { } } + stateMetricsRecorder := statemetrics.NewMRStateRecorder( + mgr.GetClient(), o.Logger, o.MetricOptions.MRStateMetrics, &v1beta1.GroupList{}, o.MetricOptions.PollStateMetricInterval, + ) + if err := mgr.Add(stateMetricsRecorder); err != nil { + return err + } + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1beta1.Group_GroupVersionKind), opts...) return ctrl.NewControllerManagedBy(mgr). diff --git a/internal/controller/groups/member/zz_controller.go b/internal/controller/groups/member/zz_controller.go index 090b4bb2..049bcb96 100755 --- a/internal/controller/groups/member/zz_controller.go +++ b/internal/controller/groups/member/zz_controller.go @@ -14,6 +14,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/crossplane/crossplane-runtime/pkg/statemetrics" tjcontroller "github.com/crossplane/upjet/pkg/controller" "github.com/crossplane/upjet/pkg/controller/handler" "github.com/crossplane/upjet/pkg/metrics" @@ -49,6 +50,7 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { managed.WithInitializers(initializers), managed.WithConnectionPublishers(cps...), managed.WithPollInterval(o.PollInterval), + managed.WithMetricRecorder(o.MetricOptions.MRMetrics), } if o.PollJitter != 0 { opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) @@ -67,6 +69,13 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { } } + stateMetricsRecorder := statemetrics.NewMRStateRecorder( + mgr.GetClient(), o.Logger, o.MetricOptions.MRStateMetrics, &v1beta1.MemberList{}, o.MetricOptions.PollStateMetricInterval, + ) + if err := mgr.Add(stateMetricsRecorder); err != nil { + return err + } + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1beta1.Member_GroupVersionKind), opts...) return ctrl.NewControllerManagedBy(mgr). diff --git a/internal/controller/invitations/invitation/zz_controller.go b/internal/controller/invitations/invitation/zz_controller.go index 8b42bc99..77aa6821 100755 --- a/internal/controller/invitations/invitation/zz_controller.go +++ b/internal/controller/invitations/invitation/zz_controller.go @@ -14,6 +14,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/crossplane/crossplane-runtime/pkg/statemetrics" tjcontroller "github.com/crossplane/upjet/pkg/controller" "github.com/crossplane/upjet/pkg/controller/handler" "github.com/crossplane/upjet/pkg/metrics" @@ -49,6 +50,7 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { managed.WithInitializers(initializers), managed.WithConnectionPublishers(cps...), managed.WithPollInterval(o.PollInterval), + managed.WithMetricRecorder(o.MetricOptions.MRMetrics), } if o.PollJitter != 0 { opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) @@ -67,6 +69,13 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { } } + stateMetricsRecorder := statemetrics.NewMRStateRecorder( + mgr.GetClient(), o.Logger, o.MetricOptions.MRStateMetrics, &v1beta1.InvitationList{}, o.MetricOptions.PollStateMetricInterval, + ) + if err := mgr.Add(stateMetricsRecorder); err != nil { + return err + } + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1beta1.Invitation_GroupVersionKind), opts...) return ctrl.NewControllerManagedBy(mgr). diff --git a/internal/controller/policies/claimsmappingpolicy/zz_controller.go b/internal/controller/policies/claimsmappingpolicy/zz_controller.go index 30227fb4..a90c27f6 100755 --- a/internal/controller/policies/claimsmappingpolicy/zz_controller.go +++ b/internal/controller/policies/claimsmappingpolicy/zz_controller.go @@ -14,6 +14,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/crossplane/crossplane-runtime/pkg/statemetrics" tjcontroller "github.com/crossplane/upjet/pkg/controller" "github.com/crossplane/upjet/pkg/controller/handler" "github.com/crossplane/upjet/pkg/metrics" @@ -49,6 +50,7 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { managed.WithInitializers(initializers), managed.WithConnectionPublishers(cps...), managed.WithPollInterval(o.PollInterval), + managed.WithMetricRecorder(o.MetricOptions.MRMetrics), } if o.PollJitter != 0 { opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) @@ -67,6 +69,13 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { } } + stateMetricsRecorder := statemetrics.NewMRStateRecorder( + mgr.GetClient(), o.Logger, o.MetricOptions.MRStateMetrics, &v1beta1.ClaimsMappingPolicyList{}, o.MetricOptions.PollStateMetricInterval, + ) + if err := mgr.Add(stateMetricsRecorder); err != nil { + return err + } + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1beta1.ClaimsMappingPolicy_GroupVersionKind), opts...) return ctrl.NewControllerManagedBy(mgr). diff --git a/internal/controller/serviceprincipaldelegated/permissiongrant/zz_controller.go b/internal/controller/serviceprincipaldelegated/permissiongrant/zz_controller.go index 4e90fa90..04687c43 100755 --- a/internal/controller/serviceprincipaldelegated/permissiongrant/zz_controller.go +++ b/internal/controller/serviceprincipaldelegated/permissiongrant/zz_controller.go @@ -14,6 +14,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/crossplane/crossplane-runtime/pkg/statemetrics" tjcontroller "github.com/crossplane/upjet/pkg/controller" "github.com/crossplane/upjet/pkg/controller/handler" "github.com/crossplane/upjet/pkg/metrics" @@ -49,6 +50,7 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { managed.WithInitializers(initializers), managed.WithConnectionPublishers(cps...), managed.WithPollInterval(o.PollInterval), + managed.WithMetricRecorder(o.MetricOptions.MRMetrics), } if o.PollJitter != 0 { opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) @@ -67,6 +69,13 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { } } + stateMetricsRecorder := statemetrics.NewMRStateRecorder( + mgr.GetClient(), o.Logger, o.MetricOptions.MRStateMetrics, &v1beta1.PermissionGrantList{}, o.MetricOptions.PollStateMetricInterval, + ) + if err := mgr.Add(stateMetricsRecorder); err != nil { + return err + } + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1beta1.PermissionGrant_GroupVersionKind), opts...) return ctrl.NewControllerManagedBy(mgr). diff --git a/internal/controller/serviceprincipals/certificate/zz_controller.go b/internal/controller/serviceprincipals/certificate/zz_controller.go index 93a33ace..ecfffde2 100755 --- a/internal/controller/serviceprincipals/certificate/zz_controller.go +++ b/internal/controller/serviceprincipals/certificate/zz_controller.go @@ -14,6 +14,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/crossplane/crossplane-runtime/pkg/statemetrics" tjcontroller "github.com/crossplane/upjet/pkg/controller" "github.com/crossplane/upjet/pkg/controller/handler" "github.com/crossplane/upjet/pkg/metrics" @@ -49,6 +50,7 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { managed.WithInitializers(initializers), managed.WithConnectionPublishers(cps...), managed.WithPollInterval(o.PollInterval), + managed.WithMetricRecorder(o.MetricOptions.MRMetrics), } if o.PollJitter != 0 { opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) @@ -67,6 +69,13 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { } } + stateMetricsRecorder := statemetrics.NewMRStateRecorder( + mgr.GetClient(), o.Logger, o.MetricOptions.MRStateMetrics, &v1beta1.CertificateList{}, o.MetricOptions.PollStateMetricInterval, + ) + if err := mgr.Add(stateMetricsRecorder); err != nil { + return err + } + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1beta1.Certificate_GroupVersionKind), opts...) return ctrl.NewControllerManagedBy(mgr). diff --git a/internal/controller/serviceprincipals/claimsmappingpolicyassignment/zz_controller.go b/internal/controller/serviceprincipals/claimsmappingpolicyassignment/zz_controller.go index 5562292b..cb3798bc 100755 --- a/internal/controller/serviceprincipals/claimsmappingpolicyassignment/zz_controller.go +++ b/internal/controller/serviceprincipals/claimsmappingpolicyassignment/zz_controller.go @@ -14,6 +14,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/crossplane/crossplane-runtime/pkg/statemetrics" tjcontroller "github.com/crossplane/upjet/pkg/controller" "github.com/crossplane/upjet/pkg/controller/handler" "github.com/crossplane/upjet/pkg/metrics" @@ -49,6 +50,7 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { managed.WithInitializers(initializers), managed.WithConnectionPublishers(cps...), managed.WithPollInterval(o.PollInterval), + managed.WithMetricRecorder(o.MetricOptions.MRMetrics), } if o.PollJitter != 0 { opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) @@ -67,6 +69,13 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { } } + stateMetricsRecorder := statemetrics.NewMRStateRecorder( + mgr.GetClient(), o.Logger, o.MetricOptions.MRStateMetrics, &v1beta1.ClaimsMappingPolicyAssignmentList{}, o.MetricOptions.PollStateMetricInterval, + ) + if err := mgr.Add(stateMetricsRecorder); err != nil { + return err + } + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1beta1.ClaimsMappingPolicyAssignment_GroupVersionKind), opts...) return ctrl.NewControllerManagedBy(mgr). diff --git a/internal/controller/serviceprincipals/password/zz_controller.go b/internal/controller/serviceprincipals/password/zz_controller.go index def590b4..b93defe0 100755 --- a/internal/controller/serviceprincipals/password/zz_controller.go +++ b/internal/controller/serviceprincipals/password/zz_controller.go @@ -14,6 +14,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/crossplane/crossplane-runtime/pkg/statemetrics" tjcontroller "github.com/crossplane/upjet/pkg/controller" "github.com/crossplane/upjet/pkg/controller/handler" "github.com/crossplane/upjet/pkg/metrics" @@ -49,6 +50,7 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { managed.WithInitializers(initializers), managed.WithConnectionPublishers(cps...), managed.WithPollInterval(o.PollInterval), + managed.WithMetricRecorder(o.MetricOptions.MRMetrics), } if o.PollJitter != 0 { opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) @@ -67,6 +69,13 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { } } + stateMetricsRecorder := statemetrics.NewMRStateRecorder( + mgr.GetClient(), o.Logger, o.MetricOptions.MRStateMetrics, &v1beta1.PasswordList{}, o.MetricOptions.PollStateMetricInterval, + ) + if err := mgr.Add(stateMetricsRecorder); err != nil { + return err + } + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1beta1.Password_GroupVersionKind), opts...) return ctrl.NewControllerManagedBy(mgr). diff --git a/internal/controller/serviceprincipals/principal/zz_controller.go b/internal/controller/serviceprincipals/principal/zz_controller.go index bd74f229..1812fa5d 100755 --- a/internal/controller/serviceprincipals/principal/zz_controller.go +++ b/internal/controller/serviceprincipals/principal/zz_controller.go @@ -14,6 +14,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/crossplane/crossplane-runtime/pkg/statemetrics" tjcontroller "github.com/crossplane/upjet/pkg/controller" "github.com/crossplane/upjet/pkg/controller/handler" "github.com/crossplane/upjet/pkg/metrics" @@ -49,6 +50,7 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { managed.WithInitializers(initializers), managed.WithConnectionPublishers(cps...), managed.WithPollInterval(o.PollInterval), + managed.WithMetricRecorder(o.MetricOptions.MRMetrics), } if o.PollJitter != 0 { opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) @@ -67,6 +69,13 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { } } + stateMetricsRecorder := statemetrics.NewMRStateRecorder( + mgr.GetClient(), o.Logger, o.MetricOptions.MRStateMetrics, &v1beta1.PrincipalList{}, o.MetricOptions.PollStateMetricInterval, + ) + if err := mgr.Add(stateMetricsRecorder); err != nil { + return err + } + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1beta1.Principal_GroupVersionKind), opts...) return ctrl.NewControllerManagedBy(mgr). diff --git a/internal/controller/serviceprincipals/tokensigningcertificate/zz_controller.go b/internal/controller/serviceprincipals/tokensigningcertificate/zz_controller.go index a70629fb..c674c1ed 100755 --- a/internal/controller/serviceprincipals/tokensigningcertificate/zz_controller.go +++ b/internal/controller/serviceprincipals/tokensigningcertificate/zz_controller.go @@ -14,6 +14,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/crossplane/crossplane-runtime/pkg/statemetrics" tjcontroller "github.com/crossplane/upjet/pkg/controller" "github.com/crossplane/upjet/pkg/controller/handler" "github.com/crossplane/upjet/pkg/metrics" @@ -49,6 +50,7 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { managed.WithInitializers(initializers), managed.WithConnectionPublishers(cps...), managed.WithPollInterval(o.PollInterval), + managed.WithMetricRecorder(o.MetricOptions.MRMetrics), } if o.PollJitter != 0 { opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) @@ -67,6 +69,13 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { } } + stateMetricsRecorder := statemetrics.NewMRStateRecorder( + mgr.GetClient(), o.Logger, o.MetricOptions.MRStateMetrics, &v1beta1.TokenSigningCertificateList{}, o.MetricOptions.PollStateMetricInterval, + ) + if err := mgr.Add(stateMetricsRecorder); err != nil { + return err + } + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1beta1.TokenSigningCertificate_GroupVersionKind), opts...) return ctrl.NewControllerManagedBy(mgr). diff --git a/internal/controller/synchronization/job/zz_controller.go b/internal/controller/synchronization/job/zz_controller.go index 34dbf6af..90c66a0f 100755 --- a/internal/controller/synchronization/job/zz_controller.go +++ b/internal/controller/synchronization/job/zz_controller.go @@ -14,6 +14,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/crossplane/crossplane-runtime/pkg/statemetrics" tjcontroller "github.com/crossplane/upjet/pkg/controller" "github.com/crossplane/upjet/pkg/controller/handler" "github.com/crossplane/upjet/pkg/metrics" @@ -49,6 +50,7 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { managed.WithInitializers(initializers), managed.WithConnectionPublishers(cps...), managed.WithPollInterval(o.PollInterval), + managed.WithMetricRecorder(o.MetricOptions.MRMetrics), } if o.PollJitter != 0 { opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) @@ -67,6 +69,13 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { } } + stateMetricsRecorder := statemetrics.NewMRStateRecorder( + mgr.GetClient(), o.Logger, o.MetricOptions.MRStateMetrics, &v1beta1.JobList{}, o.MetricOptions.PollStateMetricInterval, + ) + if err := mgr.Add(stateMetricsRecorder); err != nil { + return err + } + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1beta1.Job_GroupVersionKind), opts...) return ctrl.NewControllerManagedBy(mgr). diff --git a/internal/controller/synchronization/secret/zz_controller.go b/internal/controller/synchronization/secret/zz_controller.go index 16e32157..32182c2b 100755 --- a/internal/controller/synchronization/secret/zz_controller.go +++ b/internal/controller/synchronization/secret/zz_controller.go @@ -14,6 +14,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/crossplane/crossplane-runtime/pkg/statemetrics" tjcontroller "github.com/crossplane/upjet/pkg/controller" "github.com/crossplane/upjet/pkg/controller/handler" "github.com/crossplane/upjet/pkg/metrics" @@ -49,6 +50,7 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { managed.WithInitializers(initializers), managed.WithConnectionPublishers(cps...), managed.WithPollInterval(o.PollInterval), + managed.WithMetricRecorder(o.MetricOptions.MRMetrics), } if o.PollJitter != 0 { opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) @@ -67,6 +69,13 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { } } + stateMetricsRecorder := statemetrics.NewMRStateRecorder( + mgr.GetClient(), o.Logger, o.MetricOptions.MRStateMetrics, &v1beta1.SecretList{}, o.MetricOptions.PollStateMetricInterval, + ) + if err := mgr.Add(stateMetricsRecorder); err != nil { + return err + } + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1beta1.Secret_GroupVersionKind), opts...) return ctrl.NewControllerManagedBy(mgr). diff --git a/internal/controller/users/user/zz_controller.go b/internal/controller/users/user/zz_controller.go index 5f69a38b..9110f5b4 100755 --- a/internal/controller/users/user/zz_controller.go +++ b/internal/controller/users/user/zz_controller.go @@ -14,6 +14,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/crossplane/crossplane-runtime/pkg/statemetrics" tjcontroller "github.com/crossplane/upjet/pkg/controller" "github.com/crossplane/upjet/pkg/controller/handler" "github.com/crossplane/upjet/pkg/metrics" @@ -49,6 +50,7 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { managed.WithInitializers(initializers), managed.WithConnectionPublishers(cps...), managed.WithPollInterval(o.PollInterval), + managed.WithMetricRecorder(o.MetricOptions.MRMetrics), } if o.PollJitter != 0 { opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) @@ -67,6 +69,13 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { } } + stateMetricsRecorder := statemetrics.NewMRStateRecorder( + mgr.GetClient(), o.Logger, o.MetricOptions.MRStateMetrics, &v1beta1.UserList{}, o.MetricOptions.PollStateMetricInterval, + ) + if err := mgr.Add(stateMetricsRecorder); err != nil { + return err + } + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1beta1.User_GroupVersionKind), opts...) return ctrl.NewControllerManagedBy(mgr).