Documentation
¶
Index ¶
- Constants
- Variables
- func HealthHandler(w http.ResponseWriter, r *http.Request)
- func WatchFuncList(kubeClient kclientset.Interface, osClient osclient.Interface) map[string]*watchListItem
- type AnalyticsController
- type AnalyticsControllerConfig
- type Destination
- type Element
- type EventsCollector
- type MetricsConfig
- type MetricsServer
- type MockHttpEndpoint
- type SimpleHttpClient
- type SizeCollector
- type Stack
- type WoopraCollector
- type WoopraDestination
Constants ¶
const KeyStrategyAnnotation = "annotation"
const KeyStrategyName = "name"
const KeyStrategyUID = "uid"
const MetricsEndpoint = "/metrics"
const OnlineManagedID = "openshift.io/online-managed-id"
Variables ¶
var EventsHandledMetric = prometheus.NewDesc( "analytics_events_handled", "Number of events processed by analytics controller queue.", []string{}, prometheus.Labels{}, )
var QueueSizeMetric = prometheus.NewDesc( "analytics_queue_size_events", "Number of events pending in analytics controller queue.", []string{}, prometheus.Labels{}, )
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 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 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
}
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