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:
authorJaime Martinez <jmartinez@gitlab.com>2020-09-29 09:44:16 +0300
committerJaime Martinez <jmartinez@gitlab.com>2020-09-30 07:33:27 +0300
commit8dcfd518cf1a1a5f570fe43718a3cff8d8cd5ca0 (patch)
tree3834b69d2ceceb7c6ab71375e542b0f6ec96b0c6 /internal/vfs
parent2e9bd40bd61de95cbb8c7e598c71753d3f7475cb (diff)
Add more metrics for zip serving
Adds a bunch of new metrics related to https://gitlab.com/gitlab-org/gitlab-pages/-/issues/423. It uses [httptrace.ClienTrace](https://golang.org/src/net/http/httptrace/trace.go) to add a bunch of very granular metrics that happen when an http connection is established.
Diffstat (limited to 'internal/vfs')
-rw-r--r--internal/vfs/zip/archive.go4
-rw-r--r--internal/vfs/zip/vfs.go13
2 files changed, 16 insertions, 1 deletions
diff --git a/internal/vfs/zip/archive.go b/internal/vfs/zip/archive.go
index ce7d2ec8..cfcdee76 100644
--- a/internal/vfs/zip/archive.go
+++ b/internal/vfs/zip/archive.go
@@ -16,6 +16,7 @@ import (
"gitlab.com/gitlab-org/gitlab-pages/internal/httprange"
"gitlab.com/gitlab-org/gitlab-pages/internal/vfs"
+ "gitlab.com/gitlab-org/gitlab-pages/metrics"
)
const (
@@ -127,6 +128,9 @@ func (a *zipArchive) readArchive() {
// recycle memory
a.archive.File = nil
+
+ metrics.ZipServingFilesPerArchiveCount.Observe(float64(len(a.files)))
+ metrics.ZipServingOpenArchivesTotal.Inc()
}
func (a *zipArchive) findFile(name string) *zip.File {
diff --git a/internal/vfs/zip/vfs.go b/internal/vfs/zip/vfs.go
index 283e01c2..ce7a1477 100644
--- a/internal/vfs/zip/vfs.go
+++ b/internal/vfs/zip/vfs.go
@@ -9,6 +9,7 @@ import (
"github.com/patrickmn/go-cache"
"gitlab.com/gitlab-org/gitlab-pages/internal/vfs"
+ "gitlab.com/gitlab-org/gitlab-pages/metrics"
)
const (
@@ -69,6 +70,8 @@ func (fs *zipVFS) Name() string {
func (fs *zipVFS) findOrOpenArchive(ctx context.Context, path string) (*zipArchive, error) {
archive, expiry, found := fs.cache.GetWithExpiration(path)
if found {
+ metrics.ZipServingArchiveCacheHit.Inc()
+
// TODO: do not refreshed errored archives https://gitlab.com/gitlab-org/gitlab-pages/-/merge_requests/351
if time.Until(expiry) < defaultCacheRefreshInterval {
// refresh item
@@ -82,9 +85,17 @@ func (fs *zipVFS) findOrOpenArchive(ctx context.Context, path string) (*zipArchi
if fs.cache.Add(path, archive, cache.DefaultExpiration) != nil {
return nil, errAlreadyCached
}
+
+ metrics.ZipServingArchiveCacheMiss.Inc()
}
zipArchive := archive.(*zipArchive)
+
err := zipArchive.openArchive(ctx)
- return zipArchive, err
+ if err != nil {
+ metrics.ZipServingFailedOpenArchivesTotal.Inc()
+ return nil, err
+ }
+
+ return zipArchive, nil
}