Sitelet https://github.com/prometheus/node_exporter/pull/4
Skip to content

Modularize node_exporter and add Dockerfile - #4

Merged
discordianfish merged 2 commits into
masterfrom
modularize
Feb 12, 2014
Merged

discordianfish merged 2 commits into
masterfrom
modularize

Conversation

@discordianfish

Copy link
Copy Markdown
Member

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/) :)

@grobie

grobie commented Feb 7, 2014

Copy link
Copy Markdown
Member

A bash script to write out a go file, new level of meta programming :D

@juliusv

juliusv commented Feb 7, 2014

Copy link
Copy Markdown
Member

@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 -generators=native,gmond. By default, if empty, the flag could enable all generators.

@juliusv

juliusv commented Feb 7, 2014

Copy link
Copy Markdown
Member

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.

@discordianfish

Copy link
Copy Markdown
Member Author

@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 -generators=....
I didn't know about 'conditional compilation' but will look into that, this looks pretty promising.

@discordianfish

Copy link
Copy Markdown
Member Author

MUCH better :) What do you think? See my commit message:

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.

Comment thread node_exporter.go Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: This can be just log.Println(" -", c.Name())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah wait. I didn't realize you specifically wanted to output them on the same line. Nevermind then.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or rather, it would be log.Print(" -", c.Name()) then :)

@juliusv

juliusv commented Feb 11, 2014

Copy link
Copy Markdown
Member

👍 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.
@discordianfish

Copy link
Copy Markdown
Member Author

Ok, I've fixed those things so I guess it's okay to merge it.

discordianfish added a commit that referenced this pull request Feb 12, 2014
Modularize node_exporter and add Dockerfile
@discordianfish
discordianfish merged commit 6b77696 into master Feb 12, 2014
@discordianfish
discordianfish deleted the modularize branch February 12, 2014 10:18
simonpasquier pushed a commit to simonpasquier/node_exporter that referenced this pull request Jul 27, 2018
tamcore pushed a commit to gitgrave/node_exporter that referenced this pull request Oct 22, 2024
philipgough pushed a commit to philipgough/node_exporter that referenced this pull request Jan 8, 2025
Signed-off-by: Song Song Li <ssli@redhat.com>
private-mirrors-app-mandalorium Bot pushed a commit to Mandalorium/node_exporter that referenced this pull request Mar 25, 2025
…s/github.com/prometheus/common-0.63.0

build(deps): bump github.com/prometheus/common from 0.62.0 to 0.63.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants