trace

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2021 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// One sample is collected per epoch
	RateLimitEpochTime = "rate-limit-epoch-time"

	// Maximum time to remember a request which we selected, but haven't seen a reaponse.
	RateLimitMaxDuration = "rate-limit-max-duration"

	// Channel size for packets coming in to collector
	RateLimitQueueDepth = "rate-limit-queue-depth"

	// Parameter controlling exponential moving average
	RateLimitExponentialAlpha = "rate-limit-exponential-alpha"
)

Variables

This section is empty.

Functions

func Collect

func Collect(stop <-chan struct{}, intf, bpfFilter string, proc Collector, packetCount PacketCountConsumer) error

func CountTcpPackets added in v0.13.0

func CountTcpPackets(ifc string, packetCount PacketCountConsumer) pcap.NetworkTrafficObserver

Observe every captured TCP segment here

Types

type BackendCollector

type BackendCollector struct {
	// contains filtered or unexported fields
}

Sends witnesses up to akita cloud.

func (*BackendCollector) Close

func (c *BackendCollector) Close() error

func (*BackendCollector) Process

type Collector

type Collector interface {
	// Hands new data from network to the collector. The implementation may choose
	// to process them asynchronously (e.g. to wait for the response to a
	// corresponding request).
	// Implementations should only return error if the error is unrecoverable and
	// the whole process should stop immediately.
	Process(akinet.ParsedNetworkTraffic) error

	// Implementations must complete processing all requests/responses before
	// returning.
	Close() error
}

func New3PTrackerFilterCollector

func New3PTrackerFilterCollector(col Collector) Collector

Filters out third-party trackers.

func NewHTTPHostFilterCollector

func NewHTTPHostFilterCollector(matchers []*regexp.Regexp, col Collector) Collector

func NewHTTPPathFilterCollector

func NewHTTPPathFilterCollector(matchers []*regexp.Regexp, col Collector) Collector

Filters out HTTP paths.

type HARCollector

type HARCollector struct {
	// contains filtered or unexported fields
}

func NewHARCollector

func NewHARCollector(interfaceName, outDir string, isOutbound bool, tags map[tags.Key]string) *HARCollector

func (*HARCollector) Close

func (h *HARCollector) Close() error

TODO: output HAR files periodically instead of buffering everything in memory.

func (*HARCollector) Process

type PacketCountCollector added in v0.15.1

type PacketCountCollector struct {
	PacketCounts PacketCountConsumer
	Collector    Collector
}

This is a shim to add packet counts based on payload type.

func (*PacketCountCollector) Close added in v0.15.1

func (pc *PacketCountCollector) Close() error

func (*PacketCountCollector) Process added in v0.15.1

type PacketCountConsumer added in v0.13.0

type PacketCountConsumer interface {
	// Add an additional measurement to the current count
	Update(delta PacketCounters)
}

A consumer accepts incremental updates in the form of PacketCounters.

type PacketCountDiscard added in v0.13.0

type PacketCountDiscard struct {
}

Discard the count

func (*PacketCountDiscard) Update added in v0.13.0

func (d *PacketCountDiscard) Update(_ PacketCounters)

type PacketCountSummary added in v0.13.0

type PacketCountSummary struct {
	// contains filtered or unexported fields
}

A consumer that sums the count by (interface, port) pairs. In the future, this could put counters on a pipe and do the increments in a separate goroutine, but we would *still* need a mutex to read the totals out. TODO: limit maximum size

func NewPacketCountSummary added in v0.13.0

func NewPacketCountSummary() *PacketCountSummary

func (*PacketCountSummary) AllPorts added in v0.13.0

func (s *PacketCountSummary) AllPorts() []PacketCounters

All available port numbers

func (*PacketCountSummary) Total added in v0.13.0

func (*PacketCountSummary) TotalOnInterface added in v0.13.0

func (s *PacketCountSummary) TotalOnInterface(name string) PacketCounters

Packet counters summed over interface

func (*PacketCountSummary) TotalOnPort added in v0.13.0

func (s *PacketCountSummary) TotalOnPort(port int) PacketCounters

Packet counters summed over port

func (*PacketCountSummary) Update added in v0.13.0

func (s *PacketCountSummary) Update(c PacketCounters)

type PacketCounters added in v0.13.0

type PacketCounters struct {
	// Flow
	Interface string
	SrcPort   int
	DstPort   int

	// Number of events
	TCPPackets    int
	HTTPRequests  int
	HTTPResponses int
	Unparsed      int
}

We produce a set of packet counters indexed by interface and port number (*either* source or destination.)

func (*PacketCounters) Add added in v0.13.0

func (c *PacketCounters) Add(d PacketCounters)

type SamplingCollector

type SamplingCollector struct {
	SampleRate float64
	Collector  Collector
}

Wraps a Collector and peforms sampling.

func (*SamplingCollector) Close

func (sc *SamplingCollector) Close() error

func (*SamplingCollector) Process

type SharedRateLimit added in v0.16.0

type SharedRateLimit struct {
	// Current epoch: start time, sampling start time, count of witnesses captured
	CurrentEpochStart    time.Time
	SampleIntervalStart  time.Time
	SampleIntervalActive bool
	SampleIntervalCount  int

	// Witnesses per minute (configured value) and per epoch (derived value)
	WitnessesPerMinute float64
	WitnessesPerEpoch  int

	// Current estimate of time taken to capture WitnessesPerEpoch
	EstimatedSampleInterval time.Duration
	FirstEstimate           bool
	// contains filtered or unexported fields
}

func NewRateLimit added in v0.16.0

func NewRateLimit(witnessesPerMinute float64) *SharedRateLimit

func (*SharedRateLimit) AllowHTTPRequest added in v0.16.0

func (r *SharedRateLimit) AllowHTTPRequest() bool

Check if request should be sampled; increase the count by one.

func (*SharedRateLimit) AllowOther added in v0.16.0

func (r *SharedRateLimit) AllowOther() bool

Check if a non-HTTP packet should be sampled. All non-HTTP requests are passed through so they can be counted, if we're in an interval, but don't (yet) count against the witness budget. (For example, we might want to start counting source/dest pairs for HTTPS, or otherwise recording unparsable network traffic.)func (r *SharedRateLimit) AllowOther() bool {

func (*SharedRateLimit) IntervalStarted added in v0.16.0

func (r *SharedRateLimit) IntervalStarted() bool

func (*SharedRateLimit) NewCollector added in v0.16.0

func (r *SharedRateLimit) NewCollector(next Collector) Collector

func (*SharedRateLimit) Stop added in v0.16.0

func (r *SharedRateLimit) Stop()

type TeeCollector

type TeeCollector struct {
	Dst1 Collector
	Dst2 Collector
}

Not to be confused with coffee collector.

func (TeeCollector) Close

func (tc TeeCollector) Close() error

func (TeeCollector) Process

type UserTrafficCollector

type UserTrafficCollector struct {
	Collector Collector
}

Filters out CLI's own traffic to Akita APIs.

func (*UserTrafficCollector) Close

func (sc *UserTrafficCollector) Close() error

func (*UserTrafficCollector) Process

Jump to

Keyboard shortcuts

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