-
Notifications
You must be signed in to change notification settings - Fork 287
Support more environment variables in configuration #323
Conversation
config/config.go
Outdated
@@ -369,5 +382,13 @@ func (rc *ReporterConfig) NewReporter( | |||
} | |||
|
|||
func (rc *ReporterConfig) newTransport() (jaeger.Transport, error) { | |||
var opts transport.HTTPOption | |||
if rc.User != "" && rc.Password != "" { | |||
opts = transport.HTTPBasicAuth(rc.User, rc.Password) |
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.
ineffectual assignment to opts
Codecov Report
@@ Coverage Diff @@
## master #323 +/- ##
==========================================
- Coverage 87.15% 87.14% -0.01%
==========================================
Files 54 54
Lines 2965 2988 +23
==========================================
+ Hits 2584 2604 +20
- Misses 269 272 +3
Partials 112 112
Continue to review full report at Codecov.
|
Previously, the client could only send spans via UDP to the agent. This PR adds support for sending spans using HTTP to the collector by setting the JAEGER_ENDPOINT env var. Additionally, the HTTP transport can be secured through basic auth by setting the JAEGER_USER and JAEGER_PASSWORD env vars. Fixes: jaegertracing/jaeger#920 Signed-off-by: Daneyon Hansen <danehans@cisco.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. Thanks! I'll let @black-adder to review as well.
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.
thanks for the contribution! just a couple of nits
config/config_env.go
Outdated
@@ -157,11 +161,17 @@ func reporterConfigFromEnv() (*ReporterConfig, error) { | |||
|
|||
host := jaeger.DefaultUDPSpanServerHost | |||
if e := os.Getenv(envAgentHost); e != "" { | |||
if ep := os.Getenv(envEndpoint); ep != "" { |
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.
how about we read the envEndpoint once and use ep
in all the checks?
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.
ack
config/config_env.go
Outdated
rc.CollectorEndpoint = fmt.Sprintf("%s", u) | ||
} | ||
|
||
if e := os.Getenv(envUser); e != "" { |
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.
can we use xor here instead and combine everything into 1 check? Albeit, it might not be a worthwhile optimization given this only happens during initialization but it's always fun to use xor every now and again.
Signed-off-by: Daneyon Hansen <danehans@cisco.com>
config/config_env.go
Outdated
pswd := os.Getenv(envPassword) | ||
if user != "" && pswd == "" || user == "" && pswd != "" { | ||
return nil, errors.Errorf("you must set %s and %s env vars together", envUser, envPassword) | ||
} else { |
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.
if block ends with a return statement, so drop this else and outdent its block
config/config_env.go
Outdated
|
||
user := os.Getenv(envUser) | ||
pswd := os.Getenv(envPassword) | ||
if user != "" && pswd == "" || user == "" && pswd != "" { |
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.
File is not gofmt-ed with -s
Signed-off-by: Daneyon Hansen <danehans@cisco.com>
@danehans thanks! |
Which problem is this PR solving?
Short description of the changes
This PR adds support for sending spans using HTTP to the collector
by setting the JAEGER_ENDPOINT env var. Additionally, the HTTP
transport can be secured through basic auth by setting the
JAEGER_USER and JAEGER_PASSWORD env vars.
Signed-off-by: Daneyon Hansen danehans@cisco.com