Skip to content

Commit

Permalink
obey metrics config
Browse files Browse the repository at this point in the history
  • Loading branch information
ramin committed Jan 4, 2024
1 parent 573a7f1 commit cb42d92
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 7 additions & 3 deletions verifier/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,15 @@ func (v *Verifier) verifyRecords() {

// assume we'll need to switch on error type here
if err != nil {
v.Metrics.Errors.Add(context.Background(), 1)
v.Metrics.Misses.Add(context.Background(), 1)
if v.Metrics != nil {
v.Metrics.Errors.Add(context.Background(), 1)
v.Metrics.Misses.Add(context.Background(), 1)
}
v.errCh <- err
} else {
v.Metrics.Reads.Add(context.Background(), 1)
if v.Metrics != nil {
v.Metrics.Reads.Add(context.Background(), 1)
}
}

delete(v.History.Logs, key)
Expand Down
10 changes: 7 additions & 3 deletions verifier/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,13 @@ func NewVerifier(ctx context.Context) (*Verifier, error) {
return nil, err
}

m, err := metrics.NewMetrics()
if err != nil {
return nil, err
var m *metrics.Metrics

if config.Read().MetricsEnabled {
m, err = metrics.NewMetrics()
if err != nil {
return nil, err
}
}

return &Verifier{
Expand Down

0 comments on commit cb42d92

Please sign in to comment.