ginmon

package
Version: v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2017 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CounterHandler

func CounterHandler(ca *CounterAspect) gin.HandlerFunc

CounterHandler is a Gin middleware function that increments a global counter on each request.

func NewDataStore added in v1.1.0

func NewDataStore() dataStore

func RequestTimeHandler

func RequestTimeHandler(rt *RequestTimeAspect) gin.HandlerFunc

RequestTimeHandler is a middleware function to use in Gin

Types

type CounterAspect

type CounterAspect struct {
	RequestsSum  int            `json:"request_sum_per_minute"`
	Requests     map[string]int `json:"requests_per_minute"`
	RequestCodes map[int]int    `json:"request_codes_per_minute"`
	// contains filtered or unexported fields
}

CounterAspect stores a counter

func NewCounterAspect

func NewCounterAspect() *CounterAspect

NewCounterAspect returns a new initialized CounterAspect object.

func (*CounterAspect) GetStats

func (ca *CounterAspect) GetStats() interface{}

GetStats to fulfill aspects.Aspect interface, it returns the data that will be served as JSON.

func (*CounterAspect) InRoot

func (ca *CounterAspect) InRoot() bool

InRoot to fulfill aspects.Aspect interface, it will return where to put the JSON object into the monitoring endpoint.

func (*CounterAspect) Name

func (ca *CounterAspect) Name() string

Name to fulfill aspects.Aspect interface, it will return the name of the JSON object that will be served.

func (*CounterAspect) StartTimer

func (ca *CounterAspect) StartTimer(d time.Duration)

StartTimer will call a forever loop in a goroutine to calculate metrics for measurements every d ticks. The parameter of this function should normally be 1 * time.Minute, if not it will expose unintuive JSON keys (requests_per_minute and request_sum_per_minute).

type DataChannel added in v1.1.0

type DataChannel struct {
	Name  string
	Value float64
}

DataChannel is the data you pass into the channel. Using Name we will put the Value into the right bucket.

type GenericChannelAspect added in v1.1.0

type GenericChannelAspect struct {
	Gcd map[string]GenericChannelData
	// contains filtered or unexported fields
}

GenericChannelAspect, exported fields are used to store json fields. All fields are measured in nanoseconds.

func NewGenericChannelAspect added in v1.1.0

func NewGenericChannelAspect(name string) *GenericChannelAspect

NewGenericChannelAspect returns a new initialized GenericChannelAspect object.

func (*GenericChannelAspect) GetStats added in v1.1.0

func (gc *GenericChannelAspect) GetStats() interface{}

GetStats to fulfill aspects.Aspect interface, it returns a copy of the calculated data set that will be served as JSON.

func (*GenericChannelAspect) InRoot added in v1.1.0

func (gc *GenericChannelAspect) InRoot() bool

InRoot to fulfill aspects.Aspect interface, it will return where to put the JSON object into the monitoring endpoint.

func (*GenericChannelAspect) Name added in v1.1.0

func (gc *GenericChannelAspect) Name() string

Name to fulfill aspects.Aspect interface, it will return the name of the JSON object that will be served.

func (*GenericChannelAspect) SetupGenericChannelAspect added in v1.1.0

func (gc *GenericChannelAspect) SetupGenericChannelAspect() chan DataChannel

SetupGenericChannelAspect returns an unbuffered channel for type DataChannel, such that you can send arbitrary key (string) value (float64) pairs to it.

func (*GenericChannelAspect) StartTimer added in v1.1.0

func (gc *GenericChannelAspect) StartTimer(d time.Duration)

StartTimer will call a forever loop in a goroutine to calculate metrics for measurements every d ticks.

type GenericChannelData added in v1.1.0

type GenericChannelData struct {
	Count     int       `json:"count"`
	Min       float64   `json:"min"`
	Max       float64   `json:"max"`
	Mean      float64   `json:"mean"`
	Stdev     float64   `json:"stdev"`
	P90       float64   `json:"p90"`
	P95       float64   `json:"p95"`
	P99       float64   `json:"p99"`
	Timestamp time.Time `json:"timestamp"`
}

GenericChannelData

type RequestTimeAspect

type RequestTimeAspect struct {
	Count     int       `json:"count"`
	Min       float64   `json:"min"`
	Max       float64   `json:"max"`
	Mean      float64   `json:"mean"`
	Stdev     float64   `json:"stdev"`
	P90       float64   `json:"p90"`
	P95       float64   `json:"p95"`
	P99       float64   `json:"p99"`
	Timestamp time.Time `json:"timestamp"`
	// contains filtered or unexported fields
}

RequestTimeAspect, exported fields are used to store json fields. All fields are measured in nanoseconds.

func NewRequestTimeAspect

func NewRequestTimeAspect() *RequestTimeAspect

NewRequestTimeAspect returns a new initialized RequestTimeAspect object.

func (*RequestTimeAspect) GetStats

func (rt *RequestTimeAspect) GetStats() interface{}

GetStats to fulfill aspects.Aspect interface, it returns the data that will be served as JSON.

func (*RequestTimeAspect) InRoot

func (rt *RequestTimeAspect) InRoot() bool

InRoot to fulfill aspects.Aspect interface, it will return where to put the JSON object into the monitoring endpoint.

func (*RequestTimeAspect) Name

func (rt *RequestTimeAspect) Name() string

Name to fulfill aspects.Aspect interface, it will return the name of the JSON object that will be served.

func (*RequestTimeAspect) StartTimer

func (rt *RequestTimeAspect) StartTimer(d time.Duration)

StartTimer will call a forever loop in a goroutine to calculate metrics for measurements every d ticks.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL