ingest_limits

package
v0.0.103-dev Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2025 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProfileAnnotationKeyThrottled = "pyroscope.ingest.throttled"
)

Variables

This section is empty.

Functions

func CreateTenantAnnotation added in v1.13.3

func CreateTenantAnnotation(c *Config) ([]byte, error)

func CreateUsageGroupAnnotation added in v1.13.3

func CreateUsageGroupAnnotation(c *Config, usageGroup string) ([]byte, error)

Types

type Config

type Config struct {
	// PeriodType provides the limit period / interval (e.g., "hour"). Used in error messages only.
	PeriodType string `yaml:"period_type" json:"period_type"`
	// PeriodLimitMb provides the limit that is being set in MB. Used in error messages only.
	PeriodLimitMb int `yaml:"period_limit_mb" json:"period_limit_mb"`
	// LimitResetTime provides the time (Unix seconds) when the limit will reset. Used in error messages only.
	LimitResetTime int64 `yaml:"limit_reset_time" json:"limit_reset_time"`
	// LimitReached instructs distributors to allow or reject profiles.
	LimitReached bool `yaml:"limit_reached" json:"limit_reached"`
	// Sampling controls the sampling parameters when the limit is reached.
	Sampling SamplingConfig `yaml:"sampling" json:"sampling"`
	// UsageGroups controls ingestion for pre-configured usage groups.
	UsageGroups map[string]UsageGroup `yaml:"usage_groups" json:"usage_groups"`
}

type InstanceCountProvider

type InstanceCountProvider interface {
	InstancesCount() int
}

type ProfileAnnotation added in v1.13.3

type ProfileAnnotation struct {
	Body interface{} `json:"body"`
}

type Sampler

type Sampler struct {
	*services.BasicService
	// contains filtered or unexported fields
}

Sampler provides a very simple time-based probabilistic sampling, intended to be used when a tenant limit has been reached.

The sampler will allow a number of requests in a time interval. Once the interval is over, the number of allowed requests resets.

We introduce a probability function for a request to be allowed defined as 1 / num_replicas, to account for the size of the cluster and because tracking is done in memory.

func NewSampler

func NewSampler(instanceCount InstanceCountProvider) *Sampler

func (*Sampler) AllowRequest

func (s *Sampler) AllowRequest(tenantID string, config SamplingConfig) bool

type SamplingConfig

type SamplingConfig struct {
	NumRequests int           `yaml:"num_requests" json:"num_requests"`
	Period      time.Duration `yaml:"period" json:"period"`
}

SamplingConfig describes the params of a simple probabilistic sampling mechanism.

Distributors should allow up to NumRequests requests through and then apply a cooldown (Period) after which more requests can be let through.

type ThrottledAnnotation added in v1.13.3

type ThrottledAnnotation struct {
	PeriodType        string `json:"periodType"`
	PeriodLimitMb     int    `json:"periodLimitMb"`
	LimitResetTime    int64  `json:"limitResetTime"`
	SamplingPeriodSec int    `json:"samplingPeriodSec"`
	SamplingRequests  int    `yaml:"samplingRequests"`
	UsageGroup        string `json:"usageGroup"`
}

type UsageGroup

type UsageGroup struct {
	PeriodLimitMb int  `yaml:"period_limit_mb" json:"period_limit_mb"`
	LimitReached  bool `yaml:"limit_reached" json:"limit_reached"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL