flowlog

package
v0.0.0-...-333d07d Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MessageHandler

type MessageHandler func(vanflow.RecordMessage)

func New

func New(ctx context.Context, logFn func(msg string, args ...any), rules []Rule) MessageHandler

New creates a MessageHandler given a set of rules and a log output function

type RecordTypeSet

type RecordTypeSet map[vanflow.TypeMeta]struct{}

RecordTypeSet specifies the Record Types that a Rule is applicable for.

func NewRecordTypeSet

func NewRecordTypeSet(records ...vanflow.Record) RecordTypeSet

func NewRecordTypeSetAll

func NewRecordTypeSetAll() RecordTypeSet

NewRecordTypeSetAll returns a special RecordTypeSet that matches records of all types

type Rule

type Rule struct {
	// Priority of the rule. Lowest matching a record type wins.
	Priority int
	// Match is the set of record types the rule applies to
	Match RecordTypeSet
	// Strategy for sampling records
	Strategy SampleStrategy
}

Rule specifies how particular vanflow record types should be logged.

type SampleStrategy

type SampleStrategy interface {
	// Sample returns true when the record should be logged
	Sample(r vanflow.Record) bool
}

func RateLimited

func RateLimited(limit float64, burst int) SampleStrategy

RateLimited SampleStrategy samples events up to a limit (in events per second). Events exceeding the limit are not logged.

func TransportFlowHash

func TransportFlowHash(percent float64, parent SampleStrategy) SampleStrategy

TransportFlowHash uses a deterministic hash based on a TransportBiflow ID. Uses the AppBiflow Parent field (Transport ID) so that ideally related flows are sampled together.

func Unlimited

func Unlimited() SampleStrategy

Unlimited SampleStrategy always samples

Jump to

Keyboard shortcuts

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