in pipeline/senders/dispatcher.go [36:56]
func (d *Dispatcher) Send(report metrics.StampedMetricReport) error {
// First, register that each report will be handled by this Dispatcher's endpoints.
endpoints := d.Endpoints()
d.recorder.Register(report.Id, endpoints)
// Next, forward the reports to each subsequent sender.
errors := make([]error, len(d.senders))
wg := sync.WaitGroup{}
wg.Add(len(d.senders))
for i, ps := range d.senders {
go func(i int, s pipeline.Sender) {
// If the send generates an error, we assume that the downstream sender will register that
// error with the stats recorder.
errors[i] = s.Send(report)
wg.Done()
}(i, ps)
}
wg.Wait()
return multierror.Append(nil, errors...).ErrorOrNil()
}