From 3876fd26eec27c502df0f0c252b41d136bbaf0e1 Mon Sep 17 00:00:00 2001 From: bitliu Date: Fri, 27 Oct 2023 14:29:55 +0800 Subject: [PATCH] update Signed-off-by: bitliu --- internal/gatewayapi/runner/runner.go | 2 +- internal/message/metrics.go | 8 ++++---- internal/message/watchutil.go | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/internal/gatewayapi/runner/runner.go b/internal/gatewayapi/runner/runner.go index 9a03f7228908..60e2ce575ecc 100644 --- a/internal/gatewayapi/runner/runner.go +++ b/internal/gatewayapi/runner/runner.go @@ -49,7 +49,7 @@ func (r *Runner) Start(ctx context.Context) (err error) { } func (r *Runner) subscribeAndTranslate(ctx context.Context) { - message.HandleSubscription(message.Metadata{Runner: string(v1alpha1.LogComponentGatewayAPIRunner), Resource: "gatewayapi-resources"}, r.ProviderResources.GatewayAPIResources.Subscribe(ctx), + message.HandleSubscription(message.Metadata{Runner: string(v1alpha1.LogComponentGatewayAPIRunner), Resource: "provider-resources"}, r.ProviderResources.GatewayAPIResources.Subscribe(ctx), func(update message.Update[string, *gatewayapi.Resources], errChan chan error) { r.Logger.Info("received an update") diff --git a/internal/message/metrics.go b/internal/message/metrics.go index 7dd34f2adc72..6b7db2521d56 100644 --- a/internal/message/metrics.go +++ b/internal/message/metrics.go @@ -8,13 +8,13 @@ package message import "github.com/envoyproxy/gateway/internal/metrics" var ( - messageDepth = metrics.NewGauge("message_depth", "Current depth of message queue.") + watchableDepth = metrics.NewGauge("watchable_depth", "Current depth of watchable queue.") - messageSubscribedDurationSeconds = metrics.NewHistogram("message_subscribed_duration_seconds", "How long in seconds a subscribed message is handled.", []float64{0.001, 0.01, 0.1, 1, 5, 10}) + watchableSubscribedDurationSeconds = metrics.NewHistogram("watchable_subscribed_duration_seconds", "How long in seconds a subscribed watchable is handled.", []float64{0.001, 0.01, 0.1, 1, 5, 10}) - messageSubscribedTotal = metrics.NewCounter("message_subscribed_total", "Total number of subscribed message.") + watchableSubscribedTotal = metrics.NewCounter("watchable_subscribed_total", "Total number of subscribed watchable.") - messageSubscribedErrorsTotal = metrics.NewCounter("message_subscribed_errors_total", "Total number of subscribed message errors.") + watchableSubscribedErrorsTotal = metrics.NewCounter("watchable_subscribed_errors_total", "Total number of subscribed watchable errors.") runnerLabel = metrics.NewLabel("runner") diff --git a/internal/message/watchutil.go b/internal/message/watchutil.go index 33db1bd21b82..abd174396cdc 100644 --- a/internal/message/watchutil.go +++ b/internal/message/watchutil.go @@ -25,7 +25,7 @@ type Metadata struct { } func (m Metadata) LabelValues() []metrics.LabelValue { - labels := []metrics.LabelValue{} + labels := make([]metrics.LabelValue, 0, 2) if m.Runner != "" { labels = append(labels, runnerLabel.Value(m.Runner)) } @@ -53,7 +53,7 @@ func HandleSubscription[K comparable, V any]( go func() { for err := range errChans { logger.WithValues("runner", meta.Runner).Error(err, "observed an error") - messageSubscribedErrorsTotal.With(meta.LabelValues()...).Increment() + watchableSubscribedErrorsTotal.With(meta.LabelValues()...).Increment() } }() @@ -64,17 +64,17 @@ func HandleSubscription[K comparable, V any]( Key: k, Value: v, }, errChans) - messageSubscribedTotal.With(meta.LabelValues()...).Increment() - messageSubscribedDurationSeconds.With(meta.LabelValues()...).Record(time.Since(startHandleTime).Seconds()) + watchableSubscribedTotal.With(meta.LabelValues()...).Increment() + watchableSubscribedDurationSeconds.With(meta.LabelValues()...).Record(time.Since(startHandleTime).Seconds()) } } for snapshot := range subscription { - messageDepth.With(meta.LabelValues()...).Record(float64(len(subscription))) + watchableDepth.With(meta.LabelValues()...).Record(float64(len(subscription))) for _, update := range snapshot.Updates { startHandleTime := time.Now() handle(Update[K, V](update), errChans) - messageSubscribedTotal.With(meta.LabelValues()...).Increment() - messageSubscribedDurationSeconds.With(meta.LabelValues()...).Record(time.Since(startHandleTime).Seconds()) + watchableSubscribedTotal.With(meta.LabelValues()...).Increment() + watchableSubscribedDurationSeconds.With(meta.LabelValues()...).Record(time.Since(startHandleTime).Seconds()) } } }