1
0
Fork 0

Add Tracing Header Context Name option for Jaeger

This commit is contained in:
Mohamed Abdelkader Hizaoui 2019-02-05 18:20:03 +01:00 committed by Traefiker Bot
parent f0ee2890b2
commit 156f6b8d3c
17 changed files with 327 additions and 49 deletions

View file

@ -16,6 +16,7 @@ package config
import (
"fmt"
"net/url"
"os"
"strconv"
"strings"
@ -41,6 +42,9 @@ const (
envReporterMaxQueueSize = "JAEGER_REPORTER_MAX_QUEUE_SIZE"
envReporterFlushInterval = "JAEGER_REPORTER_FLUSH_INTERVAL"
envReporterLogSpans = "JAEGER_REPORTER_LOG_SPANS"
envEndpoint = "JAEGER_ENDPOINT"
envUser = "JAEGER_USER"
envPassword = "JAEGER_PASSWORD"
envAgentHost = "JAEGER_AGENT_HOST"
envAgentPort = "JAEGER_AGENT_PORT"
)
@ -156,12 +160,19 @@ func reporterConfigFromEnv() (*ReporterConfig, error) {
}
host := jaeger.DefaultUDPSpanServerHost
ep := os.Getenv(envEndpoint)
if e := os.Getenv(envAgentHost); e != "" {
if ep != "" {
return nil, errors.Errorf("cannot set env vars %s and %s together", envAgentHost, envEndpoint)
}
host = e
}
port := jaeger.DefaultUDPSpanServerPort
if e := os.Getenv(envAgentPort); e != "" {
if ep != "" {
return nil, errors.Errorf("cannot set env vars %s and %s together", envAgentPort, envEndpoint)
}
if value, err := strconv.ParseInt(e, 10, 0); err == nil {
port = int(value)
} else {
@ -173,6 +184,22 @@ func reporterConfigFromEnv() (*ReporterConfig, error) {
// were not explicitly passed
rc.LocalAgentHostPort = fmt.Sprintf("%s:%d", host, port)
if ep != "" {
u, err := url.ParseRequestURI(ep)
if err != nil {
return nil, errors.Wrapf(err, "cannot parse env var %s=%s", envEndpoint, ep)
}
rc.CollectorEndpoint = fmt.Sprintf("%s", u)
}
user := os.Getenv(envUser)
pswd := os.Getenv(envPassword)
if user != "" && pswd == "" || user == "" && pswd != "" {
return nil, errors.Errorf("you must set %s and %s env vars together", envUser, envPassword)
}
rc.User = user
rc.Password = pswd
return rc, nil
}