* add jaeger config

* add probability
v1.0.x
冯国庆 3 years ago committed by GitHub
parent 4d2522f0b6
commit a9b8af4c55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      pkg/net/trace/config.go
  2. 4
      pkg/net/trace/dapper.go
  3. 10
      pkg/net/trace/jaeger/config.go
  4. 2
      pkg/net/trace/jaeger/jaeger.go

@ -58,7 +58,7 @@ func TracerFromEnvFlag() (Tracer, error) {
return nil, err return nil, err
} }
report := newReport(cfg.Network, cfg.Addr, time.Duration(cfg.Timeout), cfg.ProtocolVersion) report := newReport(cfg.Network, cfg.Addr, time.Duration(cfg.Timeout), cfg.ProtocolVersion)
return NewTracer(env.AppID, report, cfg.DisableSample), nil return NewTracer(env.AppID, report, cfg.DisableSample, _probability), nil
} }
// Init init trace report. // Init init trace report.
@ -71,5 +71,5 @@ func Init(cfg *Config) {
} }
} }
report := newReport(cfg.Network, cfg.Addr, time.Duration(cfg.Timeout), cfg.ProtocolVersion) report := newReport(cfg.Network, cfg.Addr, time.Duration(cfg.Timeout), cfg.ProtocolVersion)
SetGlobalTracer(NewTracer(env.AppID, report, cfg.DisableSample)) SetGlobalTracer(NewTracer(env.AppID, report, cfg.DisableSample, _probability))
} }

@ -14,8 +14,8 @@ const (
) )
// NewTracer new a tracer. // NewTracer new a tracer.
func NewTracer(serviceName string, report reporter, disableSample bool) Tracer { func NewTracer(serviceName string, report reporter, disableSample bool, probability float32) Tracer {
sampler := newSampler(_probability) sampler := newSampler(probability)
// default internal tags // default internal tags
tags := extendTag() tags := extendTag()

@ -11,6 +11,7 @@ import (
var ( var (
_jaegerAppID = env.AppID _jaegerAppID = env.AppID
_jaegerEndpoint = "http://127.0.0.1:9191" _jaegerEndpoint = "http://127.0.0.1:9191"
_probability = 0.00025
) )
func init() { func init() {
@ -27,7 +28,10 @@ func init() {
} }
// Init Init // Init Init
func Init() { func Init(cfg *Config) {
c := &Config{Endpoint: _jaegerEndpoint, BatchSize: 120} c := cfg
trace.SetGlobalTracer(trace.NewTracer(_jaegerAppID, newReport(c), true)) if c == nil {
c = &Config{AppID: _jaegerAppID, Endpoint: _jaegerEndpoint, BatchSize: 120, Probability: float32(_probability)}
}
trace.SetGlobalTracer(trace.NewTracer(c.AppID, newReport(c), true, c.Probability))
} }

@ -6,8 +6,10 @@ import (
) )
type Config struct { type Config struct {
AppID string
Endpoint string Endpoint string
BatchSize int BatchSize int
Probability float32
} }
type JaegerReporter struct { type JaegerReporter struct {

Loading…
Cancel
Save