diag

package
v0.21.83 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: Apache-2.0, MIT Imports: 13 Imported by: 3

Documentation

Overview

Package diag provides a set of network throttling filters for diagnostic purpose.

The filters enable adding artificial latency, limiting bandwidth or chunking responses with custom chunk size and delay. This throttling can be applied to the proxy responses or to the outgoing backend requests. An additional filter, randomContent, can be used to generate response with random text of specified length.

Index

Constants

View Source
const (
	// Deprecated, use filters.RandomContentName instead
	RandomName = filters.RandomContentName
	// Deprecated, use filters.RepeatContentName instead
	RepeatName = filters.RepeatContentName
	// Deprecated, use filters.LatencyName instead
	LatencyName = filters.LatencyName
	// Deprecated, use filters.ChunksName instead
	ChunksName = filters.ChunksName
	// Deprecated, use filters.BandwidthName instead
	BandwidthName = filters.BandwidthName
	// Deprecated, use filters.BackendLatencyName instead
	BackendLatencyName = filters.BackendLatencyName
	// Deprecated, use filters.BackendBandwidthName instead
	BackendBandwidthName = filters.BackendBandwidthName
	// Deprecated, use filters.BackendChunksName instead
	BackendChunksName = filters.BackendChunksName
)
View Source
const AbsorbName = filters.AbsorbName

AbsorbName contains the name of the absorb filter. Deprecated, use filters.AbsorbName instead

View Source
const AbsorbSilentName = filters.AbsorbSilentName

AbsorbSilentName contains the name of the absorbSilent filter. Deprecated, use filters.AbsorbSilentName instead

Variables

This section is empty.

Functions

func NewAbsorb added in v0.11.31

func NewAbsorb() filters.Spec

NewAbsorb initializes a filter spec for the absorb filter.

The absorb filter reads and discards the payload of the incoming requests. It logs with INFO level and a unique ID per request: - the event of receiving the request - partial and final events for consuming request payload and total consumed byte count - the finishing event of the request - any read errors other than EOF

func NewAbsorbSilent added in v0.11.179

func NewAbsorbSilent() filters.Spec

NewAbsorbSilent initializes a filter spec for the absorbSilent filter, similar to the absorb filter, but without verbose logging of the absorbed payload.

The absorbSilent filter reads and discards the payload of the incoming requests. It only logs read errors other than EOF.

func NewBackendBandwidth

func NewBackendBandwidth() filters.Spec

NewBackendBandwidth is the equivalent of NewBandwidth but for outgoing backend requests. Eskip example:

r: * -> backendBandwidth(30) -> "https://www.example.org";

func NewBackendChunks

func NewBackendChunks() filters.Spec

NewBackendChunks is the equivalent of NewChunks but for outgoing backend requests. Eskip example:

r: * -> backendChunks(1024, 120) -> "https://www.example.org";

func NewBackendLatency

func NewBackendLatency() filters.Spec

NewBackendLatency is the equivalent of NewLatency but for outgoing backend requests. Eskip example:

r: * -> backendLatency(120) -> "https://www.example.org";

func NewBandwidth

func NewBandwidth() filters.Spec

NewBandwidth creates a filter specification whose filter instances can be used to maximize the bandwidth of the responses. It expects the bandwidth in kbyte/sec as an argument.

r: * -> bandwidth(30) -> "https://www.example.org";

func NewChunks

func NewChunks() filters.Spec

NewChunks creates a filter specification whose filter instances can be used set artificial delays in between response chunks. It expects the byte length of the chunks and the delay milliseconds.

r: * -> chunks(1024, "120ms") -> "https://www.example.org";

func NewHistogramRequestLatency added in v0.16.136

func NewHistogramRequestLatency() filters.Spec

NewHistogramRequestLatency creates filters that add latency to requests according to the histogram distribution. It expects a list of interleaved duration strings and numbers that defines a histogram. Duration strings define boundaries of consecutive buckets and numbers define bucket weights. The filter randomly selects a bucket with probability equal to its weight divided by the sum of all bucket weights (which must be non-zero) and then sleeps for a random duration in between bucket boundaries. Eskip example:

