tracker

package
v0.0.0-...-b78484e Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2022 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	MaxFlows   int  // maximum number of active (non-filtered) flows allowed at a time
	MinSamples int  // minimum number of samples required to return ended flows for further processing
	Log        bool // if true, logging is enabled
}

A Config contains the tracker configuration.

type Flow

type Flow struct {
	ID             sampler.ID     // flow ID
	Data           []sampler.Data // flow data
	StartTime      time.Time      // start time (use only when wall time needed, otherwise use monotonic timestamps in Data)
	EndTime        time.Time      // end time (use only when wall time needed, otherwise use monotonic timestamps in Data)
	Filtered       bool           // true if flow will be tracked but data not recorded/returned
	Sampled        bool           // true if flow was sampled during current track operation
	PreExisting    bool           // true if flow already existed on startup
	Partial        bool           // true if flow was pre-existing or no final sample was seen
	SamplesDeduped int            // number of samples de-duped
	EndTstampNs    uint64         // monotonic nsec time of last sample, even if it was de-duped
}

A Flow contains the data needed by the tracker for one flow.

type Metrics

type Metrics struct {
	StartTime        time.Time
	TrackTimes       metrics.DurationStats
	TrackedFlows     int
	PriorEndedFlows  uint64
	PriorTrackerTime time.Time
	EndedFlows       uint64
	InstChurnRate    float64
	sync.RWMutex
}

func (*Metrics) ChurnRate

func (m *Metrics) ChurnRate() float64

type Tracker

type Tracker struct {
	Config
	// contains filtered or unexported fields
}

func NewTracker

func NewTracker(cfg Config) (t *Tracker)

func (*Tracker) Metrics

func (t *Tracker) Metrics() (m Metrics)

func (*Tracker) Track

func (t *Tracker) Track(ss []sampler.Sample) (ended []*Flow)

Track tracks flows by adding samples to non-filtered flows, deleting any ended flows (those with missing samples), and returning any ended flows that pass the tracker's configured constraints.

As an optimization, when enforcing filtering rules, we could allow some new flows to start in the same track operation that other flows end, but for now we don't do so to avoid the added complexity.

Jump to

Keyboard shortcuts

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