This fix ensures that network stats for containerd on Windows are successfully collected. Before this change, other container stats such as CPU and memory are successfully collected, but network stats are failing for containerd.
The root cause is that the code for collecting network stats was originally written to work with docker which relies on v1 schema. After dockershim removal as Kubernetes's container runtime, containerd adoption has increased and this error is more frequently encountered when using containerd as the runtime. containerd uses v2 schema whereby the network stats need to be queried from the HNS component.
Signed-off-by: Tatenda Zifudzi <tzifudzi@amazon.com>
Collector builder functions are only used internally in the `collector`
package, and shouldn't needlessly be exposed as part of the package API
to downstream clients.
Signed-off-by: Ben Reedy <breed808@breed808.com>
Behaviour of init functions has been centralised in `collector/init.go`,
and can be called during exporter startup. This allows the exporter to
control the timing of collector initialisation, rather than relying on
the import & `init()` method.
This should reduce unexpected behaviour arising from the use of
`init()`, such as #551.
Signed-off-by: Ben Reedy <breed808@breed808.com>