filter

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2022 License: Apache-2.0 Imports: 1 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 {
}

// Filter evaluates whether request should be blocked, `true` blocks the request and `false` continues it.
func (FooURLFilter) EvaluateURLAndHeaders(span sdk.Span, url string, headers map[string][]string) bool {
	return false
}

// Filter evaluates whether request should be blocked, `true` blocks the request and `false` continues it.
func (FooURLFilter) EvaluateBody(span sdk.Span, body []byte) bool {
	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) bool

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

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) EvaluateBody

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

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) bool

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) EvaluateBody

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

EvaluateBody that always returns false

func (NoopFilter) EvaluateURLAndHeaders

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

EvaluateURLAndHeaders that always returns false

Jump to

Keyboard shortcuts

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