Documentation
¶
Overview ¶
Package sampling provides the sampling strategy.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultSamplingRule = &Manifest{ Version: 2, Default: &Rule{ FixedTarget: 1, Rate: 0.05, }, Rules: []*Rule{}, }
DefaultSamplingRule is default sampling rule, if centralized sampling rule is not available.
Functions ¶
func WildcardMatch ¶
WildcardMatch returns whether the text matchers the pattern.
func WildcardMatchCaseInsensitive ¶
WildcardMatchCaseInsensitive returns whether the text matchers the pattern.
Types ¶
type CentralizedStrategy ¶
type CentralizedStrategy struct {
// contains filtered or unexported fields
}
CentralizedStrategy is an implementation of SamplingStrategy.
func NewCentralizedStrategy ¶
func NewCentralizedStrategy(addr string, manifest *Manifest) (*CentralizedStrategy, error)
NewCentralizedStrategy returns new centralized sampling strategy with a fallback on the local rule. If local rule is nil, the DefaultSamplingRule is used.
func (*CentralizedStrategy) ShouldTrace ¶
func (s *CentralizedStrategy) ShouldTrace(req *Request) *Decision
ShouldTrace implements Strategy.
type LocalizedStrategy ¶
type LocalizedStrategy struct {
// contains filtered or unexported fields
}
LocalizedStrategy makes trace sampling decisions based on a set of rules provided in a local JSON file. Trace sampling decisions are made by the root node in the trace. If a sampling decision is made by the root service, it will be passed to downstream services through the trace header.
func NewLocalizedStrategy ¶
func NewLocalizedStrategy(manifest *Manifest) (*LocalizedStrategy, error)
NewLocalizedStrategy returns new LocalizedStrategy.
func (*LocalizedStrategy) ShouldTrace ¶
func (s *LocalizedStrategy) ShouldTrace(req *Request) *Decision
ShouldTrace implements Strategy.
type Manifest ¶
type Manifest struct { Version int `json:"version"` Default *Rule `json:"default"` Rules []*Rule `json:"rules"` }
Manifest is a list of sampling rules.
func DecodeManifest ¶
DecodeManifest decodes json-encoded manifest file.
type Rule ¶
type Rule struct { // Description Description string `json:"description"` // The hostname from the HTTP host header. Host string `json:"host"` // The method of the HTTP request. HTTPMethod string `json:"http_method"` // The URL path of the request. URLPath string `json:"url_path"` // The name of the instrumented service, as it appears in the service map. ServiceName string `json:"service_name"` // FixedTarget FixedTarget int64 `json:"fixed_target"` // The rate of matching requests to instrument, after the reservoir is exhausted. Rate float64 `json:"rate"` }
Rule is a sampling rule.
type Strategy ¶
type Strategy interface { // ShouldTrace returns a sampling decision for an incoming request. ShouldTrace(request *Request) *Decision }
Strategy provides an interface for implementing trace sampling strategies.
func NewAllStrategy ¶
func NewAllStrategy() Strategy
NewAllStrategy returns the strategy that samples all segments.
type StrategyFunc ¶ added in v1.7.0
StrategyFunc is an adapter to allow the use of ordinary functions as sampling strategies.
func (StrategyFunc) ShouldTrace ¶ added in v1.7.0
func (s StrategyFunc) ShouldTrace(request *Request) *Decision