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:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2020-02-12 14:51:07 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2020-02-12 14:51:07 +0300
commit8cc214da3afaf3d30787fe6b8d2c20f240ad2245 (patch)
tree2158d307ec7530bc946b057fa172c953a2a59ba5 /internal/serving
parentefc9707333679aecf36b38f6f53dd0a0e52698eb (diff)
parent1f685661c2d6b51d9978d4c83a147a51bd64f1ad (diff)
Merge branch 'master' into feature/gb/serverless-serving-enable
* master: Add prometheus metrics for GitLab API client Fix benchmarks Freeze tools version Add acceptance test for serverless metrics Update documentation on using Gorilla ProxyHeaders use gorilla/handlers.ProxyHeaders to get the X-Forwarded-* headers and set them in the appropriate http.Request fields Apply suggestion to metrics/metrics.go Add serverless serving metrics Conflicts: internal/serving/serverless/serverless.go
Diffstat (limited to 'internal/serving')
-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 3c360054..bec6db16 100644
--- a/internal/serving/serverless/serverless.go
+++ b/internal/serving/serverless/serverless.go
@@ -7,6 +7,7 @@ import (
"gitlab.com/gitlab-org/gitlab-pages/internal/httperrors"
"gitlab.com/gitlab-org/gitlab-pages/internal/serving"
"gitlab.com/gitlab-org/gitlab-pages/internal/source/gitlab/api"
+ "gitlab.com/gitlab-org/gitlab-pages/metrics"
)
// Serverless is a servering used to proxy requests between a client and
@@ -55,6 +56,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
}