diff --git a/log/default.go b/log/default.go index bf50f98..7ab6213 100644 --- a/log/default.go +++ b/log/default.go @@ -13,7 +13,7 @@ import ( var ( errorMetric = promauto.NewCounter( prometheus.CounterOpts{ - Name: "mefit_error_total", + Name: "spendsparrow_error_total", Help: "The total number of errors during processing", }, ) diff --git a/service/account.go b/service/account.go index 48ac0cd..443ff9b 100644 --- a/service/account.go +++ b/service/account.go @@ -9,10 +9,20 @@ import ( "spend-sparrow/types" "github.com/google/uuid" + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/client_golang/prometheus/promauto" ) var ( safeInputRegex = regexp.MustCompile(`^[a-zA-Z0-9äöüß -]+$`) + + accountMetric = promauto.NewCounterVec( + prometheus.CounterOpts{ + Name: "spendsparrow_account_total", + Help: "The total of account operations", + }, + []string{"operation"}, + ) ) type Account interface { @@ -40,6 +50,8 @@ func NewAccountImpl(db db.Account, random Random, clock Clock, settings *types.S } func (s AccountImpl) Add(user *types.User, name string) (*types.Account, error) { + accountMetric.WithLabelValues("add").Inc() + if user == nil { return nil, ErrUnauthorized } @@ -84,6 +96,7 @@ func (s AccountImpl) Add(user *types.User, name string) (*types.Account, error) } func (s AccountImpl) Update(user *types.User, id uuid.UUID, name string) (*types.Account, error) { + accountMetric.WithLabelValues("update").Inc() if user == nil { return nil, ErrUnauthorized } @@ -114,6 +127,7 @@ func (s AccountImpl) Update(user *types.User, id uuid.UUID, name string) (*types } func (s AccountImpl) Get(user *types.User, id uuid.UUID) (*types.Account, error) { + accountMetric.WithLabelValues("get").Inc() if user == nil { return nil, ErrUnauthorized @@ -131,7 +145,7 @@ func (s AccountImpl) Get(user *types.User, id uuid.UUID) (*types.Account, error) } func (s AccountImpl) GetAll(user *types.User) ([]*types.Account, error) { - + accountMetric.WithLabelValues("get_all").Inc() if user == nil { return nil, ErrUnauthorized } @@ -145,6 +159,7 @@ func (s AccountImpl) GetAll(user *types.User) ([]*types.Account, error) { } func (s AccountImpl) Delete(user *types.User, id uuid.UUID) error { + accountMetric.WithLabelValues("delete").Inc() if user == nil { return ErrUnauthorized }