New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi platform support #5
Conversation
InterfaceGenerator should probably be a part of metaGenerators. In that case prepare Host should separate intaface info from collected meta.
SGTM |
Thanks @mattn! You've been a great help to me. I'll fix some points from you, and this PR will be merged after the reviewing by an another hatena staff. |
&metricsLinux.DiskGenerator{Interval: 60}, | ||
} | ||
for _, pluginConfig := range config.Plugin["metrics"] { | ||
generators = append(generators, &metricsLinux.PluginGenerator{pluginConfig}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PluginGenerator may have configuration key for logging/debugging purpose (someday)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's so true.. It'll be necessary someday.
LGTM |
Conflicts: command/command.go metrics/linux/plugin.go metrics/linux/plugin_test.go
This branch will be merged after field tests on hatena's servers, so that this is the first time to use build constraints. |
Cool |
Ooops sorry. |
https://github.com/mackerelio/mackerel-agent/blob/multi-platform/command/command_linux.go#L25 I'm thinking some platforms are require to store some member variables to keep condition while collecting values. So it's better to make functions like For example, on linux,
But on windows, possible to be
|
@mattn. I think it is not necessary to create functions like We are planning to create platform specific functions which creates generator structs like below. // in command/command_freebsd.go
// ...
func specGenerators() []spec.Generator {
return []spec.Generator{
&specFreeBSD.KernelGenerator{"some", "field", "for", "FreeBSD"},
&specFreeBSD.CPUGenerator{"other", "fields" },
/* ... */
}
}
// ... This is no problem, because I think that differences of the Generator initialization among architectures are already hidden by |
Sure. This way has one more point. Even though it will need to add new field to the struct in the future, we don't need to change command/command_xxx.go :) |
However, it's not important or critical things. So go on your way! :) |
Yes, I agree that initializing structs by functions like As you say it's not important or critical things still now. We will solve this problem by another Pull Request. Thank you for your advice !:smile: |
日本語ですみません。 後でこれに対するWindowsパッチを書きますが(というかほぼ出来てます)、Windowsの場合は構造体にスナップショットを取った際の状態(Windowsのパフォーマンスカウンタのハンドル)を保持しています。そのハンドルの初期化処理を行う必要があり、Generate でさせるとなると初期化済みフラグみたいな物を持つ必要があります。 できれば command/command_xxx.go にはWindows API呼出しなどは入れたくないので、おそらくWindowsに限ってはNewFooGenerator(1)形式にさせて頂く事になると思います。 |
僕も日本語がいいかと思ってました! なるほどなるほど。たしかにアーキテクチャによっては初期化関数がないと実装が難しいということはありそうです。 Windows版に関しては、関数を使って初期化していただくので問題ないかと思います。 (とはいえ、コードのスタイルがアーキテクチャごとに違うのも良くないので、Linux部分についても関数で初期化するスタイルにおいおい揃えたほうが良い、ということにはなりそうですね。) Windows版については、このブランチのコードでも、まだアーキテクチャ依存の箇所があると思うので(pidとかPOSIXパスになっている部分とか)、構造を変えたほうが良さそうな部分があれば教えていただけると助かります。metrics/specに関する部分以外では、必要最低限の部分だけ、アーキテクチャごとにコードを分けることで、なるべくコードの重複がないようにしたいと思っています。 |
はてなでのサーバでの動作検証ができましたので、マージいたします。 |
👍 |
This is experiment branch to support multi platform.