Manager maintains a set of discovery providers and sends each update to a map channel. Targets are grouped by the target set name.
| 168 | // Manager maintains a set of discovery providers and sends each update to a map channel. |
| 169 | // Targets are grouped by the target set name. |
| 170 | type Manager struct { |
| 171 | logger *slog.Logger |
| 172 | name string |
| 173 | httpOpts []config.HTTPClientOption |
| 174 | mtx sync.RWMutex |
| 175 | ctx context.Context |
| 176 | |
| 177 | // Some Discoverers(e.g. k8s) send only the updates for a given target group, |
| 178 | // so we use map[tg.Source]*targetgroup.Group to know which group to update. |
| 179 | targets map[poolKey]map[string]*targetgroup.Group |
| 180 | targetsMtx sync.Mutex |
| 181 | |
| 182 | // providers keeps track of SD providers. |
| 183 | providers []*Provider |
| 184 | // The sync channel sends the updates as a map where the key is the job value from the scrape config. |
| 185 | syncCh chan map[string][]*targetgroup.Group |
| 186 | |
| 187 | // How long to wait before sending updates to the channel. The variable |
| 188 | // should only be modified in unit tests. |
| 189 | updatert time.Duration |
| 190 | |
| 191 | // The triggerSend channel signals to the Manager that new updates have been received from providers. |
| 192 | triggerSend chan struct{} |
| 193 | |
| 194 | // lastProvider counts providers registered during Manager's lifetime. |
| 195 | lastProvider uint |
| 196 | |
| 197 | // A registerer for all service discovery metrics. |
| 198 | registerer prometheus.Registerer |
| 199 | |
| 200 | metrics *Metrics |
| 201 | sdMetrics *SDMetrics |
| 202 | |
| 203 | // featureRegistry is used to track which service discovery providers are configured. |
| 204 | featureRegistry features.Collector |
| 205 | } |
| 206 | |
| 207 | // Providers returns the currently configured SD providers. |
| 208 | func (m *Manager) Providers() []*Provider { |
nothing calls this directly
no outgoing calls
no test coverage detected