Understanding the structure of node_exporter

28 views
Skip to first unread message

Siddhant Gupta

unread,
Jul 27, 2022, 4:18:02 AM7/27/22
to Prometheus Developers
I am reading the code of node_exporter and I could not understand why do we have a generic collector.go that maintains all the various collectors and registers a generic Collector interface with prometheus?

Couldn't we register all the collector directly with prometheus?

Matthias Rampke

unread,
Jul 28, 2022, 2:24:39 AM7/28/22
to Siddhant Gupta, Prometheus Developers
Not all collectors are available on all platforms – in many cases, due to the platform dependent code, they won't even compile. This structure allows us to selectively compile the various collector files, and those that are getting compiled register themselves.

Additionally, this structure allows third party software to re-use the collectors, for example as part of a bundled "one binary to rule them all" style uber-exporter.

/MR

On Wed, Jul 27, 2022, 10:18 Siddhant Gupta <siddhant...@gmail.com> wrote:
I am reading the code of node_exporter and I could not understand why do we have a generic collector.go that maintains all the various collectors and registers a generic Collector interface with prometheus?

Couldn't we register all the collector directly with prometheus?

--
You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-devel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-developers/1034f67a-7e48-482a-b3e3-c04befb0ca6an%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages