Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/apiproxy/ytsaurus.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (

ytv1 "github.com/ytsaurus/ytsaurus-k8s-operator/api/v1"
"github.com/ytsaurus/ytsaurus-k8s-operator/pkg/consts"
"github.com/ytsaurus/ytsaurus-k8s-operator/pkg/metrics"
)

type Ytsaurus struct {
Expand Down Expand Up @@ -241,8 +242,10 @@ func (c *Ytsaurus) UpdateOnDeleteComponentsSummary(ctx context.Context, waitingO
summaryParts = append(summaryParts, fmt.Sprintf("{%s (waiting %s)}",
componentName,
waitingDuration.Truncate(time.Second).String()))
metrics.ObserveOnDeleteWait(c.GetResource().Name, componentName, &condition.LastTransitionTime)
} else {
summaryParts = append(summaryParts, fmt.Sprintf("{%s}", componentName))
metrics.ObserveOnDeleteWait(c.GetResource().Name, componentName, nil)
}
}
}
Expand Down
33 changes: 33 additions & 0 deletions pkg/metrics/update_strategy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package metrics

import (
"time"

"github.com/prometheus/client_golang/prometheus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
ctrlmetrics "sigs.k8s.io/controller-runtime/pkg/metrics"
)

//nolint:gochecknoglobals // Prometheus metrics are package-level for registration and reuse.
var onDeleteWaitSeconds = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: "ytop",
Subsystem: "update_strategy",
Name: "on_delete_wait_seconds",
Help: "Seconds a component has been waiting in OnDelete mode since the mode started.",
},
[]string{"cluster", "component"},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's pass
"cluster_namespace"
"cluster"
"component"
"component_name" - instance group name/role for proxies and nodes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's have "cluster", "cluster_namespace" and "component_name". component_name will be either StatefulSet/Deployment short name (ms/hp) or short name with instance group name/role for proxies and nodes (default role is omitted).
example:

ytop_strategy_on_delete_waiting_time_seconds{cluster="test-ytsaurus",cluster_name
space="test-e2e-mfwbj",component_name="hp"}
ytop_strategy_on_delete_waiting_time_seconds{cluster="test-ytsaurus",cluster_name
space="test-e2e-mfwbj",component_name="hp-o11y"}

)

func init() {
ctrlmetrics.Registry.MustRegister(onDeleteWaitSeconds)
}

func ObserveOnDeleteWait(cluster, component string, startedAt *metav1.Time) {
lbl := []string{cluster, component}
if startedAt == nil || startedAt.IsZero() {
onDeleteWaitSeconds.DeleteLabelValues(lbl...)
return
}
onDeleteWaitSeconds.WithLabelValues(lbl...).Set(time.Since(startedAt.Time).Seconds())
}
Loading