filter

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2023 License: Apache-2.0 Imports: 2 Imported by: 6

README

Go Agent Filter

Filtering capability as specified in Hypertrace filter specification can be added to instrumentations.

Example

// Filter requests containing "foo" in URL
type FooURLFilter struct {
}

// `result.FilterResult` will contain a bool `Block` which when set to `true` means to block the request and `false` to
// continue the request. It also contains `ResponseStatusCode` which is the HTTP status code to return.

// Filter evaluates whether request should be blocked based on the url and headers.
func (FooURLFilter) EvaluateURLAndHeaders(span sdk.Span, url string, headers map[string][]string) result.FilterResult {
	return false
}

// Filter evaluates whether request should be blocked based on the body.
func (FooURLFilter) EvaluateBody(span sdk.Span, body []byte) result.FilterResult {
	return false
}

// Filter evaluates whether request should be blocked based on url, headers and body.
func (FooURLFilter) Evaluate(span sdk.Span, url string, body []byte, headers map[string][]string) result.FilterResult {
	return false
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter interface {
	// EvaluateURLAndHeaders can be used to evaluate both URL and headers
	EvaluateURLAndHeaders(span sdk.Span, url string, headers map[string][]string) result.FilterResult

	// EvaluateBody can be used to evaluate the body content
	EvaluateBody(span sdk.Span, body []byte, headers map[string][]string) result.FilterResult

	// Evaluate can be used to evaluate URL, headers and body content in one call
	Evaluate(span sdk.Span, url string, body []byte, headers map[string][]string) result.FilterResult
}

Filter evaluates whether request should be blocked, `true` blocks the request and `false` continues it.

type MultiFilter

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

MultiFilter encapsulates multiple filters

func NewMultiFilter

func NewMultiFilter(filter ...Filter) *MultiFilter

NewMultiFilter creates a new MultiFilter

func (*MultiFilter) Evaluate added in v0.7.0

func (m *MultiFilter) Evaluate(span sdk.Span, url string, body []byte, headers map[string][]string) result.FilterResult

Evaluate runs body evaluators for each filter until one returns true

func (*MultiFilter) EvaluateBody

func (m *MultiFilter) EvaluateBody(span sdk.Span, body []byte, headers map[string][]string) result.FilterResult

EvaluateBody runs body evaluators for each filter until one returns true

func (*MultiFilter) EvaluateURLAndHeaders

func (m *MultiFilter) EvaluateURLAndHeaders(span sdk.Span, url string, headers map[string][]string) result.FilterResult

EvaluateURLAndHeaders runs URL and headers evaluation for each filter until one returns true

type NoopFilter

type NoopFilter struct{}

NoopFilter is a filter that always evaluates to false

func (NoopFilter) Evaluate added in v0.7.0

func (NoopFilter) Evaluate(span sdk.Span, url string, body []byte, headers map[string][]string) result.FilterResult

Evaluate that always returns false

func (NoopFilter) EvaluateBody

func (NoopFilter) EvaluateBody(span sdk.Span, body []byte, headers map[string][]string) result.FilterResult

EvaluateBody that always returns false

func (NoopFilter) EvaluateURLAndHeaders

func (NoopFilter) EvaluateURLAndHeaders(span sdk.Span, url string, headers map[string][]string) result.FilterResult

EvaluateURLAndHeaders that always returns false

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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