Skip to content

Commit

Permalink
Add new metric to count total snapshots put in test_service
Browse files Browse the repository at this point in the history
  • Loading branch information
gdiazlo committed Mar 19, 2019
1 parent ed8434f commit e861b74
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/e2e/test_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,19 @@ var (
},
)

QedStoreEventsStoredTotal = prometheus.NewCounter(
prometheus.CounterOpts{
Name: "qed_store_events_stored_total",
Help: "Number of events stored.",
},
)

metricsList = []prometheus.Collector{
QedStoreInstancesCount,
QedStoreBatchesStoredTotal,
QedStoreSnapshotsRetrievedTotal,
QedStoreAlertsGeneratedTotal,
QedStoreEventsStoredTotal,
}

registerMetrics sync.Once
Expand Down Expand Up @@ -133,6 +141,7 @@ func (s *snapStore) Put(b *protocol.BatchSnapshots) {
targetSegment := snap.Snapshot.Version / segmentSize
targetIndex := snap.Snapshot.Version - (targetSegment * segmentSize)
s.segments[targetSegment][targetIndex] = snap
QedStoreEventsStoredTotal.Inc()
}
}

Expand Down Expand Up @@ -248,7 +257,11 @@ func (s *Service) postBatchHandler() func(http.ResponseWriter, *http.Request) {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}

if len(b.Snapshots) < 1 {
log.Infof("Empty batch recevied!")
http.Error(w, "Empty batch recevied!", http.StatusInternalServerError)
return
}
s.snaps.Put(&b)
return
}
Expand Down

0 comments on commit e861b74

Please sign in to comment.