Repository navigation
Modularize node_exporter and add Dockerfile - #4
Conversation
|
A bash script to write out a go file, new level of meta programming :D |
|
@grobie LOOOL But in all seriousness, I'd really rather solve this in a different way that doesn't require having a bash contraption which generates code. What do you think about registering the different generators with string names (most likely in a map) and then activate the desired generators via a flag? Like |
|
Another option: use Go's build tags to do conditional compilation: http://golang.org/pkg/go/build/ (see also http://stackoverflow.com/questions/10646531/golang-conditional-compilation) So for example, you could put each generator completely into its own file, and then also register that generator somehow from that file. I have never played with build tags though. |
|
@juliusv Well, originally I tried to read the collectors from the config file but then again we have to link every collector in, no matter whether it's in use or not. Same for |
|
MUCH better :) What do you think? See my commit message: This works by using a global array with references to NewXCollector Which file gets build depends on the build tags: To build only the ganglia exporter, you can do: By default it will build only the native collector. |
There was a problem hiding this comment.
Nit: This can be just log.Println(" -", c.Name())
There was a problem hiding this comment.
Ah wait. I didn't realize you specifically wanted to output them on the same line. Nevermind then.
There was a problem hiding this comment.
Or rather, it would be log.Print(" -", c.Name()) then :)
|
👍 Besides the small comments! |
This works by using a global array with references to NewXCollector
functions. Each collector appends to that array in it's init() function.
Which file gets build depends on the build tags:
To build only the ganglia exporter, you can do:
go build -tags nonative,ganglia
By default it will build only the native collector.
|
Ok, I've fixed those things so I guess it's okay to merge it. |
Modularize node_exporter and add Dockerfile
Openshift master merge 0.16.0
Hardcode USER_HZ to 100.
Signed-off-by: Song Song Li <ssli@redhat.com>
…s/github.com/prometheus/common-0.63.0 build(deps): bump github.com/prometheus/common from 0.62.0 to 0.63.0
Hi everyone,
this PR adds a Makefile and scripts to "dynamically" configure what to include in the node_exporter.
Probably better than messing around with reflect n' stuff.
Moreover this includes a Dockerfile so it can be rebuilt on every push (like https://index.docker.io/u/fish/prometheus/) :)