Documentation ¶
Overview ¶
Package metrics define interfaces for metrics collection.
Index ¶
- Constants
- func AddCollector(name string, fun CollectorFunc)
- func Init(url *common.URL)
- func InitAppInfo(appName string, appVersion string)
- func Publish(event MetricsEvent)
- func SetRegistry(name string, v func(*common.URL) MetricRegistry)
- func Subscribe(typ string, ch chan MetricsEvent)
- func Unsubscribe(typ string)
- type AggregateCounterVec
- type ApplicationMetricLevel
- type BaseCollector
- type CollectorFunc
- type ConfigCenterLevel
- type CounterMetric
- type CounterVec
- type DefaultAggregateCounterVec
- type DefaultCounterVec
- type DefaultGaugeVec
- func (d *DefaultGaugeVec) Add(labels map[string]string, v float64)
- func (d *DefaultGaugeVec) Dec(labels map[string]string)
- func (d *DefaultGaugeVec) Inc(labels map[string]string)
- func (d *DefaultGaugeVec) Set(labels map[string]string, v float64)
- func (d *DefaultGaugeVec) Sub(labels map[string]string, v float64)
- type DefaultQpsMetricVec
- type DefaultQuantileMetricVec
- type DefaultRtVec
- type GaugeMetric
- type GaugeVec
- type MethodMetricLevel
- type MetricId
- type MetricKey
- type MetricLevel
- type MetricRegistry
- type MetricSample
- type MetricsEvent
- type ObservableMetric
- type QpsMetricVec
- type QuantileMetricVec
- type ReportMode
- type Reporter
- type ReporterConfig
- type RtOpts
- type RtVec
- type ServiceMetricLevel
- type Type
Constants ¶
const ( DefaultCompression = 100 DefaultBucketNum = 10 DefaultTimeWindowSeconds = 120 )
const ( ReportModePull = "pull" ReportModePush = "push" )
const DefMaxAge = 600000000000
Variables ¶
This section is empty.
Functions ¶
func AddCollector ¶ added in v3.1.1
func AddCollector(name string, fun CollectorFunc)
AddCollector add more indicators, like metadata, sla, config-center etc.
func InitAppInfo ¶ added in v3.1.1
cannot import rootConfig,may cause cycle import,so be it
func Publish ¶ added in v3.1.1
func Publish(event MetricsEvent)
Publish publishes an event to all subscribers of the same type.
func SetRegistry ¶ added in v3.1.1
func SetRegistry(name string, v func(*common.URL) MetricRegistry)
SetRegistry extend more MetricRegistry, default PrometheusRegistry
func Subscribe ¶ added in v3.1.1
func Subscribe(typ string, ch chan MetricsEvent)
Subscribe subscribes to events of the given type.
func Unsubscribe ¶ added in v3.1.1
func Unsubscribe(typ string)
Unsubscribe unsubscribes from events of the given type.
Types ¶
type AggregateCounterVec ¶ added in v3.1.1
AggregateCounterVec means a set of aggregate counter metrics with the same metricKey but different labels.
func NewAggregateCounterVec ¶ added in v3.1.1
func NewAggregateCounterVec(metricRegistry MetricRegistry, metricKey *MetricKey) AggregateCounterVec
type ApplicationMetricLevel ¶ added in v3.1.1
type ApplicationMetricLevel struct { ApplicationName string Version string GitCommitId string Ip string HostName string }
func GetApplicationLevel ¶ added in v3.1.1
func GetApplicationLevel() *ApplicationMetricLevel
func (*ApplicationMetricLevel) Tags ¶ added in v3.1.1
func (m *ApplicationMetricLevel) Tags() map[string]string
type BaseCollector ¶ added in v3.1.1
type BaseCollector struct {
R MetricRegistry
}
func (*BaseCollector) StateCount ¶ added in v3.1.1
func (c *BaseCollector) StateCount(total, succ, fail *MetricKey, level MetricLevel, succed bool)
type CollectorFunc ¶ added in v3.1.1
type CollectorFunc func(MetricRegistry, *common.URL)
CollectorFunc used to extend more indicators
type ConfigCenterLevel ¶ added in v3.1.1
type ConfigCenterLevel struct { ApplicationName string Ip string HostName string Key string Group string ConfigCenter string ChangeType string }
func NewConfigCenterLevel ¶ added in v3.1.1
func NewConfigCenterLevel(key string, group string, configCenter string, changeType string) *ConfigCenterLevel
func (ConfigCenterLevel) Tags ¶ added in v3.1.1
func (l ConfigCenterLevel) Tags() map[string]string
type CounterMetric ¶ added in v3.1.1
type CounterMetric interface { Inc() Add(float64) }
CounterMetric counter metric
type CounterVec ¶ added in v3.1.1
type CounterVec interface { Inc(labels map[string]string) Add(labels map[string]string, v float64) }
CounterVec means a set of counters with the same metricKey but different labels
func NewCounterVec ¶ added in v3.1.1
func NewCounterVec(metricRegistry MetricRegistry, metricKey *MetricKey) CounterVec
NewCounterVec create a CounterVec default implementation.
type DefaultAggregateCounterVec ¶ added in v3.1.1
type DefaultAggregateCounterVec struct {
// contains filtered or unexported fields
}
DefaultAggregateCounterVec is a default AggregateCounterVec implementation.
It is concurrent safe, and it uses the aggregate.TimeWindowCounter to store and calculate the aggregate counter metrics.
func (*DefaultAggregateCounterVec) Inc ¶ added in v3.1.1
func (d *DefaultAggregateCounterVec) Inc(labels map[string]string)
type DefaultCounterVec ¶ added in v3.1.1
type DefaultCounterVec struct {
// contains filtered or unexported fields
}
DefaultCounterVec is a default CounterVec implementation.
func (*DefaultCounterVec) Add ¶ added in v3.1.1
func (d *DefaultCounterVec) Add(labels map[string]string, v float64)
func (*DefaultCounterVec) Inc ¶ added in v3.1.1
func (d *DefaultCounterVec) Inc(labels map[string]string)
type DefaultGaugeVec ¶ added in v3.1.1
type DefaultGaugeVec struct {
// contains filtered or unexported fields
}
DefaultGaugeVec is a default GaugeVec implementation.
func (*DefaultGaugeVec) Add ¶ added in v3.1.1
func (d *DefaultGaugeVec) Add(labels map[string]string, v float64)
func (*DefaultGaugeVec) Dec ¶ added in v3.1.1
func (d *DefaultGaugeVec) Dec(labels map[string]string)
func (*DefaultGaugeVec) Inc ¶ added in v3.1.1
func (d *DefaultGaugeVec) Inc(labels map[string]string)
type DefaultQpsMetricVec ¶ added in v3.1.1
type DefaultQpsMetricVec struct {
// contains filtered or unexported fields
}
DefaultQpsMetricVec is a default QpsMetricVec implementation.
It is concurrent safe, and it uses the aggregate.TimeWindowCounter to store and calculate the qps metrics.
func (*DefaultQpsMetricVec) Record ¶ added in v3.1.1
func (d *DefaultQpsMetricVec) Record(labels map[string]string)
type DefaultQuantileMetricVec ¶ added in v3.1.1
type DefaultQuantileMetricVec struct {
// contains filtered or unexported fields
}
DefaultQuantileMetricVec is a default QuantileMetricVec implementation.
It is concurrent safe, and it uses the aggregate.TimeWindowQuantile to store and calculate the quantile metrics.
type DefaultRtVec ¶ added in v3.1.1
type DefaultRtVec struct {
// contains filtered or unexported fields
}
DefaultRtVec is a default RtVec implementation.
If rtOpts.Aggregate is true, it will use the aggregate.TimeWindowAggregator with local aggregation, else it will use the aggregate.Result without aggregation.
type GaugeMetric ¶ added in v3.1.1
GaugeMetric gauge metric
type GaugeVec ¶ added in v3.1.1
type GaugeVec interface { Set(labels map[string]string, v float64) Inc(labels map[string]string) Dec(labels map[string]string) Add(labels map[string]string, v float64) Sub(labels map[string]string, v float64) }
GaugeVec means a set of gauges with the same metricKey but different labels
func NewGaugeVec ¶ added in v3.1.1
func NewGaugeVec(metricRegistry MetricRegistry, metricKey *MetricKey) GaugeVec
NewGaugeVec create a GaugeVec default implementation.
type MethodMetricLevel ¶ added in v3.1.1
type MethodMetricLevel struct { *ServiceMetricLevel Method string Group string Version string }
func (MethodMetricLevel) Tags ¶ added in v3.1.1
func (m MethodMetricLevel) Tags() map[string]string
type MetricId ¶ added in v3.1.1
type MetricId struct { Name string Desc string Tags map[string]string // also named label Type Type // TODO check if this field is useful }
MetricId # HELP dubbo_metadata_store_provider_succeed_total Succeed Store Provider Metadata # TYPE dubbo_metadata_store_provider_succeed_total gauge dubbo_metadata_store_provider_succeed_total{application_name="provider",hostname="localhost",interface="org.example.DemoService",ip="10.252.156.213",} 1.0 other properties except value
func NewMetricId ¶ added in v3.1.1
func NewMetricId(key *MetricKey, level MetricLevel) *MetricId
func NewMetricIdByLabels ¶ added in v3.1.1
NewMetricIdByLabels create a MetricId by key and labels
type MetricKey ¶ added in v3.1.1
func NewMetricKey ¶ added in v3.1.1
type MetricLevel ¶ added in v3.1.1
type MetricRegistry ¶ added in v3.1.1
type MetricRegistry interface { Counter(*MetricId) CounterMetric // add or update a counter Gauge(*MetricId) GaugeMetric // add or update a gauge Histogram(*MetricId) ObservableMetric // add a metric num to a histogram Summary(*MetricId) ObservableMetric // add a metric num to a summary Rt(*MetricId, *RtOpts) ObservableMetric // add a metric num to a rt Export() // expose metric data, such as Prometheus http exporter }
MetricRegistry data container,data compute、expose、agg
type MetricSample ¶ added in v3.1.1
type MetricSample struct { *MetricId // contains filtered or unexported fields }
MetricSample a metric sample,This is the final data presentation, not an intermediate result(like summary,histogram they will export to a set of MetricSample)
type MetricsEvent ¶ added in v3.1.1
type MetricsEvent interface {
Type() string
}
MetricsEvent represents an event that can be published and subscribed to.
type ObservableMetric ¶ added in v3.1.1
type ObservableMetric interface {
Observe(float64)
}
histogram summary rt metric
type QpsMetricVec ¶ added in v3.1.1
QpsMetricVec means a set of qps metrics with the same metricKey but different labels.
func NewQpsMetricVec ¶ added in v3.1.1
func NewQpsMetricVec(metricRegistry MetricRegistry, metricKey *MetricKey) QpsMetricVec
type QuantileMetricVec ¶ added in v3.1.1
QuantileMetricVec means a set of quantile metrics with the same metricKey but different labels.
func NewQuantileMetricVec ¶ added in v3.1.1
func NewQuantileMetricVec(metricRegistry MetricRegistry, metricKeys []*MetricKey, quantiles []float64) QuantileMetricVec
type ReportMode ¶
type ReportMode string
type Reporter ¶
type Reporter interface { StartServer(config *ReporterConfig) ShutdownServer() }
Reporter is an interface used to represent the backend of metrics to be exported
type ReporterConfig ¶
type ReporterConfig struct { Enable bool Namespace string Mode ReportMode Port string Path string PushGatewayAddress string SummaryMaxAge int64 Protocol string // exporters, like prometheus }
func NewReporterConfig ¶
func NewReporterConfig() *ReporterConfig
type RtVec ¶ added in v3.1.1
RtVec means a set of rt metrics with the same metricKey but different labels
type ServiceMetricLevel ¶ added in v3.1.1
type ServiceMetricLevel struct { *ApplicationMetricLevel Interface string }
func NewServiceMetric ¶ added in v3.1.1
func NewServiceMetric(interfaceName string) *ServiceMetricLevel
func (ServiceMetricLevel) Tags ¶ added in v3.1.1
func (m ServiceMetricLevel) Tags() map[string]string