sampling

package
v1.1.66 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2023 License: Apache-2.0 Imports: 4 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	SampleKey = "sample"
)

SampleKey - the key used in the metadata when a transaction qualifies for sampling and should be sent to Observer

Variables

View Source
var (
	ErrGlobalSamplingCfg = errors.New(1520, "the global sampling config has not been initialized")
	ErrSamplingCfg       = errors.New(1521, "sampling percentage must be between 0 and 100")
)

Config errors

Functions

func FilterEvents

func FilterEvents(events []publisher.Event) ([]publisher.Event, error)

FilterEvents - returns an array of events that are part of the sample

func GetGlobalSamplingPercentage

func GetGlobalSamplingPercentage() (int, error)

GetGlobalSamplingPercentage -

func SetupSampling

func SetupSampling(cfg Sampling, offlineMode bool) error

SetupSampling - set up the global sampling for use by traceability

func ShouldSampleTransaction

func ShouldSampleTransaction(details TransactionDetails) (bool, error)

ShouldSampleTransaction - receives the transaction details and returns true to sample it false to not

Types

type Sampling

type Sampling struct {
	Percentage      int  `config:"percentage"    validate:"min=0, max=100"`
	PerAPI          bool `config:"per_api"`
	PerSub          bool `config:"per_subscription"`
	ReportAllErrors bool `config:"reportAllErrors" yaml:"reportAllErrors"`
}

Sampling - configures the sampling of events the agent sends to Amplify

func DefaultConfig

func DefaultConfig() Sampling

DefaultConfig - returns a default sampling config where all transactions are sent

type TransactionDetails

type TransactionDetails struct {
	Status string
	APIID  string
	SubID  string
}

TransactionDetails - details about the transaction that are used for sampling

Jump to

Keyboard shortcuts

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