func (ds *DeterministicSampler) GetSampleRate() int {
	return ds.sampleRate
}
GetSampleRate is an accessor to find out how this sampler was initialized
package sample
import (
	"crypto/sha1"
	"errors"
	"math"
)
var (
	ErrInvalidSampleRate = errors.New("sample rate must be >= 1")
)
var GlobalSampler *DeterministicSampler
type DeterministicSampler struct {
	sampleRate int
	upperBound uint32
}
func NewDeterministicSampler(sampleRate uint) (*DeterministicSampler, error) {
	if sampleRate < 1 {
		return nil, ErrInvalidSampleRate
	}
	upperBound := math.MaxUint32 / uint32(sampleRate)
	return &DeterministicSampler{
		sampleRate: int(sampleRate),
		upperBound: upperBound,
	}, nil
}
func bytesToUint32be(b []byte) uint32 {
	return uint32(b[3]) | (uint32(b[2]) << 8) | (uint32(b[1]) << 16) | (uint32(b[0]) << 24)
}
func (ds *DeterministicSampler) Sample(determinant string) bool {
	if ds.sampleRate == 1 {
		return true
	}
	sum := sha1.Sum([]byte(determinant))
	v := bytesToUint32be(sum[:4])
	return v <= ds.upperBound
}