From e8e6b4eb25bead7d26f2fa09fc4ce1c727890185 Mon Sep 17 00:00:00 2001 From: Sandeep Sukhani Date: Fri, 6 May 2022 07:21:59 +0530 Subject: [PATCH] do not increment sync operation count metric on per index set (#6109) --- pkg/storage/stores/shipper/downloads/index_set.go | 13 +------------ .../stores/shipper/downloads/index_set_test.go | 3 +-- pkg/storage/stores/shipper/downloads/table.go | 9 +++------ 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/pkg/storage/stores/shipper/downloads/index_set.go b/pkg/storage/stores/shipper/downloads/index_set.go index a6c9347e89ec..dfb20dbc2eaf 100644 --- a/pkg/storage/stores/shipper/downloads/index_set.go +++ b/pkg/storage/stores/shipper/downloads/index_set.go @@ -45,7 +45,6 @@ type indexSet struct { baseIndexSet storage.IndexSet tableName, userID string cacheLocation string - metrics *metrics boltDBIndexClient BoltDBIndexClient logger log.Logger @@ -58,8 +57,7 @@ type indexSet struct { } func NewIndexSet(tableName, userID, cacheLocation string, baseIndexSet storage.IndexSet, - boltDBIndexClient BoltDBIndexClient, logger log.Logger, metrics *metrics, -) (IndexSet, error) { + boltDBIndexClient BoltDBIndexClient, logger log.Logger) (IndexSet, error) { if baseIndexSet.IsUserBasedIndexSet() && userID == "" { return nil, fmt.Errorf("userID must not be empty") } else if !baseIndexSet.IsUserBasedIndexSet() && userID != "" { @@ -76,7 +74,6 @@ func NewIndexSet(tableName, userID, cacheLocation string, baseIndexSet storage.I tableName: tableName, userID: userID, cacheLocation: cacheLocation, - metrics: metrics, boltDBIndexClient: boltDBIndexClient, logger: logger, lastUsedAt: time.Now(), @@ -284,14 +281,6 @@ func (t *indexSet) Sync(ctx context.Context) (err error) { func (t *indexSet) sync(ctx context.Context, lock, bypassListCache bool) (err error) { level.Debug(t.logger).Log("msg", "syncing index files") - defer func() { - status := statusSuccess - if err != nil { - status = statusFailure - } - t.metrics.tablesSyncOperationTotal.WithLabelValues(status).Inc() - }() - toDownload, toDelete, err := t.checkStorageForUpdates(ctx, lock, bypassListCache) if err != nil { return err diff --git a/pkg/storage/stores/shipper/downloads/index_set_test.go b/pkg/storage/stores/shipper/downloads/index_set_test.go index 0a7ddeb6ed2a..cd07d6a389e8 100644 --- a/pkg/storage/stores/shipper/downloads/index_set_test.go +++ b/pkg/storage/stores/shipper/downloads/index_set_test.go @@ -22,8 +22,7 @@ func buildTestIndexSet(t *testing.T, userID, path string) (*indexSet, stopFunc) cachePath := filepath.Join(path, cacheDirName) baseIndexSet := storage.NewIndexSet(storageClient, userID != "") - idxSet, err := NewIndexSet(tableName, userID, filepath.Join(cachePath, tableName, userID), baseIndexSet, - boltDBIndexClient, util_log.Logger, newMetrics(nil)) + idxSet, err := NewIndexSet(tableName, userID, filepath.Join(cachePath, tableName, userID), baseIndexSet, boltDBIndexClient, util_log.Logger) require.NoError(t, err) require.NoError(t, idxSet.Init(false)) diff --git a/pkg/storage/stores/shipper/downloads/table.go b/pkg/storage/stores/shipper/downloads/table.go index 8153423475a7..086c09cc3f28 100644 --- a/pkg/storage/stores/shipper/downloads/table.go +++ b/pkg/storage/stores/shipper/downloads/table.go @@ -108,8 +108,7 @@ func LoadTable(name, cacheLocation string, storageClient storage.Client, boltDBI } userID := fileInfo.Name() - userIndexSet, err := NewIndexSet(name, userID, filepath.Join(cacheLocation, userID), - table.baseUserIndexSet, boltDBIndexClient, loggerWithUserID(table.logger, userID), metrics) + userIndexSet, err := NewIndexSet(name, userID, filepath.Join(cacheLocation, userID), table.baseUserIndexSet, boltDBIndexClient, loggerWithUserID(table.logger, userID)) if err != nil { return nil, err } @@ -122,8 +121,7 @@ func LoadTable(name, cacheLocation string, storageClient storage.Client, boltDBI table.indexSets[userID] = userIndexSet } - commonIndexSet, err := NewIndexSet(name, "", cacheLocation, table.baseCommonIndexSet, - boltDBIndexClient, table.logger, metrics) + commonIndexSet, err := NewIndexSet(name, "", cacheLocation, table.baseCommonIndexSet, boltDBIndexClient, table.logger) if err != nil { return nil, err } @@ -298,8 +296,7 @@ func (t *table) getOrCreateIndexSet(ctx context.Context, id string, forQuerying } // instantiate the index set, add it to the map - indexSet, err = NewIndexSet(t.name, id, filepath.Join(t.cacheLocation, id), baseIndexSet, t.boltDBIndexClient, - loggerWithUserID(t.logger, id), t.metrics) + indexSet, err = NewIndexSet(t.name, id, filepath.Join(t.cacheLocation, id), baseIndexSet, t.boltDBIndexClient, loggerWithUserID(t.logger, id)) if err != nil { return nil, err }