Back to

Package reconciler

Latest Go to latest

The highest tagged major version is .

Published: Jan 21, 2020 | License: Apache-2.0 | Module:



const (
	// BrokerReadyCountN is the number of brokers that have become ready.
	BrokerReadyCountN = "broker_ready_count"
	// BrokerReadyLatencyN is the time it takes for a broker to become ready since the resource is created.
	BrokerReadyLatencyN = "broker_ready_latency"

	// TriggerReadyCountN is the number of triggers that have become ready.
	TriggerReadyCountN = "trigger_ready_count"
	// TriggerReadyLatencyN is the time it takes for a trigger to become ready since the resource is created.
	TriggerReadyLatencyN = "trigger_ready_latency"

	// ChannelReadyCountN is the number of channels that have become ready.
	ChannelReadyCountN = "channel_ready_count"
	// ChannelReadyLatencyN is the time it takes for a trigger to become ready since the resource is created.
	ChannelReadyLatencyN = "channel_ready_latency"

	// SubscriptionReadyCountN is the number of subscriptions that have become ready.
	SubscriptionReadyCountN = "subscription_ready_count"
	// SubscriptionReadyLatencyN is the time it takes for a subscription to become ready since the resource is created.
	SubscriptionReadyLatencyN = "subscription_ready_latency"

	// ContainerSourceReadyCountN is the number of container sources that have become ready.
	ContainerSourceReadyCountN = "container_source_ready_count"
	// ContainerSourceReadyLatencyN is the time it takes for a container source to become ready since the resource is created.
	ContainerSourceReadyLatencyN = "container_source_ready_latency"

	// CronJobSourceReadyCountN is the number of cron job sources that have become ready.
	CronJobSourceReadyCountN = "cron_job_source_ready_count"
	// CronJobSourceReadyLatencyN is the time it takes for a cron job source to become ready since the resource is created.
	CronJobSourceReadyLatencyN = "cron_job_source_ready_latency"

	// ApiServerSourceReadyCountN is the number of api server sources that have become ready.
	ApiServerSourceReadyCountN = "api_server_source_ready_count"
	// ApiServerSourceReadyLatencyN is the time it takes for an api server source to become ready since the resource is created.
	ApiServerSourceReadyLatencyN = "api_server_source_ready_latency"

	// InMemoryChannelReadyCountN is the number of in memory channels that have become ready.
	InMemoryChannelReadyCountN = "inmemorychannel_ready_count"
	// InMemoryChannelReadyLatencyN is the time it takes for an in memory channel to become ready since the resource is created.
	InMemoryChannelReadyLatencyN = "inmemorychannel_ready_latency"


var (
	KindToStatKeys = map[string]StatKey{

		"Broker": {
			ReadyLatencyKey: BrokerReadyLatencyN,
			ReadyCountKey:   BrokerReadyCountN,
		"Trigger": {
			ReadyLatencyKey: TriggerReadyLatencyN,
			ReadyCountKey:   TriggerReadyCountN,

		"Channel": {
			ReadyLatencyKey: ChannelReadyLatencyN,
			ReadyCountKey:   ChannelReadyCountN,
		"InMemoryChannel": {
			ReadyLatencyKey: InMemoryChannelReadyLatencyN,
			ReadyCountKey:   InMemoryChannelReadyCountN,
		"Subscription": {
			ReadyLatencyKey: SubscriptionReadyLatencyN,
			ReadyCountKey:   SubscriptionReadyCountN,

		"ContainerSource": {
			ReadyLatencyKey: ContainerSourceReadyLatencyN,
			ReadyCountKey:   ContainerSourceReadyCountN,
		"CronJobSource": {
			ReadyLatencyKey: CronJobSourceReadyLatencyN,
			ReadyCountKey:   CronJobSourceReadyCountN,
		"ApiServerSource": {
			ReadyLatencyKey: ApiServerSourceReadyLatencyN,
			ReadyCountKey:   ApiServerSourceReadyCountN,

	KindToMeasurements map[string]Measurements

func WithStatsReporter

func WithStatsReporter(ctx context.Context, sr StatsReporter) context.Context

WithStatsReporter attaches the given StatsReporter to the provided context in the returned context.

type Base

type Base struct {
	// KubeClientSet allows us to talk to the k8s for core APIs
	KubeClientSet kubernetes.Interface

	// EventingClientSet allows us to configure Eventing objects
	EventingClientSet clientset.Interface

	// LegacyClientSet allows us to configure Legacy Eventing objects
	LegacyClientSet legacyclientset.Interface

	// ApiExtensionsClientSet allows us to configure k8s API extension objects.
	ApiExtensionsClientSet apiextensionsclientset.Interface

	// DynamicClientSet allows us to configure pluggable Build objects
	DynamicClientSet dynamic.Interface

	// ConfigMapWatcher allows us to watch for ConfigMap changes.
	ConfigMapWatcher configmap.Watcher

	// Recorder is an event recorder for recording Event resources to the
	// Kubernetes API.
	Recorder record.EventRecorder

	// StatsReporter reports reconciler's metrics.
	StatsReporter StatsReporter

	// Sugared logger is easier to use but is not as performant as the
	// raw logger. In performance critical paths, call logger.Desugar()
	// and use the returned raw logger instead. In addition to the
	// performance benefits, raw logger also preserves type-safety at
	// the expense of slightly greater verbosity.
	Logger *zap.SugaredLogger

Base implements the core controller logic, given a Reconciler.

func NewBase

func NewBase(ctx context.Context, controllerAgentName string, cmw configmap.Watcher) *Base

NewBase instantiates a new instance of Base implementing the common & boilerplate code between our reconcilers.

type Measurement

type Measurement int

type Measurements

type Measurements struct {
	ReadyLatencyStat *stats.Int64Measure
	ReadyCountStat   *stats.Int64Measure

type StatKey

type StatKey struct {
	ReadyLatencyKey string
	ReadyCountKey   string

type StatsReporter

type StatsReporter interface {
	// ReportReady reports the time it took a resource to become Ready.
	ReportReady(kind, namespace, service string, d time.Duration) error

StatsReporter reports reconcilers' metrics.

func GetStatsReporter

func GetStatsReporter(ctx context.Context) StatsReporter

GetStatsReporter attempts to look up the StatsReporter on a given context. It may return nil if none is found.

func NewStatsReporter

func NewStatsReporter(reconciler string) (StatsReporter, error)

NewStatsReporter creates a reporter for reconcilers' metrics

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier