Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksontong committed Jul 16, 2024
1 parent 80d7664 commit 7b40422
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
1 change: 1 addition & 0 deletions pkg/application/controller/app/action/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func Install(ctx context.Context,
return nil, err
}

// 能看日志,是不是有限流?
destfile, err := Pull(ctx, applicationClient, platformClient, app, repo, updateStatusFunc)
if err != nil {
newStatus := app.Status.DeepCopy()
Expand Down
25 changes: 13 additions & 12 deletions pkg/util/metrics/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ package metrics

import (
"fmt"

"sync"

"github.com/prometheus/client_golang/prometheus"
"k8s.io/client-go/util/flowcontrol"
"sigs.k8s.io/controller-runtime/pkg/metrics"
compbasemetrics "k8s.io/component-base/metrics"
"k8s.io/component-base/metrics/legacyregistry"
)

var (
Expand All @@ -36,7 +37,7 @@ var (
)

type rateLimiterMetric struct {
metric prometheus.Gauge
metric *compbasemetrics.Gauge
stopCh chan struct{}
}

Expand All @@ -48,12 +49,12 @@ func registerRateLimiterMetric(ownerName string) error {
// only register once in Prometheus. We happen to see an ownerName reused in parallel integration tests.
return nil
}
metric := prometheus.NewGauge(prometheus.GaugeOpts{
metric := compbasemetrics.NewGauge(&compbasemetrics.GaugeOpts{
Name: "rate_limiter_use",
Subsystem: ownerName,
Help: fmt.Sprintf("A metric measuring the saturation of the rate limiter for %v", ownerName),
})
if err := prometheus.Register(metric); err != nil {
if err := legacyregistry.Register(metric); err != nil {
return fmt.Errorf("error registering rate limiter usage metric: %v", err)
}
stopCh := make(chan struct{})
Expand Down Expand Up @@ -81,33 +82,33 @@ func RegisterMetricAndTrackRateLimiterUsage(ownerName string, rateLimiter flowco
}

var (
GaugeApplicationInstallFailed = prometheus.NewGaugeVec(prometheus.GaugeOpts{
GaugeApplicationInstallFailed = compbasemetrics.NewGaugeVec(&compbasemetrics.GaugeOpts{
Name: "applicationInstallFailed",
Help: "application install failed count",
}, []string{"cluster", "application"})
GaugeApplicationManifestFailed = prometheus.NewGaugeVec(prometheus.GaugeOpts{
GaugeApplicationManifestFailed = compbasemetrics.NewGaugeVec(&compbasemetrics.GaugeOpts{
Name: "applicationManifestFailed",
Help: "application manifest failed",
}, []string{"cluster", "application"})
GaugeApplicationUpgradeFailed = prometheus.NewGaugeVec(prometheus.GaugeOpts{
GaugeApplicationUpgradeFailed = compbasemetrics.NewGaugeVec(&compbasemetrics.GaugeOpts{
Name: "applicationUpgradeFailed",
Help: "application upgrade failed count",
}, []string{"cluster", "application"})
GaugeApplicationDaemonsetUpgradeFailed = prometheus.NewGaugeVec(prometheus.GaugeOpts{
GaugeApplicationDaemonsetUpgradeFailed = compbasemetrics.NewGaugeVec(&compbasemetrics.GaugeOpts{
Name: "applicationDaemonsetUpgradeFailed",
Help: "application daemonset upgrade failed count",
}, []string{"cluster", "application"})
GaugeApplicationRollbackFailed = prometheus.NewGaugeVec(prometheus.GaugeOpts{
GaugeApplicationRollbackFailed = compbasemetrics.NewGaugeVec(&compbasemetrics.GaugeOpts{
Name: "applicationRollbackFailed",
Help: "application rollback failed count",
}, []string{"cluster", "application"})
GaugeApplicationSyncFailed = prometheus.NewGaugeVec(prometheus.GaugeOpts{
GaugeApplicationSyncFailed = compbasemetrics.NewGaugeVec(&compbasemetrics.GaugeOpts{
Name: "applicationSyncFailed",
Help: "application sync failed count",
}, []string{"cluster", "application"})
)

func init() {
// Register the summary and the histogram with Prometheus's default registry.
metrics.Registry.MustRegister(GaugeApplicationInstallFailed, GaugeApplicationUpgradeFailed, GaugeApplicationDaemonsetUpgradeFailed, GaugeApplicationRollbackFailed, GaugeApplicationSyncFailed, GaugeApplicationManifestFailed)
legacyregistry.MustRegister(GaugeApplicationInstallFailed, GaugeApplicationUpgradeFailed, GaugeApplicationDaemonsetUpgradeFailed, GaugeApplicationRollbackFailed, GaugeApplicationSyncFailed, GaugeApplicationManifestFailed)
}

0 comments on commit 7b40422

Please sign in to comment.