useranalytics

package
v0.0.0-...-7fd4f02 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2018 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const KeyStrategyAnnotation = "annotation"
View Source
const KeyStrategyName = "name"
View Source
const KeyStrategyUID = "uid"
View Source
const MetricsEndpoint = "/metrics"
View Source
const OnlineManagedID = "openshift.io/online-managed-id"

Variables

View Source
var EventsHandledMetric = prometheus.NewDesc(
	"analytics_events_handled",
	"Number of events processed by analytics controller queue.",
	[]string{},
	prometheus.Labels{},
)
View Source
var QueueSizeMetric = prometheus.NewDesc(
	"analytics_queue_size_events",
	"Number of events pending in analytics controller queue.",
	[]string{},
	prometheus.Labels{},
)
View Source
var WoopraLatencyMetric = prometheus.NewDesc(
	"analytics_woopra_latency_seconds",
	"Latency to the Woopra API endpoint in seconds, 0 representing no connection.",
	[]string{},
	prometheus.Labels{},
)

Functions

func HealthHandler

func HealthHandler(w http.ResponseWriter, r *http.Request)

HealthHandler handles returning a simple 200 response on an http request

func WatchFuncList

func WatchFuncList(kubeClient kclientset.Interface, osClient osclient.Interface) map[string]*watchListItem

watchFuncList returns all the objects and watch functions we're using for analytics.

Types

type AnalyticsController

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

AnalyticsController is a controller that Watches & Forwards analytics data to various endpoints. Only new analytics are forwarded. There is no replay.

func NewAnalyticsController

func NewAnalyticsController(config *AnalyticsControllerConfig) (*AnalyticsController, error)

NewAnalyticsController creates a new ThirdPartyAnalyticsController

func (*AnalyticsController) AddEvent

func (c *AnalyticsController) AddEvent(ev *analyticsEvent) error

AddEvent is the primary way of adding analytic events to the processing queue. Re-adding the same event will cause duplicates. Sending events is not retried. All destinations are queued as separate work items. The namespace owner is automatically assigned as the event owner. Events w/ timestamps earlier than the start of this controller are not processed.

func (*AnalyticsController) Run

func (c *AnalyticsController) Run(stopCh <-chan struct{}, workers int)

Run starts all the watches within this controller and starts workers to process events

type AnalyticsControllerConfig

type AnalyticsControllerConfig struct {
	Destinations            map[string]Destination
	KubeClient              kclientset.Interface
	OSClient                osclient.Interface
	MaximumQueueLength      int
	MetricsPollingFrequency int
	ClusterName             string
	UserKeyStrategy         string
	UserKeyAnnotation       string
	Typer                   runtime.ObjectTyper
}

type Destination

type Destination interface {
	Send(ev *analyticsEvent) error
}

A "Destination" is a thing that can send data to an endpoint. In the "Store and Forward" implementation, this object sends data to endpoints and includes any transformation required. Current implementations are bespoke and specific to the destination endpoint.

type Element

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

type EventsCollector

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

func NewEventsCollector

func NewEventsCollector(controller *AnalyticsController) *EventsCollector

func (*EventsCollector) Collect

func (c *EventsCollector) Collect(ch chan<- prometheus.Metric)

func (*EventsCollector) Describe

func (c *EventsCollector) Describe(ch chan<- *prometheus.Desc)

type MetricsConfig

type MetricsConfig struct {
	BindAddr       string `json:"bindAddr" yaml:"bindAddr"`
	CollectRuntime bool   `json:"collectRuntime" yaml:"collectRuntime"`
	CollectWoopra  bool   `json:"collectWoopra" yaml:"collectWoopra"`
	CollectQueue   bool   `json:"collectQueue" yaml:"collectQueue"`
}

type MetricsServer

type MetricsServer struct {
	Config       MetricsConfig
	WoopraClient *WoopraDestination
	Controller   *AnalyticsController
}

func (*MetricsServer) Serve

func (s *MetricsServer) Serve() error

type MockHttpEndpoint

type MockHttpEndpoint struct {
	Port            int
	RequestsHandled int
	LastRequestURI  string
	URLPrefix       string
	// maximum number of milliseconds to handle a request.
	// 0 for no latency
	MaxLatency int
	// percent chance of returning HTTP error, 0 - 100
	FlakeRate int
	DupeCheck bool
	// contains the unique hash of an event and the number of times it is posted to the endpoint
	Analytics map[string]int
}

func (*MockHttpEndpoint) Run

func (m *MockHttpEndpoint) Run(stopCh <-chan struct{})

type SimpleHttpClient

type SimpleHttpClient interface {
	Get(endpoint string) (resp *http.Response, err error)
	Post(endpoint string, bodyType string, body io.Reader) (resp *http.Response, err error)
}

SimpleHttpClient is a tiny HTTP interface that allows easy mock testing

func NewSimpleHttpClient

func NewSimpleHttpClient() SimpleHttpClient

type SizeCollector

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

func NewSizeCollector

func NewSizeCollector(controller *AnalyticsController) *SizeCollector

func (*SizeCollector) Collect

func (c *SizeCollector) Collect(ch chan<- prometheus.Metric)

func (*SizeCollector) Describe

func (c *SizeCollector) Describe(ch chan<- *prometheus.Desc)

type Stack

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

func NewStack

func NewStack(max int) *Stack

func (*Stack) AsList

func (s *Stack) AsList() []interface{}

func (*Stack) Len

func (s *Stack) Len() int

Return the stack's length

func (*Stack) Max

func (s *Stack) Max() int

Return the stack's max

func (*Stack) Peek

func (s *Stack) Peek() (value interface{}, exists bool)

Peek returns a top without removing it from list

func (*Stack) Pop

func (s *Stack) Pop() (value interface{})

Remove the top element from the stack and return it's value If the stack is empty, return nil

func (*Stack) PopLast

func (s *Stack) PopLast() (value interface{})

func (*Stack) Push

func (s *Stack) Push(value interface{})

Push a new element onto the stack

type WoopraCollector

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

func NewWoopraCollector

func NewWoopraCollector(client *WoopraDestination) *WoopraCollector

func (*WoopraCollector) Collect

func (c *WoopraCollector) Collect(ch chan<- prometheus.Metric)

func (*WoopraCollector) Describe

func (c *WoopraCollector) Describe(ch chan<- *prometheus.Desc)

type WoopraDestination

type WoopraDestination struct {
	Method   string
	Endpoint string
	Domain   string
	Client   SimpleHttpClient
}

func (*WoopraDestination) Send

func (d *WoopraDestination) Send(ev *analyticsEvent) error

Jump to

Keyboard shortcuts

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