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:
Diffstat (limited to 'internal/vfs/zip')
-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
}