@@ -60,7 +60,7 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
6060 }
6161
6262 // Load any externally defined collectors.
63- if err := c .LoadCollectorFiles (); err != nil {
63+ if err := c .loadCollectorFiles (); err != nil {
6464 return err
6565 }
6666
@@ -99,8 +99,20 @@ func (c *Config) YAML() ([]byte, error) {
9999 return yaml .Marshal (c )
100100}
101101
102+ // ReloadCollectorFiles blah
103+ func (c * Config ) ReloadCollectorFiles () error {
104+ if len (c .Collectors ) > 0 {
105+ c .Collectors = c .Collectors [:0 ]
106+ }
107+ err := c .loadCollectorFiles ()
108+ if err != nil {
109+ return err
110+ }
111+ return nil
112+ }
113+
102114// LoadCollectorFiles resolves all collector file globs to files and loads the collectors they define.
103- func (c * Config ) LoadCollectorFiles () error {
115+ func (c * Config ) loadCollectorFiles () error {
104116 baseDir := filepath .Dir (c .configFile )
105117 for _ , cfglob := range c .CollectorFiles {
106118 // Resolve relative paths by joining them to the configuration file's directory.
@@ -128,9 +140,6 @@ func (c *Config) LoadCollectorFiles() error {
128140 return err
129141 }
130142
131- if len (c .Collectors ) > 0 {
132- c .Collectors = c .Collectors [:0 ]
133- }
134143 c .Collectors = append (c .Collectors , & cc )
135144 klog .Infof ("Loaded collector %q from %s" , cc .Name , cf )
136145 }
0 commit comments