Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Shushlin <vshushlin@gitlab.com>2020-02-05 11:43:47 +0300
committerVladimir Shushlin <vshushlin@gitlab.com>2020-02-05 11:43:47 +0300
commitb7b8f51a6bb5de9f5bea0066f72333980700353d (patch)
tree95b753f685849ecf385284d5e3a427df93ab722c /internal
parent711b882cdd7790281e431de1d77784ba53063a99 (diff)
parentf6f21d80e32393100993900efde1fa072386e738 (diff)
Merge branch 'feature/gb/add-serveress-metrics' into 'master'
Add serverless serving metrics Closes #346 See merge request gitlab-org/gitlab-pages!231
Diffstat (limited to 'internal')
-rw-r--r--internal/serving/serverless/serverless.go3
-rw-r--r--internal/serving/serverless/transport.go7
2 files changed, 9 insertions, 1 deletions
diff --git a/internal/serving/serverless/serverless.go b/internal/serving/serverless/serverless.go
index a8d090da..a73affeb 100644
--- a/internal/serving/serverless/serverless.go
+++ b/internal/serving/serverless/serverless.go
@@ -5,6 +5,7 @@ import (
"gitlab.com/gitlab-org/gitlab-pages/internal/httperrors"
"gitlab.com/gitlab-org/gitlab-pages/internal/serving"
+ "gitlab.com/gitlab-org/gitlab-pages/metrics"
)
// Serverless is a servering used to proxy requests between a client and
@@ -26,6 +27,8 @@ func New(function Function, cluster Cluster) serving.Serving {
// ServeFileHTTP handle an incoming request and proxies it to Knative cluster
func (s *Serverless) ServeFileHTTP(h serving.Handler) bool {
+ metrics.ServerlessRequests.Inc()
+
s.proxy.ServeHTTP(h.Writer, h.Request)
return true
diff --git a/internal/serving/serverless/transport.go b/internal/serving/serverless/transport.go
index 5a0f5165..b7fabb13 100644
--- a/internal/serving/serverless/transport.go
+++ b/internal/serving/serverless/transport.go
@@ -5,6 +5,8 @@ import (
"net"
"net/http"
"time"
+
+ "gitlab.com/gitlab-org/gitlab-pages/metrics"
)
// Transport is a struct that handle the proxy connection round trip to Knative
@@ -39,8 +41,11 @@ func NewTransport(cluster Cluster) *Transport {
// RoundTrip performs a connection to a Knative cluster and returns a response
func (t *Transport) RoundTrip(request *http.Request) (*http.Response, error) {
+ start := time.Now()
+
response, err := t.transport.RoundTrip(request)
- // TODO add prometheus metrics for round trip timing
+ metrics.ServerlessLatency.Observe(time.Since(start).Seconds())
+
return response, err
}