From 2b01dc23e332974a89b48a3d881b1c2f62078a51 Mon Sep 17 00:00:00 2001 From: Bella Khizgiyaev Date: Wed, 19 Jun 2024 20:52:52 +0300 Subject: [PATCH] Remove unused dependencies for recording rules Signed-off-by: Bella Khizgiyaev --- go.mod | 2 +- go.sum | 2 - .../operator-observability/LICENSE | 201 ------------------ .../pkg/operatormetrics/BUILD.bazel | 23 -- .../pkg/operatormetrics/collector.go | 99 --------- .../pkg/operatormetrics/counter.go | 36 ---- .../pkg/operatormetrics/counter_vec.go | 38 ---- .../pkg/operatormetrics/gauge.go | 36 ---- .../pkg/operatormetrics/gauge_vec.go | 38 ---- .../pkg/operatormetrics/histogram.go | 51 ----- .../pkg/operatormetrics/histogram_vec.go | 42 ---- .../pkg/operatormetrics/metric.go | 42 ---- .../pkg/operatormetrics/registry.go | 14 -- .../pkg/operatormetrics/summary.go | 51 ----- .../pkg/operatormetrics/summary_vec.go | 42 ---- .../pkg/operatormetrics/wrapper_registry.go | 166 --------------- .../pkg/operatorrules/BUILD.bazel | 23 -- .../pkg/operatorrules/prometheusrules.go | 76 ------- .../pkg/operatorrules/rbac.go | 45 ---- .../pkg/operatorrules/recordingrule.go | 24 --- .../pkg/operatorrules/registry.go | 82 ------- .../pkg/operatorrules/schema.go | 22 -- vendor/modules.txt | 6 +- 23 files changed, 3 insertions(+), 1158 deletions(-) delete mode 100644 vendor/github.com/machadovilaca/operator-observability/LICENSE delete mode 100644 vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/BUILD.bazel delete mode 100644 vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/collector.go delete mode 100644 vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/counter.go delete mode 100644 vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/counter_vec.go delete mode 100644 vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/gauge.go delete mode 100644 vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/gauge_vec.go delete mode 100644 vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/histogram.go delete mode 100644 vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/histogram_vec.go delete mode 100644 vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/metric.go delete mode 100644 vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/registry.go delete mode 100644 vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/summary.go delete mode 100644 vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/summary_vec.go delete mode 100644 vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/wrapper_registry.go delete mode 100644 vendor/github.com/machadovilaca/operator-observability/pkg/operatorrules/BUILD.bazel delete mode 100644 vendor/github.com/machadovilaca/operator-observability/pkg/operatorrules/prometheusrules.go delete mode 100644 vendor/github.com/machadovilaca/operator-observability/pkg/operatorrules/rbac.go delete mode 100644 vendor/github.com/machadovilaca/operator-observability/pkg/operatorrules/recordingrule.go delete mode 100644 vendor/github.com/machadovilaca/operator-observability/pkg/operatorrules/registry.go delete mode 100644 vendor/github.com/machadovilaca/operator-observability/pkg/operatorrules/schema.go diff --git a/go.mod b/go.mod index 55ef8f481..f91ce8875 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,6 @@ require ( github.com/gophercloud/utils v0.0.0-20230418172808-6eab72e966e1 github.com/gorilla/websocket v1.5.1 github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.4.0 - github.com/machadovilaca/operator-observability v0.0.20 github.com/mattn/go-sqlite3 v1.14.18 github.com/onsi/ginkgo v1.16.5 github.com/onsi/ginkgo/v2 v2.13.2 @@ -92,6 +91,7 @@ require ( github.com/openshift/custom-resource-status v1.1.2 // indirect github.com/pborman/uuid v1.2.1 // indirect github.com/pelletier/go-toml/v2 v2.0.8 // indirect + github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus/procfs v0.11.1 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect diff --git a/go.sum b/go.sum index c5972e09b..15d89f1e0 100644 --- a/go.sum +++ b/go.sum @@ -182,8 +182,6 @@ github.com/kubev2v/gophercloud v0.0.0-20230629135522-9d701a75c760/go.mod h1:aAVq github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw= github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= -github.com/machadovilaca/operator-observability v0.0.20 h1:I9CLKWcaJU9KtPREhUu4yn/CLAZUpxFqEUz/ZVenkAI= -github.com/machadovilaca/operator-observability v0.0.20/go.mod h1:e4Z3VhOXb9InkmSh00JjqBBijE+iD+YMzynBpKB3+gE= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= diff --git a/vendor/github.com/machadovilaca/operator-observability/LICENSE b/vendor/github.com/machadovilaca/operator-observability/LICENSE deleted file mode 100644 index 261eeb9e9..000000000 --- a/vendor/github.com/machadovilaca/operator-observability/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/BUILD.bazel b/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/BUILD.bazel deleted file mode 100644 index 260644ea2..000000000 --- a/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/BUILD.bazel +++ /dev/null @@ -1,23 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -go_library( - name = "operatormetrics", - srcs = [ - "collector.go", - "counter.go", - "counter_vec.go", - "gauge.go", - "gauge_vec.go", - "histogram.go", - "histogram_vec.go", - "metric.go", - "registry.go", - "summary.go", - "summary_vec.go", - "wrapper_registry.go", - ], - importmap = "github.com/konveyor/forklift-controller/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics", - importpath = "github.com/machadovilaca/operator-observability/pkg/operatormetrics", - visibility = ["//visibility:public"], - deps = ["//vendor/github.com/prometheus/client_golang/prometheus"], -) diff --git a/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/collector.go b/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/collector.go deleted file mode 100644 index 35015f51a..000000000 --- a/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/collector.go +++ /dev/null @@ -1,99 +0,0 @@ -package operatormetrics - -import ( - "fmt" - "strings" - - "github.com/prometheus/client_golang/prometheus" -) - -// Collector registers a prometheus.Collector with a set of metrics in the -// Prometheus registry. The metrics are collected by calling the CollectCallback -// function. -type Collector struct { - // Metrics is a list of metrics to be collected by the collector. - Metrics []Metric - - // CollectCallback is a function that returns a list of CollectionResults. - // The CollectionResults are used to populate the metrics in the collector. - CollectCallback func() []CollectorResult -} - -type CollectorResult struct { - Metric Metric - Labels []string - ConstLabels map[string]string - Value float64 -} - -func (c Collector) hash() string { - var sb strings.Builder - - for _, cm := range c.Metrics { - sb.WriteString(cm.GetOpts().Name) - } - - return sb.String() -} - -func (c Collector) Describe(ch chan<- *prometheus.Desc) { - for _, cm := range c.Metrics { - cm.getCollector().Describe(ch) - } -} - -func (c Collector) Collect(ch chan<- prometheus.Metric) { - collectedMetrics := c.CollectCallback() - - for _, cr := range collectedMetrics { - metric, ok := operatorRegistry.registeredCollectorMetrics[cr.Metric.GetOpts().Name] - if !ok { - fmt.Printf("metric %s not found in registry", cr.Metric.GetOpts().Name) - continue - } - - if err := collectValue(ch, metric, cr); err != nil { - fmt.Printf("error collecting metric %s: %v", cr.Metric.GetOpts().Name, err) - } - } -} - -func collectValue(ch chan<- prometheus.Metric, metric Metric, cr CollectorResult) error { - var mType prometheus.ValueType - - switch metric.GetType() { - case CounterType: - mType = prometheus.CounterValue - case GaugeType: - mType = prometheus.GaugeValue - case CounterVecType: - mType = prometheus.CounterValue - case GaugeVecType: - mType = prometheus.GaugeValue - default: - return fmt.Errorf("encountered unsupported type for collector %v", metric.GetType()) - } - - labels := map[string]string{} - for k, v := range cr.ConstLabels { - labels[k] = v - } - for k, v := range metric.GetOpts().ConstLabels { - labels[k] = v - } - - desc := prometheus.NewDesc( - metric.GetOpts().Name, - metric.GetOpts().Help, - metric.GetOpts().labels, - labels, - ) - - cm, err := prometheus.NewConstMetric(desc, mType, cr.Value, cr.Labels...) - if err != nil { - return err - } - ch <- cm - - return nil -} diff --git a/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/counter.go b/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/counter.go deleted file mode 100644 index ddca79de4..000000000 --- a/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/counter.go +++ /dev/null @@ -1,36 +0,0 @@ -package operatormetrics - -import "github.com/prometheus/client_golang/prometheus" - -type Counter struct { - prometheus.Counter - - metricOpts MetricOpts -} - -var _ Metric = &Counter{} - -// NewCounter creates a new Counter. The Counter must be registered with the -// Prometheus registry through RegisterMetrics. -func NewCounter(metricOpts MetricOpts) *Counter { - return &Counter{ - Counter: prometheus.NewCounter(prometheus.CounterOpts(convertOpts(metricOpts))), - metricOpts: metricOpts, - } -} - -func (c *Counter) GetOpts() MetricOpts { - return c.metricOpts -} - -func (c *Counter) GetType() MetricType { - return CounterType -} - -func (c *Counter) GetBaseType() MetricType { - return CounterType -} - -func (c *Counter) getCollector() prometheus.Collector { - return c.Counter -} diff --git a/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/counter_vec.go b/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/counter_vec.go deleted file mode 100644 index 568ce6c7b..000000000 --- a/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/counter_vec.go +++ /dev/null @@ -1,38 +0,0 @@ -package operatormetrics - -import "github.com/prometheus/client_golang/prometheus" - -type CounterVec struct { - prometheus.CounterVec - - metricOpts MetricOpts -} - -var _ Metric = &CounterVec{} - -// NewCounterVec creates a new CounterVec. The CounterVec must be registered -// with the Prometheus registry through RegisterMetrics. -func NewCounterVec(metricOpts MetricOpts, labels []string) *CounterVec { - metricOpts.labels = labels - - return &CounterVec{ - CounterVec: *prometheus.NewCounterVec(prometheus.CounterOpts(convertOpts(metricOpts)), labels), - metricOpts: metricOpts, - } -} - -func (c *CounterVec) GetOpts() MetricOpts { - return c.metricOpts -} - -func (c *CounterVec) GetType() MetricType { - return CounterVecType -} - -func (c *CounterVec) GetBaseType() MetricType { - return CounterType -} - -func (c *CounterVec) getCollector() prometheus.Collector { - return c.CounterVec -} diff --git a/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/gauge.go b/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/gauge.go deleted file mode 100644 index de2699b2c..000000000 --- a/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/gauge.go +++ /dev/null @@ -1,36 +0,0 @@ -package operatormetrics - -import "github.com/prometheus/client_golang/prometheus" - -type Gauge struct { - prometheus.Gauge - - metricOpts MetricOpts -} - -var _ Metric = &Gauge{} - -// NewGauge creates a new Gauge. The Gauge must be registered with the -// Prometheus registry through RegisterMetrics. -func NewGauge(metricOpts MetricOpts) *Gauge { - return &Gauge{ - Gauge: prometheus.NewGauge(prometheus.GaugeOpts(convertOpts(metricOpts))), - metricOpts: metricOpts, - } -} - -func (c *Gauge) GetOpts() MetricOpts { - return c.metricOpts -} - -func (c *Gauge) GetType() MetricType { - return GaugeType -} - -func (c *Gauge) GetBaseType() MetricType { - return GaugeType -} - -func (c *Gauge) getCollector() prometheus.Collector { - return c.Gauge -} diff --git a/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/gauge_vec.go b/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/gauge_vec.go deleted file mode 100644 index c771dece9..000000000 --- a/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/gauge_vec.go +++ /dev/null @@ -1,38 +0,0 @@ -package operatormetrics - -import "github.com/prometheus/client_golang/prometheus" - -type GaugeVec struct { - prometheus.GaugeVec - - metricOpts MetricOpts -} - -var _ Metric = &GaugeVec{} - -// NewGaugeVec creates a new GaugeVec. The GaugeVec must be registered -// with the Prometheus registry through RegisterMetrics. -func NewGaugeVec(metricOpts MetricOpts, labels []string) *GaugeVec { - metricOpts.labels = labels - - return &GaugeVec{ - GaugeVec: *prometheus.NewGaugeVec(prometheus.GaugeOpts(convertOpts(metricOpts)), labels), - metricOpts: metricOpts, - } -} - -func (c *GaugeVec) GetOpts() MetricOpts { - return c.metricOpts -} - -func (c *GaugeVec) GetType() MetricType { - return GaugeVecType -} - -func (c *GaugeVec) GetBaseType() MetricType { - return GaugeType -} - -func (c *GaugeVec) getCollector() prometheus.Collector { - return c.GaugeVec -} diff --git a/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/histogram.go b/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/histogram.go deleted file mode 100644 index b764835e2..000000000 --- a/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/histogram.go +++ /dev/null @@ -1,51 +0,0 @@ -package operatormetrics - -import ( - "github.com/prometheus/client_golang/prometheus" -) - -type Histogram struct { - prometheus.Histogram - - metricOpts MetricOpts - histogramOpts prometheus.HistogramOpts -} - -var _ Metric = &Histogram{} - -// NewHistogram creates a new Histogram. The Histogram must be registered with the -// Prometheus registry through RegisterMetrics. -func NewHistogram(metricOpts MetricOpts, histogramOpts prometheus.HistogramOpts) *Histogram { - return &Histogram{ - Histogram: prometheus.NewHistogram(makePrometheusHistogramOpts(metricOpts, histogramOpts)), - metricOpts: metricOpts, - histogramOpts: histogramOpts, - } -} - -func makePrometheusHistogramOpts(metricOpts MetricOpts, histogramOpts prometheus.HistogramOpts) prometheus.HistogramOpts { - histogramOpts.Name = metricOpts.Name - histogramOpts.Help = metricOpts.Help - histogramOpts.ConstLabels = metricOpts.ConstLabels - return histogramOpts -} - -func (c *Histogram) GetOpts() MetricOpts { - return c.metricOpts -} - -func (c *Histogram) GetHistogramOpts() prometheus.HistogramOpts { - return c.histogramOpts -} - -func (c *Histogram) GetType() MetricType { - return HistogramType -} - -func (c *Histogram) GetBaseType() MetricType { - return HistogramType -} - -func (c *Histogram) getCollector() prometheus.Collector { - return c.Histogram -} diff --git a/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/histogram_vec.go b/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/histogram_vec.go deleted file mode 100644 index f272495f1..000000000 --- a/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/histogram_vec.go +++ /dev/null @@ -1,42 +0,0 @@ -package operatormetrics - -import "github.com/prometheus/client_golang/prometheus" - -type HistogramVec struct { - prometheus.HistogramVec - - metricOpts MetricOpts - histogramOpts prometheus.HistogramOpts -} - -var _ Metric = &HistogramVec{} - -// NewHistogramVec creates a new HistogramVec. The HistogramVec must be -// registered with the Prometheus registry through RegisterMetrics. -func NewHistogramVec(metricOpts MetricOpts, histogramOpts prometheus.HistogramOpts, labels []string) *HistogramVec { - return &HistogramVec{ - HistogramVec: *prometheus.NewHistogramVec(makePrometheusHistogramOpts(metricOpts, histogramOpts), labels), - metricOpts: metricOpts, - histogramOpts: histogramOpts, - } -} - -func (c *HistogramVec) GetOpts() MetricOpts { - return c.metricOpts -} - -func (c *HistogramVec) GetHistogramOpts() prometheus.HistogramOpts { - return c.histogramOpts -} - -func (c *HistogramVec) GetType() MetricType { - return HistogramVecType -} - -func (c *HistogramVec) GetBaseType() MetricType { - return HistogramType -} - -func (c *HistogramVec) getCollector() prometheus.Collector { - return c.HistogramVec -} diff --git a/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/metric.go b/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/metric.go deleted file mode 100644 index 108d86bb9..000000000 --- a/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/metric.go +++ /dev/null @@ -1,42 +0,0 @@ -package operatormetrics - -import "github.com/prometheus/client_golang/prometheus" - -type MetricOpts struct { - Name string - Help string - ConstLabels map[string]string - ExtraFields map[string]string - - labels []string -} - -type Metric interface { - GetOpts() MetricOpts - GetType() MetricType - GetBaseType() MetricType - - getCollector() prometheus.Collector -} - -type MetricType string - -const ( - CounterType MetricType = "Counter" - GaugeType MetricType = "Gauge" - HistogramType MetricType = "Histogram" - SummaryType MetricType = "Summary" - - CounterVecType MetricType = "CounterVec" - GaugeVecType MetricType = "GaugeVec" - HistogramVecType MetricType = "HistogramVec" - SummaryVecType MetricType = "SummaryVec" -) - -func convertOpts(opts MetricOpts) prometheus.Opts { - return prometheus.Opts{ - Name: opts.Name, - Help: opts.Help, - ConstLabels: opts.ConstLabels, - } -} diff --git a/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/registry.go b/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/registry.go deleted file mode 100644 index b1e803067..000000000 --- a/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/registry.go +++ /dev/null @@ -1,14 +0,0 @@ -package operatormetrics - -import ( - "github.com/prometheus/client_golang/prometheus" -) - -type RegistryFunc func(c prometheus.Collector) error -type UnregisterFunc func(c prometheus.Collector) bool - -// Register is the function used to register metrics and collectors by this package. -var Register RegistryFunc = prometheus.Register - -// Unregister is the function used to unregister metrics and collectors by this package. -var Unregister UnregisterFunc = prometheus.Unregister diff --git a/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/summary.go b/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/summary.go deleted file mode 100644 index 3bf9d37c8..000000000 --- a/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/summary.go +++ /dev/null @@ -1,51 +0,0 @@ -package operatormetrics - -import ( - "github.com/prometheus/client_golang/prometheus" -) - -type Summary struct { - prometheus.Summary - - metricOpts MetricOpts - summaryOpts prometheus.SummaryOpts -} - -var _ Metric = &Summary{} - -// NewSummary creates a new Summary. The Summary must be registered with the -// Prometheus registry through RegisterMetrics. -func NewSummary(metricOpts MetricOpts, summaryOpts prometheus.SummaryOpts) *Summary { - return &Summary{ - Summary: prometheus.NewSummary(makePrometheusSummaryOpts(metricOpts, summaryOpts)), - metricOpts: metricOpts, - summaryOpts: summaryOpts, - } -} - -func makePrometheusSummaryOpts(metricOpts MetricOpts, summaryOpts prometheus.SummaryOpts) prometheus.SummaryOpts { - summaryOpts.Name = metricOpts.Name - summaryOpts.Help = metricOpts.Help - summaryOpts.ConstLabels = metricOpts.ConstLabels - return summaryOpts -} - -func (c *Summary) GetOpts() MetricOpts { - return c.metricOpts -} - -func (c *Summary) GetSummaryOpts() prometheus.SummaryOpts { - return c.summaryOpts -} - -func (c *Summary) GetType() MetricType { - return SummaryType -} - -func (c *Summary) GetBaseType() MetricType { - return SummaryType -} - -func (c *Summary) getCollector() prometheus.Collector { - return c.Summary -} diff --git a/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/summary_vec.go b/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/summary_vec.go deleted file mode 100644 index 6ea8bc542..000000000 --- a/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/summary_vec.go +++ /dev/null @@ -1,42 +0,0 @@ -package operatormetrics - -import "github.com/prometheus/client_golang/prometheus" - -type SummaryVec struct { - prometheus.SummaryVec - - metricOpts MetricOpts - summaryOpts prometheus.SummaryOpts -} - -var _ Metric = &SummaryVec{} - -// NewSummaryVec creates a new SummaryVec. The SummaryVec must be -// registered with the Prometheus registry through RegisterMetrics. -func NewSummaryVec(metricOpts MetricOpts, summaryOpts prometheus.SummaryOpts, labels []string) *SummaryVec { - return &SummaryVec{ - SummaryVec: *prometheus.NewSummaryVec(makePrometheusSummaryOpts(metricOpts, summaryOpts), labels), - metricOpts: metricOpts, - summaryOpts: summaryOpts, - } -} - -func (c *SummaryVec) GetOpts() MetricOpts { - return c.metricOpts -} - -func (c *SummaryVec) GetSummaryOpts() prometheus.SummaryOpts { - return c.summaryOpts -} - -func (c *SummaryVec) GetType() MetricType { - return SummaryVecType -} - -func (c *SummaryVec) GetBaseType() MetricType { - return SummaryType -} - -func (c *SummaryVec) getCollector() prometheus.Collector { - return c.SummaryVec -} diff --git a/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/wrapper_registry.go b/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/wrapper_registry.go deleted file mode 100644 index 8bb2b76e9..000000000 --- a/vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics/wrapper_registry.go +++ /dev/null @@ -1,166 +0,0 @@ -package operatormetrics - -import ( - "cmp" - "fmt" - "slices" -) - -var operatorRegistry = newRegistry() - -type operatorRegisterer struct { - registeredMetrics map[string]Metric - - registeredCollectors map[string]Collector - registeredCollectorMetrics map[string]Metric -} - -func newRegistry() operatorRegisterer { - return operatorRegisterer{ - registeredMetrics: map[string]Metric{}, - registeredCollectors: map[string]Collector{}, - registeredCollectorMetrics: map[string]Metric{}, - } -} - -// RegisterMetrics registers the metrics with the Prometheus registry. -func RegisterMetrics(allMetrics ...[]Metric) error { - for _, metricList := range allMetrics { - for _, metric := range metricList { - if metricExists(metric) { - err := unregisterMetric(metric) - if err != nil { - return err - } - } - - err := registerMetric(metric) - if err != nil { - return err - } - } - } - - return nil -} - -// RegisterCollector registers the collector with the Prometheus registry. -func RegisterCollector(collectors ...Collector) error { - for _, collector := range collectors { - if collectorExists(collector) { - err := unregisterCollector(collector) - if err != nil { - return err - } - } - - err := registerCollector(collector) - if err != nil { - return err - } - } - - return nil -} - -// ListMetrics returns a list of all registered metrics. -func ListMetrics() []Metric { - var result []Metric - - for _, rm := range operatorRegistry.registeredMetrics { - result = append(result, rm) - } - - for _, rc := range operatorRegistry.registeredCollectorMetrics { - result = append(result, rc) - } - - slices.SortFunc(result, func(a, b Metric) int { - return cmp.Compare(a.GetOpts().Name, b.GetOpts().Name) - }) - - return result -} - -// CleanRegistry removes all registered metrics. -func CleanRegistry() error { - for _, metric := range operatorRegistry.registeredMetrics { - err := unregisterMetric(metric) - if err != nil { - return err - } - } - - for _, collector := range operatorRegistry.registeredCollectors { - err := unregisterCollector(collector) - if err != nil { - return err - } - } - - return nil -} - -func metricExists(metric Metric) bool { - _, ok := operatorRegistry.registeredMetrics[metric.GetOpts().Name] - return ok -} - -func unregisterMetric(metric Metric) error { - if succeeded := Unregister(metric.getCollector()); succeeded { - delete(operatorRegistry.registeredMetrics, metric.GetOpts().Name) - return nil - } - - return fmt.Errorf("failed to unregister from Prometheus client metric %s", metric.GetOpts().Name) -} - -func registerMetric(metric Metric) error { - err := Register(metric.getCollector()) - if err != nil { - return err - } - operatorRegistry.registeredMetrics[metric.GetOpts().Name] = metric - - return nil -} - -func collectorExists(collector Collector) bool { - _, ok := operatorRegistry.registeredCollectors[collector.hash()] - return ok -} - -func unregisterCollector(collector Collector) error { - if succeeded := Unregister(collector); succeeded { - delete(operatorRegistry.registeredCollectors, collector.hash()) - for _, metric := range collector.Metrics { - delete(operatorRegistry.registeredCollectorMetrics, metric.GetOpts().Name) - } - return nil - } - - return fmt.Errorf("failed to unregister from Prometheus client collector with metrics: %s", buildCollectorMetricListString(collector)) -} - -func registerCollector(collector Collector) error { - err := Register(collector) - if err != nil { - return err - } - - operatorRegistry.registeredCollectors[collector.hash()] = collector - for _, cm := range collector.Metrics { - operatorRegistry.registeredCollectorMetrics[cm.GetOpts().Name] = cm - } - - return nil -} - -func buildCollectorMetricListString(collector Collector) string { - metricsList := "" - for _, metric := range collector.Metrics { - metricsList += metric.GetOpts().Name + ", " - } - metricsList = metricsList[:len(metricsList)-2] - return metricsList -} diff --git a/vendor/github.com/machadovilaca/operator-observability/pkg/operatorrules/BUILD.bazel b/vendor/github.com/machadovilaca/operator-observability/pkg/operatorrules/BUILD.bazel deleted file mode 100644 index 1f4b8a27a..000000000 --- a/vendor/github.com/machadovilaca/operator-observability/pkg/operatorrules/BUILD.bazel +++ /dev/null @@ -1,23 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -go_library( - name = "operatorrules", - srcs = [ - "prometheusrules.go", - "rbac.go", - "recordingrule.go", - "registry.go", - "schema.go", - ], - importmap = "github.com/konveyor/forklift-controller/vendor/github.com/machadovilaca/operator-observability/pkg/operatorrules", - importpath = "github.com/machadovilaca/operator-observability/pkg/operatorrules", - visibility = ["//visibility:public"], - deps = [ - "//vendor/github.com/machadovilaca/operator-observability/pkg/operatormetrics", - "//vendor/github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1:monitoring", - "//vendor/k8s.io/api/rbac/v1:rbac", - "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:meta", - "//vendor/k8s.io/apimachinery/pkg/runtime", - "//vendor/k8s.io/apimachinery/pkg/util/intstr", - ], -) diff --git a/vendor/github.com/machadovilaca/operator-observability/pkg/operatorrules/prometheusrules.go b/vendor/github.com/machadovilaca/operator-observability/pkg/operatorrules/prometheusrules.go deleted file mode 100644 index 88000e635..000000000 --- a/vendor/github.com/machadovilaca/operator-observability/pkg/operatorrules/prometheusrules.go +++ /dev/null @@ -1,76 +0,0 @@ -package operatorrules - -import ( - "cmp" - "fmt" - "slices" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - promv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" -) - -// BuildPrometheusRule builds a PrometheusRule object from the registered recording rules and alerts. -func BuildPrometheusRule(name, namespace string, labels map[string]string) (*promv1.PrometheusRule, error) { - spec, err := buildPrometheusRuleSpec() - if err != nil { - return nil, err - } - - return &promv1.PrometheusRule{ - TypeMeta: metav1.TypeMeta{ - APIVersion: promv1.SchemeGroupVersion.String(), - Kind: promv1.PrometheusRuleKind, - }, - ObjectMeta: metav1.ObjectMeta{ - Name: name, - Namespace: namespace, - Labels: labels, - }, - Spec: *spec, - }, nil -} - -func buildPrometheusRuleSpec() (*promv1.PrometheusRuleSpec, error) { - var groups []promv1.RuleGroup - - if len(operatorRegistry.registeredRecordingRules) != 0 { - groups = append(groups, promv1.RuleGroup{ - Name: "recordingRules.rules", - Rules: buildRecordingRulesRules(), - }) - } - - if len(operatorRegistry.registeredAlerts) != 0 { - groups = append(groups, promv1.RuleGroup{ - Name: "alerts.rules", - Rules: ListAlerts(), - }) - } - - if len(groups) == 0 { - return nil, fmt.Errorf("no registered recording rule or alert") - } - - return &promv1.PrometheusRuleSpec{Groups: groups}, nil -} - -func buildRecordingRulesRules() []promv1.Rule { - var rules []promv1.Rule - - for _, recordingRule := range operatorRegistry.registeredRecordingRules { - rules = append(rules, promv1.Rule{ - Record: recordingRule.MetricsOpts.Name, - Expr: recordingRule.Expr, - Labels: recordingRule.MetricsOpts.ConstLabels, - }) - } - - slices.SortFunc(rules, func(a, b promv1.Rule) int { - aKey := a.Record + ":" + a.Expr.String() - bKey := b.Record + ":" + b.Expr.String() - return cmp.Compare(aKey, bKey) - }) - - return rules -} diff --git a/vendor/github.com/machadovilaca/operator-observability/pkg/operatorrules/rbac.go b/vendor/github.com/machadovilaca/operator-observability/pkg/operatorrules/rbac.go deleted file mode 100644 index da582ceec..000000000 --- a/vendor/github.com/machadovilaca/operator-observability/pkg/operatorrules/rbac.go +++ /dev/null @@ -1,45 +0,0 @@ -package operatorrules - -import ( - rbacv1 "k8s.io/api/rbac/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -func BuildRoleAndRoleBinding(namePrefix, namespace, promSAName, promSANamespace string, labels map[string]string) (*rbacv1.Role, *rbacv1.RoleBinding) { - r := &rbacv1.Role{ - ObjectMeta: metav1.ObjectMeta{ - Name: namePrefix + "-role", - Namespace: namespace, - Labels: labels, - }, - Rules: []rbacv1.PolicyRule{ - { - APIGroups: []string{""}, - Resources: []string{"services", "endpoints", "pods"}, - Verbs: []string{"get", "list"}, - }, - }, - } - - rb := &rbacv1.RoleBinding{ - ObjectMeta: metav1.ObjectMeta{ - Name: namePrefix + "-rolebinding", - Namespace: namespace, - Labels: labels, - }, - RoleRef: rbacv1.RoleRef{ - Kind: "Role", - Name: namePrefix + "-role", - APIGroup: rbacv1.GroupName, - }, - Subjects: []rbacv1.Subject{ - { - Kind: "ServiceAccount", - Name: promSAName, - Namespace: promSANamespace, - }, - }, - } - - return r, rb -} diff --git a/vendor/github.com/machadovilaca/operator-observability/pkg/operatorrules/recordingrule.go b/vendor/github.com/machadovilaca/operator-observability/pkg/operatorrules/recordingrule.go deleted file mode 100644 index 8dfc50c3e..000000000 --- a/vendor/github.com/machadovilaca/operator-observability/pkg/operatorrules/recordingrule.go +++ /dev/null @@ -1,24 +0,0 @@ -package operatorrules - -import ( - "k8s.io/apimachinery/pkg/util/intstr" - - "github.com/machadovilaca/operator-observability/pkg/operatormetrics" -) - -// RecordingRule is a struct that represents a Prometheus recording rule. -type RecordingRule struct { - MetricsOpts operatormetrics.MetricOpts - MetricType operatormetrics.MetricType - Expr intstr.IntOrString -} - -// GetOpts returns the metric options of the recording rule. -func (c RecordingRule) GetOpts() operatormetrics.MetricOpts { - return c.MetricsOpts -} - -// GetType returns the metric type of the recording rule. -func (c RecordingRule) GetType() operatormetrics.MetricType { - return c.MetricType -} diff --git a/vendor/github.com/machadovilaca/operator-observability/pkg/operatorrules/registry.go b/vendor/github.com/machadovilaca/operator-observability/pkg/operatorrules/registry.go deleted file mode 100644 index fdef00604..000000000 --- a/vendor/github.com/machadovilaca/operator-observability/pkg/operatorrules/registry.go +++ /dev/null @@ -1,82 +0,0 @@ -package operatorrules - -import ( - "cmp" - "slices" - - promv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" -) - -var operatorRegistry = newRegistry() - -type operatorRegisterer struct { - registeredRecordingRules map[string]RecordingRule - registeredAlerts map[string]promv1.Rule -} - -func newRegistry() operatorRegisterer { - return operatorRegisterer{ - registeredRecordingRules: map[string]RecordingRule{}, - registeredAlerts: map[string]promv1.Rule{}, - } -} - -// RegisterRecordingRules registers the given recording rules. -func RegisterRecordingRules(recordingRules ...[]RecordingRule) error { - for _, recordingRuleList := range recordingRules { - for _, recordingRule := range recordingRuleList { - key := recordingRule.MetricsOpts.Name + ":" + recordingRule.Expr.String() - operatorRegistry.registeredRecordingRules[key] = recordingRule - } - } - - return nil -} - -// RegisterAlerts registers the given alerts. -func RegisterAlerts(alerts ...[]promv1.Rule) error { - for _, alertList := range alerts { - for _, alert := range alertList { - operatorRegistry.registeredAlerts[alert.Alert] = alert - } - } - - return nil -} - -// ListRecordingRules returns the registered recording rules. -func ListRecordingRules() []RecordingRule { - var rules []RecordingRule - for _, rule := range operatorRegistry.registeredRecordingRules { - rules = append(rules, rule) - } - - slices.SortFunc(rules, func(a, b RecordingRule) int { - aKey := a.GetOpts().Name + ":" + a.Expr.String() - bKey := b.GetOpts().Name + ":" + b.Expr.String() - - return cmp.Compare(aKey, bKey) - }) - - return rules -} - -// ListAlerts returns the registered alerts. -func ListAlerts() []promv1.Rule { - var alerts []promv1.Rule - for _, alert := range operatorRegistry.registeredAlerts { - alerts = append(alerts, alert) - } - - slices.SortFunc(alerts, func(a, b promv1.Rule) int { - return cmp.Compare(a.Alert, b.Alert) - }) - - return alerts -} - -// CleanRegistry removes all registered rules and alerts. -func CleanRegistry() error { - operatorRegistry = newRegistry() - return nil -} diff --git a/vendor/github.com/machadovilaca/operator-observability/pkg/operatorrules/schema.go b/vendor/github.com/machadovilaca/operator-observability/pkg/operatorrules/schema.go deleted file mode 100644 index c06a032d7..000000000 --- a/vendor/github.com/machadovilaca/operator-observability/pkg/operatorrules/schema.go +++ /dev/null @@ -1,22 +0,0 @@ -package operatorrules - -import ( - rbacv1 "k8s.io/api/rbac/v1" - "k8s.io/apimachinery/pkg/runtime" - - promv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" -) - -func AddToScheme(scheme *runtime.Scheme) error { - err := promv1.AddToScheme(scheme) - if err != nil { - return err - } - - err = rbacv1.AddToScheme(scheme) - if err != nil { - return err - } - - return nil -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 240aaf3da..1279af347 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -211,10 +211,6 @@ github.com/klauspost/cpuid/v2 # github.com/leodido/go-urn v1.2.4 ## explicit; go 1.16 github.com/leodido/go-urn -# github.com/machadovilaca/operator-observability v0.0.20 -## explicit; go 1.21 -github.com/machadovilaca/operator-observability/pkg/operatormetrics -github.com/machadovilaca/operator-observability/pkg/operatorrules # github.com/mailru/easyjson v0.7.7 ## explicit; go 1.12 github.com/mailru/easyjson/buffer @@ -354,6 +350,8 @@ github.com/pkg/errors # github.com/pkg/profile v1.7.0 ## explicit; go 1.13 github.com/pkg/profile +# github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 +## explicit # github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.68.0 ## explicit; go 1.17 github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring