mirror of
https://github.com/gitpod-io/gitpod.git
synced 2025-12-08 17:36:30 +00:00
40 lines
988 B
Go
40 lines
988 B
Go
// Copyright (c) 2022 Gitpod GmbH. All rights reserved.
|
|
// Licensed under the GNU Affero General Public License (AGPL).
|
|
// See License-AGPL.txt in the project root for license information.
|
|
|
|
package metrics
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
)
|
|
|
|
type SupervisorMetrics struct {
|
|
IDEReadyDurationTotal *prometheus.HistogramVec
|
|
}
|
|
|
|
func NewMetrics() *SupervisorMetrics {
|
|
return &SupervisorMetrics{
|
|
IDEReadyDurationTotal: prometheus.NewHistogramVec(prometheus.HistogramOpts{
|
|
Name: "supervisor_ide_ready_duration_total",
|
|
Help: "the IDE startup time",
|
|
Buckets: []float64{0.1, 0.5, 1, 1.5, 2, 2.5, 5, 10},
|
|
}, []string{"kind"}),
|
|
}
|
|
}
|
|
|
|
func (m *SupervisorMetrics) Register(registry *prometheus.Registry) error {
|
|
metrics := []prometheus.Collector{
|
|
m.IDEReadyDurationTotal,
|
|
}
|
|
|
|
for _, metric := range metrics {
|
|
err := registry.Register(metric)
|
|
if err != nil {
|
|
return fmt.Errorf("failed to register metric: %w", err)
|
|
}
|
|
}
|
|
return nil
|
|
}
|