collect

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TraceSendGotRoot        = "trace_send_got_root"
	TraceSendExpired        = "trace_send_expired"
	TraceSendEjectedFull    = "trace_send_ejected_full"
	TraceSendEjectedMemsize = "trace_send_ejected_memsize"
)

These are the names of the metrics we use to track our send decisions.

Variables

View Source
var ErrWouldBlock = errors.New("not adding span, channel buffer is full")

Functions

This section is empty.

Types

type Collector

type Collector interface {
	// AddSpan adds a span to be collected, buffered, and merged into a trace.
	// Once the trace is "complete", it'll be passed off to the sampler then
	// scheduled for transmission.
	AddSpan(*types.Span) error
	AddSpanFromPeer(*types.Span) error
	Stressed() bool
	GetStressedSampleRate(traceID string) (rate uint, keep bool, reason string)
	ProcessSpanImmediately(sp *types.Span, keep bool, sampleRate uint, reason string)
}

func GetCollectorImplementation

func GetCollectorImplementation(c config.Config) Collector

type InMemCollector

type InMemCollector struct {
	Config         config.Config          `inject:""`
	Logger         logger.Logger          `inject:""`
	Transmission   transmit.Transmission  `inject:"upstreamTransmission"`
	Metrics        metrics.Metrics        `inject:"genericMetrics"`
	SamplerFactory *sample.SamplerFactory `inject:""`
	StressRelief   StressReliever         `inject:"stressRelief"`

	// For test use only
	BlockOnAddSpan bool
	// contains filtered or unexported fields
}

InMemCollector is a single threaded collector.

func (*InMemCollector) AddSpan

func (i *InMemCollector) AddSpan(sp *types.Span) error

AddSpan accepts the incoming span to a queue and returns immediately

func (*InMemCollector) AddSpanFromPeer

func (i *InMemCollector) AddSpanFromPeer(sp *types.Span) error

AddSpan accepts the incoming span to a queue and returns immediately

func (*InMemCollector) GetStressedSampleRate added in v1.20.0

func (i *InMemCollector) GetStressedSampleRate(traceID string) (rate uint, keep bool, reason string)

func (*InMemCollector) ProcessSpanImmediately added in v1.20.0

func (i *InMemCollector) ProcessSpanImmediately(sp *types.Span, keep bool, sampleRate uint, reason string)

ProcessSpanImmediately is an escape hatch used under stressful conditions -- it submits a span for immediate transmission without enqueuing it for normal processing. This means it ignores dry run mode and doesn't build a complete trace context or cache the trace in the active trace buffer. It only gets called on the first span for a trace under stressful conditions; we got here because the StressRelief system detected that this is a new trace AND that it is being sampled. Therefore, we also put the traceID into the sent traces cache as "kept". It doesn't do any logging and barely touches metrics; this is about as minimal as we can make it.

func (*InMemCollector) Start

func (i *InMemCollector) Start() error

func (*InMemCollector) Stop

func (i *InMemCollector) Stop() error

func (*InMemCollector) Stressed added in v1.20.0

func (i *InMemCollector) Stressed() bool

Stressed returns true if the collector is undergoing significant stress

type MockStressReliever added in v1.20.0

type MockStressReliever struct{}

func (*MockStressReliever) GetSampleRate added in v1.20.0

func (m *MockStressReliever) GetSampleRate(traceID string) (rate uint, keep bool, reason string)

func (*MockStressReliever) Recalc added in v1.20.0

func (m *MockStressReliever) Recalc()

func (*MockStressReliever) Start added in v1.20.0

func (m *MockStressReliever) Start() error

func (*MockStressReliever) StressLevel added in v1.20.0

func (m *MockStressReliever) StressLevel() uint

func (*MockStressReliever) Stressed added in v1.20.0

func (m *MockStressReliever) Stressed() bool

func (*MockStressReliever) UpdateFromConfig added in v1.20.0

func (m *MockStressReliever) UpdateFromConfig(cfg config.StressReliefConfig) error

type StressRelief added in v1.20.0

type StressRelief struct {
	RefineryMetrics metrics.Metrics `inject:"metrics"`
	Logger          logger.Logger   `inject:""`
	Done            chan struct{}
	// contains filtered or unexported fields
}

func (*StressRelief) GetSampleRate added in v1.20.0

func (s *StressRelief) GetSampleRate(traceID string) (rate uint, keep bool, reason string)

func (*StressRelief) Recalc added in v1.20.0

func (s *StressRelief) Recalc()

We want to calculate the stress from various values around the system. Each key value can be reported as a key-value. This should be called periodically.

func (*StressRelief) Start added in v1.20.0

func (s *StressRelief) Start() error

func (*StressRelief) StressLevel added in v1.20.0

func (s *StressRelief) StressLevel() uint

func (*StressRelief) Stressed added in v1.20.0

func (s *StressRelief) Stressed() bool

Stressed() indicates whether the system should act as if it's stressed. Note that the stress_level metric is independent of mode.

func (*StressRelief) UpdateFromConfig added in v1.20.0

func (s *StressRelief) UpdateFromConfig(cfg config.StressReliefConfig) error

type StressReliefCalculation added in v1.20.0

type StressReliefCalculation struct {
	Numerator   string
	Denominator string
	Algorithm   string
	Reason      string
}

type StressReliefMode added in v1.20.0

type StressReliefMode int
const (
	Never StressReliefMode = iota
	Monitor
	Always
)

type StressReliever added in v1.20.0

type StressReliever interface {
	Start() error
	UpdateFromConfig(cfg config.StressReliefConfig) error
	Recalc()
	StressLevel() uint
	Stressed() bool
	GetSampleRate(traceID string) (rate uint, keep bool, reason string)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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