func newExternalSinkManager(externalSinks []sink_api.ExternalSink) (ExternalSinkManager, error) { // Get supported metrics. supportedMetrics := sink_api.SupportedStatMetrics() for i := range supportedMetrics { supportedMetrics[i].Labels = sink_api.SupportedLabels() } // Create the metrics. descriptors := make([]sink_api.MetricDescriptor, 0, len(supportedMetrics)) for _, supported := range supportedMetrics { descriptors = append(descriptors, supported.MetricDescriptor) } for _, externalSink := range externalSinks { err := externalSink.Register(descriptors) if err != nil { return nil, err } } decoder := sink_api.NewDecoder() return &externalSinkManager{ externalSinks: externalSinks, decoder: decoder, }, nil }
// NewExternalSinkManager returns an external sink manager that will manage pushing data to all // the sinks in 'externalSinks', which is a map of sink name to ExternalSink object. func NewExternalSinkManager(externalSinks []sink_api.ExternalSink) (ExternalSinkManager, error) { m := &externalSinkManager{ decoder: sink_api_old.NewDecoder(), } if externalSinks != nil { if err := m.SetSinks(externalSinks); err != nil { return nil, err } } return m, nil }