dpsink

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2018 License: Apache-2.0 Imports: 12 Imported by: 40

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultLogger = log.DefaultLogger.CreateChild()

DefaultLogger is used by package structs that don't have a default logger set.

View Source
var Discard = discardSink{}

Discard is a datapoint sink that does nothing with points it gets

Functions

This section is empty.

Types

type Counter

type Counter struct {
	TotalProcessErrors int64
	TotalDatapoints    int64
	TotalEvents        int64
	TotalProcessCalls  int64
	ProcessErrorPoints int64
	TotalProcessTimeNs int64
	CallsInFlight      int64
	Logger             log.Logger
}

Counter records stats on datapoints to go through it as a sink middleware

func (*Counter) AddDatapoints

func (c *Counter) AddDatapoints(ctx context.Context, points []*datapoint.Datapoint, next Sink) error

AddDatapoints will send points to the next sink and track points send to the next sink

func (*Counter) AddEvents

func (c *Counter) AddEvents(ctx context.Context, events []*event.Event, next Sink) error

AddEvents will send events to the next sink and track events sent to the next sink

func (*Counter) Datapoints

func (c *Counter) Datapoints() []*datapoint.Datapoint

Datapoints returns counter stats

type DSink

type DSink interface {
	AddDatapoints(ctx context.Context, points []*datapoint.Datapoint) error
}

A DSink is an object that can accept datapoints and do something with them, like forward them to some endpoint

type ESink

type ESink interface {
	AddEvents(ctx context.Context, events []*event.Event) error
}

A ESink is an object that can accept events and do something with them, like forward them to some endpoint

type EmptyMetricFilter

type EmptyMetricFilter struct {
	EmptyMetricFiltered int64
}

EmptyMetricFilter filters empty metric name datapoints

func (*EmptyMetricFilter) AddDatapoints

func (e *EmptyMetricFilter) AddDatapoints(ctx context.Context, points []*datapoint.Datapoint, next Sink) error

AddDatapoints will send points to the next sink that have a non empty metric name

func (*EmptyMetricFilter) FilterDatapoints

func (e *EmptyMetricFilter) FilterDatapoints(points []*datapoint.Datapoint) []*datapoint.Datapoint

FilterDatapoints returns points that have a non empty metric name

type FlagCheck

type FlagCheck interface {
	HasFlag(ctx context.Context) bool
}

FlagCheck checks a context to see if a debug flag is set

type ItemFlagger

type ItemFlagger struct {
	CtxFlagCheck        FlagCheck
	Logger              log.Logger
	EventMetaName       string
	MetricDimensionName string
	// contains filtered or unexported fields
}

ItemFlagger will flag events and datapoints according to which dimensions are set or if the connection context has a flag set.

func (*ItemFlagger) AddDatapoints

func (f *ItemFlagger) AddDatapoints(ctx context.Context, points []*datapoint.Datapoint, next Sink) error

AddDatapoints adds a signal to each datapoint if the signal is inside the context

func (*ItemFlagger) AddEvents

func (f *ItemFlagger) AddEvents(ctx context.Context, events []*event.Event, next Sink) error

AddEvents adds a signal to each event if the signal is inside the context

func (*ItemFlagger) Datapoints

func (f *ItemFlagger) Datapoints() []*datapoint.Datapoint

Datapoints returns debug stat information about the flagger

func (*ItemFlagger) GetDimensions

func (f *ItemFlagger) GetDimensions() map[string]string

GetDimensions returns which dimensions are flagged

func (*ItemFlagger) HasDatapointFlag

func (f *ItemFlagger) HasDatapointFlag(dp *datapoint.Datapoint) bool

HasDatapointFlag return true if the datapoint is connected to this item

func (*ItemFlagger) HasEventFlag

func (f *ItemFlagger) HasEventFlag(ev *event.Event) bool

HasEventFlag return true if the event is connected to this item

func (*ItemFlagger) ServeHTTP

func (f *ItemFlagger) ServeHTTP(rw http.ResponseWriter, req *http.Request)

ServeHTTP supports GET to see the current dimensions and POST to change the current dimensions. POST expects (and GET returns) a JSON encoded map[string]string

func (*ItemFlagger) SetDatapointFlag

func (f *ItemFlagger) SetDatapointFlag(dp *datapoint.Datapoint)

SetDatapointFlag flags the datapoint as connected to this flagger

func (*ItemFlagger) SetDatapointFlags

func (f *ItemFlagger) SetDatapointFlags(ctx context.Context, points []*datapoint.Datapoint)

SetDatapointFlags sets the log flag for every datapoint if the signal is inside the context

func (*ItemFlagger) SetDimensions

func (f *ItemFlagger) SetDimensions(dims map[string]string)

SetDimensions controls which dimensions are flagged

func (*ItemFlagger) SetEventFlag

func (f *ItemFlagger) SetEventFlag(ev *event.Event)

SetEventFlag flags the event as connected to this flagger

func (*ItemFlagger) Var

func (f *ItemFlagger) Var() expvar.Var

Var returns the dimensions that are being filtered

type MiddlewareConstructor

type MiddlewareConstructor func(sendTo Sink) Sink

A MiddlewareConstructor is used by FromChain to chain together a bunch of sinks that forward to each other

func NextWrap

func NextWrap(wrapping NextSink) MiddlewareConstructor

NextWrap wraps a NextSink to make it usable by MiddlewareConstructor

type NextSink

type NextSink interface {
	AddDatapoints(ctx context.Context, points []*datapoint.Datapoint, next Sink) error
	AddEvents(ctx context.Context, events []*event.Event, next Sink) error
}

NextSink is a special case of a sink that forwards to another sink

type RateLimitErrorLogging

type RateLimitErrorLogging struct {
	LogThrottle time.Duration
	Logger      log.Logger
	// contains filtered or unexported fields
}

RateLimitErrorLogging does a log of errors forwarding points in a rate limited manner

func (*RateLimitErrorLogging) AddDatapoints

func (e *RateLimitErrorLogging) AddDatapoints(ctx context.Context, points []*datapoint.Datapoint, next Sink) error

AddDatapoints forwards points and will log any errors forwarding, but only one per LogThrottle duration

func (*RateLimitErrorLogging) AddEvents

func (e *RateLimitErrorLogging) AddEvents(ctx context.Context, points []*event.Event, next Sink) error

AddEvents forwards points and will log any errors forwarding, but only one per LogThrottle duration

type Sink

type Sink interface {
	DSink
	ESink
}

A Sink is an object that can accept datapoints or events and do something with them, like forward them to some endpoint

func FromChain

func FromChain(endSink Sink, sinks ...MiddlewareConstructor) Sink

FromChain creates an endpoint Sink that sends calls between multiple middlewares for things like counting points in between.

func IncludingDimensions

func IncludingDimensions(dims map[string]string, sink Sink) Sink

IncludingDimensions returns a sink that wraps another sink adding dims to each datapoint and event

type WithDimensions

type WithDimensions struct {
	Dimensions map[string]string
}

WithDimensions adds dimensions on top of the datapoints of a collector

func (*WithDimensions) AddDatapoints

func (w *WithDimensions) AddDatapoints(ctx context.Context, points []*datapoint.Datapoint, next Sink) error

AddDatapoints calls next() including the wrapped dimensions on each point

func (*WithDimensions) AddEvents

func (w *WithDimensions) AddEvents(ctx context.Context, events []*event.Event, next Sink) error

AddEvents calls next() including the wrapped dimensions on each point

Jump to

Keyboard shortcuts

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