* 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. 6
      pkg/net/trace/jaeger/jaeger.go

@ -58,7 +58,7 @@ func TracerFromEnvFlag() (Tracer, error) {
return nil, err
}
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.
@ -71,5 +71,5 @@ func Init(cfg *Config) {
}
}
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.
func NewTracer(serviceName string, report reporter, disableSample bool) Tracer {
sampler := newSampler(_probability)
func NewTracer(serviceName string, report reporter, disableSample bool, probability float32) Tracer {
sampler := newSampler(probability)
// default internal tags
tags := extendTag()

@ -11,6 +11,7 @@ import (
var (
_jaegerAppID = env.AppID
_jaegerEndpoint = "http://127.0.0.1:9191"
_probability = 0.00025
)
func init() {
@ -27,7 +28,10 @@ func init() {
}
// Init Init
func Init() {
c := &Config{Endpoint: _jaegerEndpoint, BatchSize: 120}
trace.SetGlobalTracer(trace.NewTracer(_jaegerAppID, newReport(c), true))
func Init(cfg *Config) {
c := cfg
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 {
Endpoint string
BatchSize int
AppID string
Endpoint string
BatchSize int
Probability float32
}
type JaegerReporter struct {

Loading…
Cancel
Save