Documentation ¶
Overview ¶
Author SunJun <i@sjis.me>
Author SunJun <i@sjis.me>
Index ¶
- Variables
- type AutumnMetric
- type CollectorPure
- func (cp *CollectorPure) GetAllMetrics() map[string]AutumnMetric
- func (cp *CollectorPure) GetMetric(id string) (AutumnMetric, bool)
- func (cp *CollectorPure) Handler() http.HandlerFunc
- func (cp *CollectorPure) ListenAndServe(addr string, h func(http.ResponseWriter, *http.Request)) error
- func (cp *CollectorPure) MetricsHandler() http.HandlerFunc
- func (cp *CollectorPure) NewLocalPureMetric(name string, labels ...string) *LocalPureMetric
- func (cp *CollectorPure) NewMetric(name string, metricType MetricType, labels ...string) prometheus.Collector
- func (cp *CollectorPure) Register(ams ...AutumnMetric)
- func (cp *CollectorPure) RegisterPrometheus(pmc ...prometheus.Collector)
- func (cp *CollectorPure) Unregister(ids ...string)
- func (cp *CollectorPure) Use(next http.Handler) http.Handler
- func (cp *CollectorPure) UseAfterHandlerHook(h ...HandlerFunc)
- func (cp *CollectorPure) UseBeforeHandlerHook(h ...HandlerFunc)
- type Context
- func (c *Context) Abort()
- func (c *Context) Get(key string) (value interface{}, exists bool)
- func (c *Context) GetBool(key string) (b bool)
- func (c *Context) GetDuration(key string) (d time.Duration)
- func (c *Context) GetFloat64(key string) (f64 float64)
- func (c *Context) GetInt(key string) (i int)
- func (c *Context) GetInt64(key string) (i64 int64)
- func (c *Context) GetString(key string) (s string)
- func (c *Context) GetStringMap(key string) (sm map[string]interface{})
- func (c *Context) GetStringMapString(key string) (sms map[string]string)
- func (c *Context) GetStringMapStringSlice(key string) (smss map[string][]string)
- func (c *Context) GetStringSlice(key string) (ss []string)
- func (c *Context) GetTime(key string) (t time.Time)
- func (c *Context) MustGet(key string) interface{}
- func (c *Context) Next()
- func (c *Context) Set(key string, value interface{})
- type HandlerFunc
- type HandlerType
- type LabelValue
- type LocalPureMetric
- func (arm *LocalPureMetric) Add(value float64, labelValues ...string) error
- func (arm *LocalPureMetric) GetLabelValues() []*LabelValue
- func (arm *LocalPureMetric) GetLabels() []string
- func (arm *LocalPureMetric) GetName() string
- func (arm *LocalPureMetric) GetValue(labelValues ...string) float64
- func (arm *LocalPureMetric) Incr(labelValues ...string) error
- func (arm *LocalPureMetric) Set(value float64, labelValues ...string) error
- type MetricCollection
- type MetricType
- type ResponseWriter
Constants ¶
This section is empty.
Variables ¶
var (
DefaultMetricPath = "/metrics"
)
Functions ¶
This section is empty.
Types ¶
type AutumnMetric ¶
type AutumnMetric interface { // Get the metrics object id GetName() string // Get the metrics indicator value GetValue(...string) float64 // Get the metrics parameter set GetLabels() []string // Get the corresponding values of different parameters of metrics GetLabelValues() []*LabelValue Set(float64, ...string) error Incr(...string) error Add(float64, ...string) error }
Metrics object interface, providing metrics metric data operations and obtaining metrics basic information
type CollectorPure ¶
type CollectorPure struct {
// contains filtered or unexported fields
}
func NewPureCollector ¶
func NewPureCollector(subsystem string, path ...string) *CollectorPure
func (*CollectorPure) GetAllMetrics ¶
func (cp *CollectorPure) GetAllMetrics() map[string]AutumnMetric
func (*CollectorPure) GetMetric ¶
func (cp *CollectorPure) GetMetric(id string) (AutumnMetric, bool)
func (*CollectorPure) Handler ¶
func (cp *CollectorPure) Handler() http.HandlerFunc
Complete metrics processor with default metrics in the prometheus library
func (*CollectorPure) ListenAndServe ¶
func (cp *CollectorPure) ListenAndServe(addr string, h func(http.ResponseWriter, *http.Request)) error
start with server
func (*CollectorPure) MetricsHandler ¶
func (cp *CollectorPure) MetricsHandler() http.HandlerFunc
Complete metrics processor with default metrics in the prometheus library
func (*CollectorPure) NewLocalPureMetric ¶
func (cp *CollectorPure) NewLocalPureMetric(name string, labels ...string) *LocalPureMetric
func (*CollectorPure) NewMetric ¶
func (cp *CollectorPure) NewMetric(name string, metricType MetricType, labels ...string) prometheus.Collector
NewMetric associates prometheus.Collector based on Metric.Type
func (*CollectorPure) Register ¶
func (cp *CollectorPure) Register(ams ...AutumnMetric)
func (*CollectorPure) RegisterPrometheus ¶
func (cp *CollectorPure) RegisterPrometheus(pmc ...prometheus.Collector)
func (*CollectorPure) Unregister ¶
func (cp *CollectorPure) Unregister(ids ...string)
func (*CollectorPure) Use ¶
func (cp *CollectorPure) Use(next http.Handler) http.Handler
Middleware handler
func (*CollectorPure) UseAfterHandlerHook ¶
func (cp *CollectorPure) UseAfterHandlerHook(h ...HandlerFunc)
func (*CollectorPure) UseBeforeHandlerHook ¶
func (cp *CollectorPure) UseBeforeHandlerHook(h ...HandlerFunc)
type Context ¶
type Context struct { Request *http.Request ResponseWriter *ResponseWriter Keys map[string]interface{} // contains filtered or unexported fields }
func (*Context) Get ¶
Get returns the value for the given key, ie: (value, true). If the value does not exists it returns (nil, false)
func (*Context) GetDuration ¶
GetDuration returns the value associated with the key as a duration.
func (*Context) GetFloat64 ¶
GetFloat64 returns the value associated with the key as a float64.
func (*Context) GetStringMap ¶
GetStringMap returns the value associated with the key as a map of interfaces.
func (*Context) GetStringMapString ¶
GetStringMapString returns the value associated with the key as a map of strings.
func (*Context) GetStringMapStringSlice ¶
GetStringMapStringSlice returns the value associated with the key as a map to a slice of strings.
func (*Context) GetStringSlice ¶
GetStringSlice returns the value associated with the key as a slice of strings.
type HandlerFunc ¶
type HandlerFunc func(*Context)
type HandlerType ¶
type HandlerType int
type LabelValue ¶
Metrics labels correspond to different combinations of value values
type LocalPureMetric ¶
type LocalPureMetric struct { Name string Type MetricType Labels []string LabelValues map[string]*LabelValue // contains filtered or unexported fields }
func (*LocalPureMetric) Add ¶
func (arm *LocalPureMetric) Add(value float64, labelValues ...string) error
func (*LocalPureMetric) GetLabelValues ¶
func (arm *LocalPureMetric) GetLabelValues() []*LabelValue
func (*LocalPureMetric) GetLabels ¶
func (arm *LocalPureMetric) GetLabels() []string
func (*LocalPureMetric) GetName ¶
func (arm *LocalPureMetric) GetName() string
func (*LocalPureMetric) GetValue ¶
func (arm *LocalPureMetric) GetValue(labelValues ...string) float64
func (*LocalPureMetric) Incr ¶
func (arm *LocalPureMetric) Incr(labelValues ...string) error
type MetricCollection ¶
type MetricCollection interface { // Register metrics Register(...AutumnMetric) // Register Prometheus native metrics collector RegisterPrometheus(...prometheus.Collector) // Unregister metrics Unregister(...string) // Http middleware, Used to collect http indicator information Use(http.Handler) http.Handler // Get a metrics object GetMetric(string) (AutumnMetric, bool) // Full metrics interface, return full metrics metrics MetricsHandler() http.HandlerFunc // Full metrics interface, return full metrics metrics Handler() http.HandlerFunc // Start the http service and provide the metrics interface ListenAndServe(string, func(http.ResponseWriter, *http.Request)) error // Add http middleware handler pre hook UseBeforeHandlerHook(...HandlerFunc) // Add http middleware handler after hook UseAfterHandlerHook(...HandlerFunc) }
Metrics collection interface for registering metrics objects, providing metrics interfaces and services
type MetricType ¶
type MetricType int
const ( CounterVec MetricType = iota Counter GaugeVec Gauge HistogramVec Histogram SummaryVec Summary )
type ResponseWriter ¶
type ResponseWriter struct { http.ResponseWriter // contains filtered or unexported fields }
func (*ResponseWriter) Size ¶
func (w *ResponseWriter) Size() int
func (*ResponseWriter) Status ¶
func (w *ResponseWriter) Status() int
func (*ResponseWriter) WriteHeader ¶
func (w *ResponseWriter) WriteHeader(statusCode int)