Преглед изворни кода

[server] Remove custom metrics for collection diff (#520)

Neeraj Gupta пре 1 година
родитељ
комит
f796a7f63a

+ 0 - 1
server/cmd/museum/main.go

@@ -293,7 +293,6 @@ func main() {
 		BillingCtrl:          billingController,
 		BillingCtrl:          billingController,
 		QueueRepo:            queueRepo,
 		QueueRepo:            queueRepo,
 		TaskRepo:             taskLockingRepo,
 		TaskRepo:             taskLockingRepo,
-		LatencyLogger:        latencyLogger,
 	}
 	}
 
 
 	kexCtrl := &kexCtrl.Controller{
 	kexCtrl := &kexCtrl.Controller{

+ 0 - 18
server/pkg/controller/collection.go

@@ -7,13 +7,11 @@ import (
 	"github.com/ente-io/museum/pkg/repo/cast"
 	"github.com/ente-io/museum/pkg/repo/cast"
 	"runtime/debug"
 	"runtime/debug"
 	"strings"
 	"strings"
-	t "time"
 
 
 	"github.com/ente-io/museum/pkg/controller/access"
 	"github.com/ente-io/museum/pkg/controller/access"
 	"github.com/gin-contrib/requestid"
 	"github.com/gin-contrib/requestid"
 	"github.com/google/go-cmp/cmp"
 	"github.com/google/go-cmp/cmp"
 	"github.com/google/go-cmp/cmp/cmpopts"
 	"github.com/google/go-cmp/cmp/cmpopts"
-	"github.com/prometheus/client_golang/prometheus"
 
 
 	"github.com/ente-io/museum/pkg/utils/array"
 	"github.com/ente-io/museum/pkg/utils/array"
 	"github.com/ente-io/museum/pkg/utils/auth"
 	"github.com/ente-io/museum/pkg/utils/auth"
@@ -41,7 +39,6 @@ type CollectionController struct {
 	QueueRepo            *repo.QueueRepository
 	QueueRepo            *repo.QueueRepository
 	CastRepo             *cast.Repository
 	CastRepo             *cast.Repository
 	TaskRepo             *repo.TaskLockRepository
 	TaskRepo             *repo.TaskLockRepository
-	LatencyLogger        *prometheus.HistogramVec
 }
 }
 
 
 // Create creates a collection
 // Create creates a collection
@@ -469,7 +466,6 @@ func (c *CollectionController) isRemoveAllowed(ctx *gin.Context, actorUserID int
 
 
 // GetDiffV2 returns the changes in user's collections since a timestamp, along with hasMore bool flag.
 // GetDiffV2 returns the changes in user's collections since a timestamp, along with hasMore bool flag.
 func (c *CollectionController) GetDiffV2(ctx *gin.Context, cID int64, userID int64, sinceTime int64) ([]ente.File, bool, error) {
 func (c *CollectionController) GetDiffV2(ctx *gin.Context, cID int64, userID int64, sinceTime int64) ([]ente.File, bool, error) {
-	startTime := t.Now()
 	reqContextLogger := log.WithFields(log.Fields{
 	reqContextLogger := log.WithFields(log.Fields{
 		"user_id":       userID,
 		"user_id":       userID,
 		"collection_id": cID,
 		"collection_id": cID,
@@ -477,10 +473,6 @@ func (c *CollectionController) GetDiffV2(ctx *gin.Context, cID int64, userID int
 		"req_id":        requestid.Get(ctx),
 		"req_id":        requestid.Get(ctx),
 	})
 	})
 	reqContextLogger.Info("Start")
 	reqContextLogger.Info("Start")
-	defer func() {
-		c.LatencyLogger.WithLabelValues("CollectionController.GetDiffV2").
-			Observe(float64(t.Since(startTime).Milliseconds()))
-	}()
 	_, err := c.AccessCtrl.GetCollection(ctx, &access.GetCollectionParams{
 	_, err := c.AccessCtrl.GetCollection(ctx, &access.GetCollectionParams{
 		CollectionID: cID,
 		CollectionID: cID,
 		ActorUserID:  userID,
 		ActorUserID:  userID,
@@ -533,17 +525,12 @@ func (c *CollectionController) GetFile(ctx *gin.Context, collectionID int64, fil
 // GetPublicDiff returns the changes in the collections since a timestamp, along with hasMore bool flag.
 // GetPublicDiff returns the changes in the collections since a timestamp, along with hasMore bool flag.
 func (c *CollectionController) GetPublicDiff(ctx *gin.Context, sinceTime int64) ([]ente.File, bool, error) {
 func (c *CollectionController) GetPublicDiff(ctx *gin.Context, sinceTime int64) ([]ente.File, bool, error) {
 	accessContext := auth.MustGetPublicAccessContext(ctx)
 	accessContext := auth.MustGetPublicAccessContext(ctx)
-	startTime := t.Now()
 	reqContextLogger := log.WithFields(log.Fields{
 	reqContextLogger := log.WithFields(log.Fields{
 		"public_id":     accessContext.ID,
 		"public_id":     accessContext.ID,
 		"collection_id": accessContext.CollectionID,
 		"collection_id": accessContext.CollectionID,
 		"since_time":    sinceTime,
 		"since_time":    sinceTime,
 		"req_id":        requestid.Get(ctx),
 		"req_id":        requestid.Get(ctx),
 	})
 	})
-	defer func() {
-		c.LatencyLogger.WithLabelValues("CollectionController.GetPublicDiff").
-			Observe(float64(t.Since(startTime).Milliseconds()))
-	}()
 	diff, hasMore, err := c.getDiff(accessContext.CollectionID, sinceTime, CollectionDiffLimit, reqContextLogger)
 	diff, hasMore, err := c.getDiff(accessContext.CollectionID, sinceTime, CollectionDiffLimit, reqContextLogger)
 	if err != nil {
 	if err != nil {
 		return nil, false, stacktrace.Propagate(err, "")
 		return nil, false, stacktrace.Propagate(err, "")
@@ -574,11 +561,6 @@ func (c *CollectionController) GetPublicDiff(ctx *gin.Context, sinceTime int64)
 func (c *CollectionController) getDiff(cID int64, sinceTime int64, limit int, logger *log.Entry) ([]ente.File, bool, error) {
 func (c *CollectionController) getDiff(cID int64, sinceTime int64, limit int, logger *log.Entry) ([]ente.File, bool, error) {
 	logger.Info("getDiff")
 	logger.Info("getDiff")
 	// request for limit +1 files
 	// request for limit +1 files
-	startTime := t.Now()
-	defer func() {
-		c.LatencyLogger.WithLabelValues("CollectionController.getDiff").
-			Observe(float64(t.Since(startTime).Milliseconds()))
-	}()
 	diffLimitPlusOne, err := c.CollectionRepo.GetDiff(cID, sinceTime, limit+1)
 	diffLimitPlusOne, err := c.CollectionRepo.GetDiff(cID, sinceTime, limit+1)
 	logger.Info("Got diff from repo")
 	logger.Info("Got diff from repo")
 	if err != nil {
 	if err != nil {

+ 0 - 6
server/pkg/controller/collection_cast.go

@@ -7,7 +7,6 @@ import (
 	"github.com/gin-contrib/requestid"
 	"github.com/gin-contrib/requestid"
 	"github.com/gin-gonic/gin"
 	"github.com/gin-gonic/gin"
 	log "github.com/sirupsen/logrus"
 	log "github.com/sirupsen/logrus"
-	t "time"
 )
 )
 
 
 func (c *CollectionController) GetCastCollection(ctx *gin.Context) (*ente.Collection, error) {
 func (c *CollectionController) GetCastCollection(ctx *gin.Context) (*ente.Collection, error) {
@@ -26,16 +25,11 @@ func (c *CollectionController) GetCastCollection(ctx *gin.Context) (*ente.Collec
 func (c *CollectionController) GetCastDiff(ctx *gin.Context, sinceTime int64) ([]ente.File, bool, error) {
 func (c *CollectionController) GetCastDiff(ctx *gin.Context, sinceTime int64) ([]ente.File, bool, error) {
 	castCtx := auth.GetCastCtx(ctx)
 	castCtx := auth.GetCastCtx(ctx)
 	collectionID := castCtx.CollectionID
 	collectionID := castCtx.CollectionID
-	startTime := t.Now()
 	reqContextLogger := log.WithFields(log.Fields{
 	reqContextLogger := log.WithFields(log.Fields{
 		"collection_id": collectionID,
 		"collection_id": collectionID,
 		"since_time":    sinceTime,
 		"since_time":    sinceTime,
 		"req_id":        requestid.Get(ctx),
 		"req_id":        requestid.Get(ctx),
 	})
 	})
-	defer func() {
-		c.LatencyLogger.WithLabelValues("CollectionController.GetCastDiff").
-			Observe(float64(t.Since(startTime).Milliseconds()))
-	}()
 	diff, hasMore, err := c.getDiff(collectionID, sinceTime, CollectionDiffLimit, reqContextLogger)
 	diff, hasMore, err := c.getDiff(collectionID, sinceTime, CollectionDiffLimit, reqContextLogger)
 	if err != nil {
 	if err != nil {
 		return nil, false, stacktrace.Propagate(err, "")
 		return nil, false, stacktrace.Propagate(err, "")