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
Allow environment variables in config #334
Conversation
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
Need more tests and polish the code. I want to see how people feel about this idea. I will finish if people like it |
I like the idea. It seems better than relying on the automatic stuff that viper can do since it becomes explicit what is coming from env vars just by looking at the config file. I would say go for it. |
@bogdandrutu the feature looks useful to me. Nit: implementation-wise perhaps would be nicer to avoid using |
If only for tests I would postpone that extra work. We can make sure we don't reuse the same variable name across tests to make sure they don't interact with each other. Also I am hearing a lot this argument against globals, but I had the impression that the testing framework will spawn a new instance for every test when run in parallel (I may be wrong). |
I don't think Go's There is also a small danger that an env variable may be accidentally defined by the calling proces and will be inherited by child But, I agree, if we choose unique enough names it should not be an issue in practice. |
Given that |
@pjanotti good to know, I was not aware |
Hitting the bug spf13/viper#673 |
@tigrannajaryan @pjanotti that is a nice option, but unfortunately our config is not an object and exposes Load with only 3 elements which means adding a new option will be a lot of unnecessary work. I think this can be solved separately if we really want to. |
This is now ready for review, please help me merge this :) |
Codecov Report
@@ Coverage Diff @@
## master #334 +/- ##
==========================================
+ Coverage 74.05% 74.22% +0.17%
==========================================
Files 115 115
Lines 6668 6681 +13
==========================================
+ Hits 4938 4959 +21
+ Misses 1480 1474 -6
+ Partials 250 248 -2
Continue to review full report at Codecov.
|
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.
LGTM @bogdandrutu just some nits and copy and paste comment errors
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
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.
LGTM
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.
Co-Authored-By: Yang Song <songy23@users.noreply.github.com>
* Prom exporter structure * update prometheus exporter with master and add example. * remove distributedcontext from prometheus example * docs and interface checker * make precommit * make precommit & remove "OnRegisterError" * coerce values to float * return register errors and maybe fix precommit? * add option to specify a prometheus.Registry * make exporter implement http.Handler interface * fix map keys bugs * remove unused const * fix modules dependencies. * add support for histogram * get metrics with labels values only instead of a labels map * make exporter implements label encoder interface * encode labels if the encoder is different. * split metrics on several files and encapsulate them in structs * make pre commit * unexport 'sanitize' * remove 'AllValues' in favor of 'Points' and change to 'NewDefaultLabelEncoder' * add prometheus tests * remove newlines on struct declaration * formatting * rewording * imports * add todo on labelValues * blame myself for todo (: * add todos on sanitize * add support for summaries. custom remove label encoder. * imports * imports * update with upstream
With this change values (direct values, values in maps, values in a list) that uses the expand env format see https://golang.org/pkg/os/#ExpandEnv will be expanded and users will be able to use environment variables to set these values.
Signed-off-by: Bogdan Drutu bogdandrutu@gmail.com