Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jun 14, 2023. It is now read-only.
This repository was archived by the owner on Jun 14, 2023. It is now read-only.

RandomSampler may get not sampled when samplingRate is 0 #101

@matianjun1

Description

@matianjun1

go2sky/sampler.go

Lines 52 to 56 in 520133d

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

rand.Intn(100) should be [0-100), so that when samplingRate is 0, IsSampled maybe true

fix like this s.threshold >= s.rand.Intn(100) + 1

If confused with IsSampled(), NewConstSampler always return false when input param sample is false

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions