diff options
-rw-r--r-- | acceptance_test.go | 7 | ||||
-rw-r--r-- | internal/httprange/transport.go | 26 | ||||
-rw-r--r-- | metrics/metrics.go | 11 |
3 files changed, 28 insertions, 16 deletions
diff --git a/acceptance_test.go b/acceptance_test.go index 7817bf81..e131d6de 100644 --- a/acceptance_test.go +++ b/acceptance_test.go @@ -487,8 +487,15 @@ func TestPrometheusMetricsCanBeScraped(t *testing.T) { require.Contains(t, string(body), "gitlab_pages_serving_time_seconds_sum") require.Contains(t, string(body), `gitlab_pages_domains_source_api_requests_total{status_code="200"}`) require.Contains(t, string(body), `gitlab_pages_domains_source_api_call_duration{status_code="200"}`) + // object storage require.Contains(t, string(body), `gitlab_pages_object_storage_backend_requests_total{status_code="206"}`) require.Contains(t, string(body), `gitlab_pages_object_storage_backend_requests_duration{status_code="206"}`) + require.Contains(t, string(body), `gitlab_pages_object_storage_backend_request_responsiveness_ms_count`) + require.Contains(t, string(body), `gitlab_pages_object_storage_open_zip_archives_total`) + require.Contains(t, string(body), `gitlab_pages_object_storage_failed_open_zip_archives_total`) + require.Contains(t, string(body), `gitlab_pages_object_storage_files_per_zip_archive`) + require.Contains(t, string(body), `gitlab_pages_object_storage_zip_archive_cache_hit`) + require.Contains(t, string(body), `gitlab_pages_object_storage_zip_archive_cache_miss`) } func TestDisabledRedirects(t *testing.T) { diff --git a/internal/httprange/transport.go b/internal/httprange/transport.go index ffe47d7c..90c1a46c 100644 --- a/internal/httprange/transport.go +++ b/internal/httprange/transport.go @@ -26,37 +26,37 @@ func (tr *tracedTransport) RoundTrip(r *http.Request) (*http.Response, error) { func newTracer(start time.Time) *httptrace.ClientTrace { trace := &httptrace.ClientTrace{ GetConn: func(host string) { - metrics.ObjectStorageResponsiveness.WithLabelValues("get_connection").Observe(float64(time.Since(start))) + observe("get_connection", start) log.WithFields(log.Fields{ "host": host, }).Traceln("get_connection") }, GotConn: func(connInfo httptrace.GotConnInfo) { - metrics.ObjectStorageResponsiveness.WithLabelValues("get_connection").Observe(float64(time.Since(start))) + observe("get_connection", start) log.WithFields(log.Fields{ "reused": connInfo.Reused, "was_idle": connInfo.WasIdle, "idle_time_ms": connInfo.IdleTime.Milliseconds(), - }).Traceln("got_connection") + }).Traceln("get_connection") }, PutIdleConn: nil, GotFirstResponseByte: func() { - metrics.ObjectStorageResponsiveness.WithLabelValues("got_first_response_byte").Observe(float64(time.Since(start))) + observe("got_first_response_byte", start) }, Got100Continue: nil, Got1xxResponse: nil, DNSStart: func(d httptrace.DNSStartInfo) { - metrics.ObjectStorageResponsiveness.WithLabelValues("dns_lookup_start").Observe(float64(time.Since(start))) + observe("dns_lookup_start", start) }, DNSDone: func(d httptrace.DNSDoneInfo) { - metrics.ObjectStorageResponsiveness.WithLabelValues("dns_lookup_done").Observe(float64(time.Since(start))) + observe("dns_lookup_done", start) - log.WithFields(log.Fields{}).WithError(d.Err).Traceln("connect_start") + log.WithFields(log.Fields{}).WithError(d.Err).Traceln("dns_lookup_done") }, ConnectStart: func(net, addr string) { - metrics.ObjectStorageResponsiveness.WithLabelValues("connect_start").Observe(float64(time.Since(start))) + observe("connect_start", start) log.WithFields(log.Fields{ "network": net, @@ -64,7 +64,7 @@ func newTracer(start time.Time) *httptrace.ClientTrace { }).Traceln("connect_start") }, ConnectDone: func(net string, addr string, err error) { - metrics.ObjectStorageResponsiveness.WithLabelValues("connect_done").Observe(float64(time.Since(start))) + observe("connect_done", start) log.WithFields(log.Fields{ "network": net, @@ -72,10 +72,10 @@ func newTracer(start time.Time) *httptrace.ClientTrace { }).WithError(err).Traceln("connect_done") }, TLSHandshakeStart: func() { - metrics.ObjectStorageResponsiveness.WithLabelValues("tls_handshake_start").Observe(float64(time.Since(start))) + observe("tls_handshake_start", start) }, TLSHandshakeDone: func(connState tls.ConnectionState, err error) { - metrics.ObjectStorageResponsiveness.WithLabelValues("tls_handshake_done").Observe(float64(time.Since(start))) + observe("tls_handshake_done", start) log.WithFields(log.Fields{ "version": connState.Version, @@ -90,3 +90,7 @@ func newTracer(start time.Time) *httptrace.ClientTrace { return trace } + +func observe(label string, start time.Time) { + metrics.ObjectStorageResponsiveness.WithLabelValues(label).Observe(float64(time.Since(start).Milliseconds())) +} diff --git a/metrics/metrics.go b/metrics/metrics.go index b1d10f2f..6f46c6c2 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -113,11 +113,12 @@ var ( Help: "The time (in seconds) it takes to get a response from the Object Storage provider for zip file serving", }, []string{"status_code"}) - // ObjectStorageResponsiveness Object Storage request responsiveness for different stages of an http request - // see httptrace.ClientTrace + // ObjectStorageResponsiveness Object Storage request responsiveness in ms for different stages of an http request + // see httptrace.ClientTrac ObjectStorageResponsiveness = prometheus.NewHistogramVec(prometheus.HistogramOpts{ - Name: "gitlab_pages_object_storage_backend_request_responsiveness", - Help: "Object Storage request responsiveness for different stages (TLS Handshake,response write, etc)", + Name: "gitlab_pages_object_storage_backend_request_responsiveness_ms", + Help: "Object Storage request responsiveness for different stages (TLS Handshake,response write, etc)", + Buckets: []float64{1, 5, 10, 20, 50, 100, 250, 500, 1000, 2000, 5000, 10000, 20000}, }, []string{"request_stage"}) // ZipServingOpenArchivesTotal is the number of zip archives that have been opened @@ -137,7 +138,7 @@ var ( Name: "gitlab_pages_object_storage_files_per_zip_archive", Help: "The number of files per zip archive", // squared buckets up to 2^13 - Buckets: prometheus.ExponentialBuckets(2, 2, 13), + Buckets: prometheus.ExponentialBuckets(1, 2, 14), }) // ZipServingArchiveCacheHit is the number of zip archive cache hits |