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-30 08:24:12 +0300
committerJaime Martinez <jmartinez@gitlab.com>2020-09-30 08:24:12 +0300
commit031f6a1e63b52bf18db4087da7f678428f0ffdb8 (patch)
treef6beea5e90337f71dd03c80cd24de25b59cca8ee /internal/vfs
parent9f34b7999ed3b7c1f1cef6faa42d5d42ea3c5569 (diff)
Use histograms instead of gauges for transport durations
Diffstat (limited to 'internal/vfs')
-rw-r--r--internal/vfs/zip/archive.go12
-rw-r--r--internal/vfs/zip/vfs.go5
2 files changed, 12 insertions, 5 deletions
diff --git a/internal/vfs/zip/archive.go b/internal/vfs/zip/archive.go
index cfcdee76..7a9bcc3d 100644
--- a/internal/vfs/zip/archive.go
+++ b/internal/vfs/zip/archive.go
@@ -59,7 +59,16 @@ func newArchive(path string, openTimeout time.Duration) *zipArchive {
}
}
-func (a *zipArchive) openArchive(parentCtx context.Context) error {
+func (a *zipArchive) openArchive(parentCtx context.Context) (err error) {
+ defer func() {
+ // checking named return err value
+ if err != nil {
+ metrics.ZipServingOpenArchivesTotal.WithLabelValues("error").Inc()
+ } else {
+ metrics.ZipServingOpenArchivesTotal.WithLabelValues("ok").Inc()
+ }
+ }()
+
// return early if openArchive was done already in a concurrent request
select {
case <-a.done:
@@ -130,7 +139,6 @@ func (a *zipArchive) readArchive() {
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 6d0ba616..985ec3bb 100644
--- a/internal/vfs/zip/vfs.go
+++ b/internal/vfs/zip/vfs.go
@@ -70,7 +70,7 @@ 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.ZipServingArchiveCache.Inc()
+ metrics.ZipServingArchiveCache.WithLabelValues("hit").Inc()
// TODO: do not refreshed errored archives https://gitlab.com/gitlab-org/gitlab-pages/-/merge_requests/351
if time.Until(expiry) < defaultCacheRefreshInterval {
@@ -86,14 +86,13 @@ func (fs *zipVFS) findOrOpenArchive(ctx context.Context, path string) (*zipArchi
return nil, errAlreadyCached
}
- metrics.ZipServingArchiveCacheMiss.Inc()
+ metrics.ZipServingArchiveCache.WithLabelValues("miss").Inc()
}
zipArchive := archive.(*zipArchive)
err := zipArchive.openArchive(ctx)
if err != nil {
- metrics.ZipServingFailedOpenArchivesTotal.Inc()
return nil, err
}