r: * -> histogramRequestLatency("0ms", 50, "5ms", 0, "10ms", 30, "15ms", 20, "20ms") -> "https://www.example.org";

The example above adds a latency * between 0ms and 5ms to 50% of the requests * between 5ms and 10ms to 0% of the requests * between 10ms and 15ms to 30% of the requests * and between 15ms and 20ms to 20% of the requests.

func NewHistogramResponseLatency added in v0.16.136

func NewHistogramResponseLatency() filters.Spec

NewHistogramResponseLatency creates filters that add latency to responses according to the histogram distribution, similar to NewHistogramRequestLatency.

func NewLatency

func NewLatency() filters.Spec

NewLatency creates a filter specification whose filter instances can be used to add additional latency to responses. It expects the latency in milliseconds as an argument. It always adds this value in addition to the natural latency, and does not do any adjustments. Eskip example:

r: * -> latency(120) -> "https://www.example.org";

func NewLogBody added in v0.18.96

func NewLogBody() filters.Spec

NewLogBody creates a filter specification for the 'logBody()' filter.

func NewLogHeader added in v0.11.51

func NewLogHeader() filters.Spec

NewLogHeader creates a filter specification for the 'logHeader()' filter.

func NewNormalRequestLatency added in v0.13.75

func NewNormalRequestLatency() filters.Spec

NewNormalRequestLatency creates a latency for requests with normal distribution. Example delay around 1s with +/-120ms.

r: * -> normalRequestLatency("1s", "120ms") -> "https://www.example.org";

func NewNormalResponseLatency added in v0.13.75

func NewNormalResponseLatency() filters.Spec

NewNormalResponseLatency creates a latency for responses with normal distribution. Example delay around 1s with +/-120ms.

r: * -> normalRequestLatency("1s", "120ms") -> "https://www.example.org";

func NewRandom

func NewRandom() filters.Spec

NewRandom creates a filter specification whose filter instances can be used to respond to requests with random text of specified length. It expects the the byte length of the random response to be generated as an argument. Eskip example:

r: * -> randomContent(2048) -> <shunt>;

func NewRepeat added in v0.12.6

func NewRepeat() filters.Spec

NewRepeat creates a filter specification whose filter instances can be used to respond to requests with a repeated text. It expects the text and the byte length of the response body to be generated as arguments. Eskip example:

r: * -> repeatContent("x", 100) -> <shunt>;

func NewRepeatHex added in v0.15.32

func NewRepeatHex() filters.Spec

NewRepeatHex creates a filter specification whose filter instances can be used to respond to requests with a repeated bytes. It expects the bytes represented by the hexadecimal string of an even length and the byte length of the response body to be generated as arguments. Eskip example:

r: * -> repeatContentHex("0123456789abcdef", 16) -> <shunt>;

func NewTarpit added in v0.18.65

func NewTarpit() filters.Spec

func NewUniformRequestLatency added in v0.13.75

func NewUniformRequestLatency() filters.Spec

NewUniformRequestLatency creates a latency for requests with uniform distribution. Example delay around 1s with +/-120ms.

r: * -> uniformRequestLatency("1s", "120ms") -> "https://www.example.org";

func NewUniformResponseLatency added in v0.13.75

func NewUniformResponseLatency() filters.Spec

NewUniformResponseLatency creates a latency for responses with uniform distribution. Example delay around 1s with +/-120ms.

r: * -> uniformRequestLatency("1s", "120ms") -> "https://www.example.org";

func NewWrap added in v0.15.28

func NewWrap() filters.Spec

NewWrap creates a filter specification whose filter instances can be used to add prefix and suffix to the response. Eskip example:

r: * -> wrapContent("foo", "baz") -> inlineContent("bar") -> <shunt>;

func NewWrapHex added in v0.15.32

func NewWrapHex() filters.Spec

NewWrapHex creates a filter specification whose filter instances can be used to add prefix and suffix represented by the hexadecimal strings of an even length to the response. Eskip example:

r: * -> wrapContentHex("68657861", "6d616c") -> inlineContent("deci") -> <shunt>;

Types

This section is empty.

Jump to

Keyboard shortcuts

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