Path: blob/main/components/public-api-server/pkg/proxy/prometheusmetrics.go
2500 views
// Copyright (c) 2022 Gitpod GmbH. All rights reserved.1// Licensed under the GNU Affero General Public License (AGPL).2// See License.AGPL.txt in the project root for license information.34package proxy56import (7"strconv"8"time"910"github.com/prometheus/client_golang/prometheus"11)1213func reportConnectionDuration(d time.Duration) {14proxyConnectionCreateDurationSeconds.Observe(d.Seconds())15}1617var (18proxyConnectionCreateDurationSeconds = prometheus.NewHistogram(prometheus.HistogramOpts{19Namespace: "gitpod",20Subsystem: "public_api",21Name: "proxy_connection_create_duration_seconds",22Help: "Histogram of connection time in seconds",23})2425connectionPoolSize = prometheus.NewGauge(prometheus.GaugeOpts{26Namespace: "gitpod",27Subsystem: "public_api",28Name: "proxy_connection_pool_size",29Help: "Gauge of connections in connection pool",30})3132connectionPoolCacheOutcome = prometheus.NewCounterVec(prometheus.CounterOpts{33Namespace: "gitpod",34Subsystem: "public_api",35Name: "proxy_connection_pool_cache_outcomes_total",36Help: "Counter of cachce accesses",37}, []string{"hit"})38)3940func RegisterMetrics(registry *prometheus.Registry) {41registry.MustRegister(proxyConnectionCreateDurationSeconds)42registry.MustRegister(connectionPoolSize)43registry.MustRegister(connectionPoolCacheOutcome)44}4546func reportCacheOutcome(hit bool) {47connectionPoolCacheOutcome.WithLabelValues(strconv.FormatBool(hit)).Inc()48}495051