Documentation
¶
Index ¶
- Constants
- type BloomFilter
- type ExtraMetricHandleFn
- type Metric
- type MetricType
- type Monitor
- func (m *Monitor) AddMetric(metric *Metric) error
- func (m *Monitor) AddMetrics(metrics []*Metric) error
- func (m *Monitor) AddRawMetric(name string, ty MetricType, metric prometheus.Collector) error
- func (m *Monitor) GetMetric(name string) *Metric
- func (m *Monitor) GetRawMetric(name string) prometheus.Collector
- func (m *Monitor) Use(r *gin.Engine) error
- type Option
- func WithBloomFilter(bloomFilter BloomFilter) Option
- func WithCloseDefault(closeDefault bool) Option
- func WithExcludeFn(excludeFn RequestExcludeFn) Option
- func WithExtraMetricHandle(extraMetricHandle ExtraMetricHandleFn) Option
- func WithMetricPath(path string) Option
- func WithReqDuration(duration []float64) Option
- type RequestExcludeFn
Constants ¶
const ( KB uint64 = 1 << (10 * iota) MB GB TB PB EB )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BloomFilter ¶
BloomFilter is interface for bloom filter
func NewBloomFilter ¶
func NewBloomFilter() BloomFilter
NewBloomFilter creates a single bloomFilter.
type ExtraMetricHandleFn ¶
ExtraMetricHandleFn Handle extra metrics
type Metric ¶
type Metric struct {
Type MetricType
NameSpace string
Name string
Description string
Labels []string
ConstLabels map[string]string
Buckets []float64
Objectives map[float64]float64
// contains filtered or unexported fields
}
Metric defines a metric object. Users can use it to save metric data. Every metric should be globally unique by name.
func (*Metric) Add ¶
Add adds the given value to the Metric object. Only for Counter/Gauge type metric.
type MetricType ¶
type MetricType int
MetricType is the type of metric
const ( // None . None MetricType = iota // Counter is a cumulative metric. Counter // Gauge is a metric that represents a single numerical value that can arbitrarily go up and down. Gauge // Histogram is samples observations and counts them in configurable buckets. Histogram // Summary samples observations. Summary )
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
Monitor is an object that uses to set gin server monitor.
func NewMonitor ¶
NewMonitor create a new monitor.
func (*Monitor) AddMetrics ¶
AddMetrics add custom monitor metrics.
func (*Monitor) AddRawMetric ¶
func (m *Monitor) AddRawMetric(name string, ty MetricType, metric prometheus.Collector) error
AddRawMetric add raw monitor metric.
func (*Monitor) GetRawMetric ¶
func (m *Monitor) GetRawMetric(name string) prometheus.Collector
GetRawMetric used to get raw metric object by metric_name.
type Option ¶
type Option func(*options)
Option is the options for gmetrics
func WithBloomFilter ¶
func WithBloomFilter(bloomFilter BloomFilter) Option
WithBloomFilter is the bloom filter of the uv metrics, set nil close uv metrics.
func WithCloseDefault ¶
WithCloseDefault set the default metrics close
func WithExcludeFn ¶
func WithExcludeFn(excludeFn RequestExcludeFn) Option
WithExcludeFn is to exclude func of the metrics
func WithExtraMetricHandle ¶
func WithExtraMetricHandle(extraMetricHandle ExtraMetricHandleFn) Option
WithExtraMetricHandle is adding extra metric handle
func WithMetricPath ¶
WithMetricPath is the path of the metrics
func WithReqDuration ¶
WithReqDuration is the duration of the metrics
type RequestExcludeFn ¶
RequestExcludeFn Exclude requests that are not counted







