mirror of
https://github.com/gitpod-io/gitpod.git
synced 2025-12-08 17:36:30 +00:00
50 lines
1.4 KiB
Go
50 lines
1.4 KiB
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 proxy
|
|
|
|
import (
|
|
"strconv"
|
|
"time"
|
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
)
|
|
|
|
func reportConnectionDuration(d time.Duration) {
|
|
proxyConnectionCreateDurationSeconds.Observe(d.Seconds())
|
|
}
|
|
|
|
var (
|
|
proxyConnectionCreateDurationSeconds = prometheus.NewHistogram(prometheus.HistogramOpts{
|
|
Namespace: "gitpod",
|
|
Subsystem: "public_api",
|
|
Name: "proxy_connection_create_duration_seconds",
|
|
Help: "Histogram of connection time in seconds",
|
|
})
|
|
|
|
connectionPoolSize = prometheus.NewGauge(prometheus.GaugeOpts{
|
|
Namespace: "gitpod",
|
|
Subsystem: "public_api",
|
|
Name: "proxy_connection_pool_size",
|
|
Help: "Gauge of connections in connection pool",
|
|
})
|
|
|
|
connectionPoolCacheOutcome = prometheus.NewCounterVec(prometheus.CounterOpts{
|
|
Namespace: "gitpod",
|
|
Subsystem: "public_api",
|
|
Name: "proxy_connection_pool_cache_outcomes_total",
|
|
Help: "Counter of cachce accesses",
|
|
}, []string{"hit"})
|
|
)
|
|
|
|
func RegisterMetrics(registry *prometheus.Registry) {
|
|
registry.MustRegister(proxyConnectionCreateDurationSeconds)
|
|
registry.MustRegister(connectionPoolSize)
|
|
registry.MustRegister(connectionPoolCacheOutcome)
|
|
}
|
|
|
|
func reportCacheOutcome(hit bool) {
|
|
connectionPoolCacheOutcome.WithLabelValues(strconv.FormatBool(hit)).Inc()
|
|
}
|