SkyAPM / go2sky

Distributed tracing and monitor SDK in Go for Apache SkyWalking APM
https://skywalking.apache.org/
Apache License 2.0
447 stars 122 forks source link

Build tracer with customized sampler object not just by sampling rate #84

Closed buxingzhe closed 3 years ago

buxingzhe commented 3 years ago

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] Currently, trace_opts.go provides a function to set sampler with signature func WithSampler(samplingRate float64) TracerOption . I hope it can provide another function like func WithSampler(sampler Sampler) TracerOption, then I can set my customized sampler. At the same time, the RandomSampler has a little bug:

func (s *RandomSampler) IsSampled(operation string) bool {
    return s.threshold >= s.rand.Intn(100)
}

It should be s.threshold > s.rand.Intn(100).

Describe the solution you'd like A clear and concise description of what you want to happen.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.