Documentation
¶
Index ¶
- Constants
- Variables
- func EnableRunTimeMetrics()
- func GenerateRandomString(n int) string
- func GetSystemPrometheusRegistry() *prometheus.Registry
- func Initialize(connSettings string) *gorm.DB
- func RegisterCommonDatabaseCounters(serviceName string, db *gorm.DB, metricsExporter *MetricsExporter)
- func RegisterCommonRequestCounters(serviceName string, metricsExporter *MetricsExporter)
- func RegisterCommonRuntimeCounters(serviceName string, metricsExporter *MetricsExporter)
- func RegisterInfraMetrics(options Options, metricsExporter *MetricsExporter)
- func Setup() *gorm.DB
- func SetupTests() *gorm.DB
- type CounterAlias
- type CounterMetadata
- type CounterOpts
- type CounterType
- type GaugeOpts
- type HistogramOpts
- type MetricsExporter
- func (c *MetricsExporter) CounterAdd(name string, val float64, labels map[string]string) error
- func (c *MetricsExporter) CreateCounter(opts CounterOpts) error
- func (c *MetricsExporter) CreateGauge(opts GaugeOpts) error
- func (c *MetricsExporter) CreateGaugeFunc(opts GaugeOpts, f func() float64) error
- func (c *MetricsExporter) CreateHistogram(opts HistogramOpts) error
- func (c *MetricsExporter) CreateSummary(opts SummaryOpts) error
- func (c *MetricsExporter) GaugeSet(name string, val float64, labels map[string]string) error
- func (c *MetricsExporter) HistogramObserve(name string, val float64, labels map[string]string) error
- func (c *MetricsExporter) Monitor(next http.Handler) http.Handler
- func (c *MetricsExporter) ObtainGaugeFunc(name string) (*prometheus.GaugeFunc, error)
- func (c *MetricsExporter) SummaryObserve(name string, val float64, labels map[string]string) error
- type NewRegistry
- type Options
- type Registry
- type SummaryOpts
Constants ¶
const ( OpenConnections = "_open_connections" IdleConnections = "_idle_connections_open" ConnectionsInUse = "_connections_in_use" DatabaseConnectionWaitDuration = "_database_connection_wait_duration" DatabaseOperationLatency = "_database_operation_latency" )
const (
NumberOfGoRoutines = "_number_of_go_routines"
)
const (
RequestInfo = "_request_info"
)
const SUBSYSTEM string = "database"
Variables ¶
var Enum = &CounterType{
GaugeFunc: "GAUGE_FUNC",
CounterVec: "COUNTER_VEC",
GaugeVec: "GAUGE_VEC",
SummaryVec: "SUMMARY_VEC",
HistogramVec: "HISTOGRAM_VEC",
}
var REQUEST_SUBSYSTEM = "Request"
var RUNTIME_SUBSYSTEM = "Runtime"
Functions ¶
func GenerateRandomString ¶
func GetSystemPrometheusRegistry ¶
func GetSystemPrometheusRegistry() *prometheus.Registry
GetSystemPrometheusRegistry return prometheus registry which go chassis use
func Initialize ¶
Initialize creates a singular connection to the backend database instance
func RegisterCommonDatabaseCounters ¶
func RegisterCommonDatabaseCounters(serviceName string, db *gorm.DB, metricsExporter *MetricsExporter)
RegisterCommonDatabaseCounters generate common database specific counters of interest for a given service
func RegisterCommonRequestCounters ¶
func RegisterCommonRequestCounters(serviceName string, metricsExporter *MetricsExporter)
RegisterCommonRuntimeCounters generate common runtime specific counters of interest for a given service
func RegisterCommonRuntimeCounters ¶
func RegisterCommonRuntimeCounters(serviceName string, metricsExporter *MetricsExporter)
RegisterCommonRuntimeCounters generate common runtime specific counters of interest for a given service
func RegisterInfraMetrics ¶
func RegisterInfraMetrics(options Options, metricsExporter *MetricsExporter)
func SetupTests ¶
init initializes a connection to the database initially and performs package level cleanup handler initialization
Types ¶
type CounterAlias ¶
type CounterAlias string
type CounterMetadata ¶
type CounterOpts ¶
type CounterOpts struct {
Name string
Namespace string
Subsystem string
Help string
Labels []string
}
CounterOpts is options to create a counter options
type CounterType ¶
type CounterType struct {
GaugeFunc CounterAlias
CounterVec CounterAlias
GaugeVec CounterAlias
SummaryVec CounterAlias
HistogramVec CounterAlias
}
type HistogramOpts ¶
type HistogramOpts struct {
Name string
Namespace string
Subsystem string
Help string
Labels []string
Buckets []float64
}
HistogramOpts is options to create histogram collector
type MetricsExporter ¶
type MetricsExporter struct {
FlushInterval time.Duration
ServiceName string
// contains filtered or unexported fields
}
MetricsExporter is a prom exporter for go
func (*MetricsExporter) CounterAdd ¶
CounterAdd adds a new counter and sets its initial start value
func (*MetricsExporter) CreateCounter ¶
func (c *MetricsExporter) CreateCounter(opts CounterOpts) error
CreateCounter creates a metric of type counter
func (*MetricsExporter) CreateGauge ¶
func (c *MetricsExporter) CreateGauge(opts GaugeOpts) error
CreateGauge creates a metric of type gauge
func (*MetricsExporter) CreateGaugeFunc ¶
func (c *MetricsExporter) CreateGaugeFunc(opts GaugeOpts, f func() float64) error
func (*MetricsExporter) CreateHistogram ¶
func (c *MetricsExporter) CreateHistogram(opts HistogramOpts) error
CreateHistogram creates a metric of type histogram
func (*MetricsExporter) CreateSummary ¶
func (c *MetricsExporter) CreateSummary(opts SummaryOpts) error
CreateSummary creates a metric of type summary
func (*MetricsExporter) HistogramObserve ¶
func (c *MetricsExporter) HistogramObserve(name string, val float64, labels map[string]string) error
HistogramObserve creates a histogram counter and initializes it to some start value
func (*MetricsExporter) ObtainGaugeFunc ¶
func (c *MetricsExporter) ObtainGaugeFunc(name string) (*prometheus.GaugeFunc, error)
func (*MetricsExporter) SummaryObserve ¶
SummaryObserve creates a summary counter and initializes it to a start value
type Options ¶
type Options struct {
FlushInterval time.Duration
EnableGoRuntimeMetrics bool
DbConn *gorm.DB
ServiceName string
}
Options control config
type Registry ¶
type Registry interface {
// CreateGauge creates a gauge metric type
CreateGauge(opts GaugeOpts) error
// CreateCounter creates a counter metric type
CreateCounter(opts CounterOpts) error
// CreateSummary creates a summary metric type
CreateSummary(opts SummaryOpts) error
// CreateHistogram creates a histogram metric type
CreateHistogram(opts HistogramOpts) error
// CreateGaugeFunc create a gauge function metric type
CreateGaugeFunc(opts GaugeOpts, f func() float64) error
// GaugeSet sets a gauge counter type to a value specified by val
GaugeSet(name string, val float64, labels map[string]string) error
// CounterAdd sets a gauge counter to a value specified by val
CounterAdd(name string, val float64, labels map[string]string) error
// SummaryObserve specifies a counter of summary type
SummaryObserve(name string, val float64, Labels map[string]string) error
// HistogramObserve set/increments a histogram counter type
HistogramObserve(name string, val float64, labels map[string]string) error
// ObtainGaugeFunc attempts to obtain a gauge function by name
ObtainGaugeFunc(name string) (*prometheus.GaugeFunc, error)
// Monitor observes the request size and latency associated with a specific route and records it in a summary vector metric
Monitor(next http.Handler) http.Handler
}
Registry holds all of metrics collectors name is a unique ID for different type of metrics
func NewMetricsExporter ¶
NewMetricsExporter create a prometheus exporter