Documentation ¶
Index ¶
Constants ¶
View Source
const ( // QuotaWindowShort specifies the length of time to wait before logging in order to estimate the first // GCR Quota of 50,000 HTTP requests per 10 min. // NOTE: These metrics are only a rough approximation of the actual GCR quotas. The specific 10min measurement // is ambiguous, as the start and end time are not specified in the docs. Therefore, it's impossible for our // requests counters to perfectly line up with the actual GCR quota. // Source: https://cloud.google.com/container-registry/quotas QuotaWindowShort time.Duration = time.Minute * 10 // QuotaWindowLong specifies the length of time to wait before logging in order to estimate the second // GCR Quota of 1,000,000 HTTP requests per day. QuotaWindowLong time.Duration = time.Hour * 24 // TimestampFormat specifies the syntax for logging time stamps of request counters. TimestampFormat string = "2006-01-02 15:04:05" )
Variables ¶
View Source
var ( // EnableCounting will only become true if the Init function is called. This allows // requests to be counted and logged. EnableCounting bool // NetMonitor holds all request counters for recording HTTP requests to GCR. NetMonitor *NetworkMonitor // Debug is defined to simplify testing of logrus.Debug calls. Debug func(args ...interface{}) = logrus.Debug // Warn is defined to simplify testing of logrus.Warn calls. Warn func(args ...interface{}) = logrus.Warn // Clock is defined to allow mocking of time functions. Clock tw.Time = tw.RealTime{} )
Functions ¶
Types ¶
type NetworkMonitor ¶
type NetworkMonitor struct {
RequestCounters RequestCounters
}
NetworkMonitor is the primary means of monitoring network traffic between CIP and GCR.
func (*NetworkMonitor) Log ¶
func (nm *NetworkMonitor) Log()
Log begins logging each request counter at their specified intervals.
type RequestCounter ¶
type RequestCounter struct { Mutex sync.Mutex // Lock to prevent race-conditions with concurrent processes. Requests uint64 // Number of HTTP requests since recording started. Since time.Time // When the current request counter began recording requests. Interval time.Duration // The duration of time between each log. Threshold uint64 // When to warn of a high request count during a logging cycle. Setting a }
RequestCounter records the number of HTTP requests to GCR.
func (*RequestCounter) Cycle ¶
func (rc *RequestCounter) Cycle()
Cycle sleeps for the request counter's interval and flushes itself.
func (*RequestCounter) Flush ¶
func (rc *RequestCounter) Flush()
Flush records the number of HTTP requests found and resets the request counter.
func (*RequestCounter) Increment ¶
func (rc *RequestCounter) Increment()
increment adds 1 to the request counter, signifying another call to GCR.
type RequestCounters ¶
type RequestCounters []*RequestCounter
RequestCounters holds multiple request counters.
Click to show internal directories.
Click to hide internal directories.