Add Tracing Header Context Name option for Jaeger
This commit is contained in:
parent
f0ee2890b2
commit
156f6b8d3c
17 changed files with 327 additions and 49 deletions
26
vendor/github.com/uber/jaeger-client-go/config/config.go
generated
vendored
26
vendor/github.com/uber/jaeger-client-go/config/config.go
generated
vendored
|
@ -27,6 +27,7 @@ import (
|
|||
"github.com/uber/jaeger-client-go/internal/baggage/remote"
|
||||
throttler "github.com/uber/jaeger-client-go/internal/throttler/remote"
|
||||
"github.com/uber/jaeger-client-go/rpcmetrics"
|
||||
"github.com/uber/jaeger-client-go/transport"
|
||||
)
|
||||
|
||||
const defaultSamplingProbability = 0.001
|
||||
|
@ -108,6 +109,18 @@ type ReporterConfig struct {
|
|||
// LocalAgentHostPort instructs reporter to send spans to jaeger-agent at this address
|
||||
// Can be set by exporting an environment variable named JAEGER_AGENT_HOST / JAEGER_AGENT_PORT
|
||||
LocalAgentHostPort string `yaml:"localAgentHostPort"`
|
||||
|
||||
// CollectorEndpoint instructs reporter to send spans to jaeger-collector at this URL
|
||||
// Can be set by exporting an environment variable named JAEGER_ENDPOINT
|
||||
CollectorEndpoint string `yaml:"collectorEndpoint"`
|
||||
|
||||
// User instructs reporter to include a user for basic http authentication when sending spans to jaeger-collector.
|
||||
// Can be set by exporting an environment variable named JAEGER_USER
|
||||
User string `yaml:"user"`
|
||||
|
||||
// Password instructs reporter to include a password for basic http authentication when sending spans to
|
||||
// jaeger-collector. Can be set by exporting an environment variable named JAEGER_PASSWORD
|
||||
Password string `yaml:"password"`
|
||||
}
|
||||
|
||||
// BaggageRestrictionsConfig configures the baggage restrictions manager which can be used to whitelist
|
||||
|
@ -218,6 +231,7 @@ func (c Configuration) NewTracer(options ...Option) (opentracing.Tracer, io.Clos
|
|||
jaeger.TracerOptions.CustomHeaderKeys(c.Headers),
|
||||
jaeger.TracerOptions.Gen128Bit(opts.gen128Bit),
|
||||
jaeger.TracerOptions.ZipkinSharedRPCSpan(opts.zipkinSharedRPCSpan),
|
||||
jaeger.TracerOptions.MaxTagValueLength(opts.maxTagValueLength),
|
||||
}
|
||||
|
||||
for _, tag := range opts.tags {
|
||||
|
@ -344,7 +358,7 @@ func (sc *SamplerConfig) NewSampler(
|
|||
return nil, fmt.Errorf("Unknown sampler type %v", sc.Type)
|
||||
}
|
||||
|
||||
// NewReporter instantiates a new reporter that submits spans to tcollector
|
||||
// NewReporter instantiates a new reporter that submits spans to the collector
|
||||
func (rc *ReporterConfig) NewReporter(
|
||||
serviceName string,
|
||||
metrics *jaeger.Metrics,
|
||||
|
@ -368,5 +382,13 @@ func (rc *ReporterConfig) NewReporter(
|
|||
}
|
||||
|
||||
func (rc *ReporterConfig) newTransport() (jaeger.Transport, error) {
|
||||
return jaeger.NewUDPTransport(rc.LocalAgentHostPort, 0)
|
||||
switch {
|
||||
case rc.CollectorEndpoint != "" && rc.User != "" && rc.Password != "":
|
||||
return transport.NewHTTPTransport(rc.CollectorEndpoint, transport.HTTPBatchSize(1),
|
||||
transport.HTTPBasicAuth(rc.User, rc.Password)), nil
|
||||
case rc.CollectorEndpoint != "":
|
||||
return transport.NewHTTPTransport(rc.CollectorEndpoint, transport.HTTPBatchSize(1)), nil
|
||||
default:
|
||||
return jaeger.NewUDPTransport(rc.LocalAgentHostPort, 0)
|
||||
}
|
||||
}
|
||||
|
|
27
vendor/github.com/uber/jaeger-client-go/config/config_env.go
generated
vendored
27
vendor/github.com/uber/jaeger-client-go/config/config_env.go
generated
vendored
|
@ -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
|
||||
}
|
||||
|
||||
|
|
8
vendor/github.com/uber/jaeger-client-go/config/options.go
generated
vendored
8
vendor/github.com/uber/jaeger-client-go/config/options.go
generated
vendored
|
@ -34,6 +34,7 @@ type Options struct {
|
|||
observers []jaeger.Observer
|
||||
gen128Bit bool
|
||||
zipkinSharedRPCSpan bool
|
||||
maxTagValueLength int
|
||||
tags []opentracing.Tag
|
||||
injectors map[interface{}]jaeger.Injector
|
||||
extractors map[interface{}]jaeger.Extractor
|
||||
|
@ -101,6 +102,13 @@ func ZipkinSharedRPCSpan(zipkinSharedRPCSpan bool) Option {
|
|||
}
|
||||
}
|
||||
|
||||
// MaxTagValueLength can be provided to override the default max tag value length.
|
||||
func MaxTagValueLength(maxTagValueLength int) Option {
|
||||
return func(c *Options) {
|
||||
c.maxTagValueLength = maxTagValueLength
|
||||
}
|
||||
}
|
||||
|
||||
// Tag creates an option that adds a tracer-level tag.
|
||||
func Tag(key string, value interface{}) Option {
|
||||
return func(c *Options) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue