diff options
-rw-r--r-- | acceptance_test.go | 1 | ||||
-rw-r--r-- | app.go | 6 | ||||
-rw-r--r-- | metrics/metrics.go | 7 |
3 files changed, 12 insertions, 2 deletions
diff --git a/acceptance_test.go b/acceptance_test.go index 4e773566..79a9b275 100644 --- a/acceptance_test.go +++ b/acceptance_test.go @@ -403,6 +403,7 @@ func TestPrometheusMetricsCanBeScraped(t *testing.T) { require.Contains(t, string(body), "gitlab_pages_domains_configuration_update_duration gauge") require.Contains(t, string(body), "gitlab_pages_domains_source_cache_hit 0") require.Contains(t, string(body), "gitlab_pages_domains_source_cache_miss 0") + require.Contains(t, string(body), "gitlab_pages_domains_source_failures_total 0") require.Contains(t, string(body), "gitlab_pages_serverless_requests 0") require.Contains(t, string(body), "gitlab_pages_serverless_latency_sum 0") } @@ -11,7 +11,7 @@ import ( "github.com/rs/cors" log "github.com/sirupsen/logrus" "gitlab.com/gitlab-org/labkit/errortracking" - "gitlab.com/gitlab-org/labkit/metrics" + labmetrics "gitlab.com/gitlab-org/labkit/metrics" mimedb "gitlab.com/lupine/go-mimedb" "gitlab.com/gitlab-org/gitlab-pages/internal/acme" @@ -25,6 +25,7 @@ import ( "gitlab.com/gitlab-org/gitlab-pages/internal/netutil" "gitlab.com/gitlab-org/gitlab-pages/internal/request" "gitlab.com/gitlab-org/gitlab-pages/internal/source" + "gitlab.com/gitlab-org/gitlab-pages/metrics" ) const ( @@ -159,6 +160,7 @@ func (a *theApp) routingMiddleware(handler http.Handler) http.Handler { // middleware chain and simply respond with 502 after logging this host, domain, err := a.getHostAndDomain(r) if err != nil { + metrics.DomainsSourceFailures.Inc() log.WithError(err).Error("could not fetch domain information from a source") httperrors.Serve502(w) @@ -331,7 +333,7 @@ func (a *theApp) buildHandlerPipeline() (http.Handler, error) { } // Metrics - metricsMiddleware := metrics.NewHandlerFactory(metrics.WithNamespace("gitlab_pages")) + metricsMiddleware := labmetrics.NewHandlerFactory(labmetrics.WithNamespace("gitlab_pages")) handler = metricsMiddleware(handler) handler = a.routingMiddleware(handler) diff --git a/metrics/metrics.go b/metrics/metrics.go index 7ae50c81..bb14de04 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -47,6 +47,12 @@ var ( Help: "The number of GitLab domains API cache misses", }) + // DomainsSourceFailures is the number of GitLab API calls that failed + DomainsSourceFailures = prometheus.NewCounter(prometheus.CounterOpts{ + Name: "gitlab_pages_domains_source_failures_total", + Help: "The number of GitLab API calls that failed", + }) + // ServerlessRequests measures the amount of serverless invocations ServerlessRequests = prometheus.NewCounter(prometheus.CounterOpts{ Name: "gitlab_pages_serverless_requests", @@ -84,6 +90,7 @@ func MustRegister() { DomainsSourceCacheMiss, DomainsSourceAPIReqTotal, DomainsSourceAPICallDuration, + DomainsSourceFailures, ServerlessRequests, ServerlessLatency, ) |