draft prometheus update booking...
This commit is contained in:
parent
c7290b0ead
commit
f61c9f5df9
@ -134,11 +134,10 @@ func (p *PrometheusService) Call(bookingID string) (*booking.Booking, map[string
|
||||
func (p *PrometheusService) Stream(bookingID string, end *time.Time, interval time.Duration, flusher http.Flusher, encoder *json.Encoder) {
|
||||
if end != nil {
|
||||
max := 100
|
||||
count := 0
|
||||
bookIDS := []string{}
|
||||
mets := map[string][]models.MetricsSnapshot{}
|
||||
for time.Now().Before(*end) {
|
||||
go func() {
|
||||
count++
|
||||
book, metrics := p.Call(bookingID)
|
||||
for k, v := range metrics {
|
||||
if me, ok := mets[k]; !ok {
|
||||
@ -148,9 +147,10 @@ func (p *PrometheusService) Stream(bookingID string, end *time.Time, interval ti
|
||||
mets[k] = me
|
||||
}
|
||||
}
|
||||
bookIDS = append(bookIDS, bookingID)
|
||||
encoder.Encode(metrics)
|
||||
flusher.Flush()
|
||||
if count == max {
|
||||
if len(bookIDS) == max {
|
||||
if book.ExecutionMetrics == nil {
|
||||
book.ExecutionMetrics = mets
|
||||
} else {
|
||||
@ -164,6 +164,7 @@ func (p *PrometheusService) Stream(bookingID string, end *time.Time, interval ti
|
||||
}
|
||||
}
|
||||
book.GetAccessor(nil).UpdateOne(book, bookingID)
|
||||
bookIDS = []string{}
|
||||
}
|
||||
}()
|
||||
time.Sleep(interval)
|
||||
|
Loading…
Reference in New Issue
Block a user