chore: update goctl version to 1.6.0 (#3674)
This commit is contained in:
@@ -34,11 +34,9 @@ var (
|
|||||||
Labels: []string{"command"},
|
Labels: []string{"command"},
|
||||||
})
|
})
|
||||||
|
|
||||||
connLabels = []string{"key", "client_type"}
|
connLabels = []string{"key", "client_type"}
|
||||||
|
connCollector = newCollector()
|
||||||
connCollector = newCollector()
|
_ prometheus.Collector = (*collector)(nil)
|
||||||
|
|
||||||
_ prometheus.Collector = (*collector)(nil)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
|||||||
@@ -34,11 +34,9 @@ var (
|
|||||||
Labels: []string{"command"},
|
Labels: []string{"command"},
|
||||||
})
|
})
|
||||||
|
|
||||||
connLabels = []string{"db_name", "hash"}
|
connLabels = []string{"db_name", "hash"}
|
||||||
|
connCollector = newCollector()
|
||||||
connCollector = newCollector()
|
_ prometheus.Collector = (*collector)(nil)
|
||||||
|
|
||||||
_ prometheus.Collector = (*collector)(nil)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
@@ -143,15 +141,24 @@ func (c *collector) Collect(ch chan<- prometheus.Metric) {
|
|||||||
for _, client := range c.clients {
|
for _, client := range c.clients {
|
||||||
dbName, hash := client.dbName, client.hash
|
dbName, hash := client.dbName, client.hash
|
||||||
stats := client.poolStats()
|
stats := client.poolStats()
|
||||||
ch <- prometheus.MustNewConstMetric(c.maxOpenConnections, prometheus.GaugeValue, float64(stats.MaxOpenConnections), dbName, hash)
|
ch <- prometheus.MustNewConstMetric(c.maxOpenConnections, prometheus.GaugeValue,
|
||||||
ch <- prometheus.MustNewConstMetric(c.openConnections, prometheus.GaugeValue, float64(stats.OpenConnections), dbName, hash)
|
float64(stats.MaxOpenConnections), dbName, hash)
|
||||||
ch <- prometheus.MustNewConstMetric(c.inUseConnections, prometheus.GaugeValue, float64(stats.InUse), dbName, hash)
|
ch <- prometheus.MustNewConstMetric(c.openConnections, prometheus.GaugeValue,
|
||||||
ch <- prometheus.MustNewConstMetric(c.idleConnections, prometheus.GaugeValue, float64(stats.Idle), dbName, hash)
|
float64(stats.OpenConnections), dbName, hash)
|
||||||
ch <- prometheus.MustNewConstMetric(c.waitCount, prometheus.CounterValue, float64(stats.WaitCount), dbName, hash)
|
ch <- prometheus.MustNewConstMetric(c.inUseConnections, prometheus.GaugeValue,
|
||||||
ch <- prometheus.MustNewConstMetric(c.waitDuration, prometheus.CounterValue, stats.WaitDuration.Seconds(), dbName, hash)
|
float64(stats.InUse), dbName, hash)
|
||||||
ch <- prometheus.MustNewConstMetric(c.maxIdleClosed, prometheus.CounterValue, float64(stats.MaxIdleClosed), dbName, hash)
|
ch <- prometheus.MustNewConstMetric(c.idleConnections, prometheus.GaugeValue,
|
||||||
ch <- prometheus.MustNewConstMetric(c.maxLifetimeClosed, prometheus.CounterValue, float64(stats.MaxLifetimeClosed), dbName, hash)
|
float64(stats.Idle), dbName, hash)
|
||||||
ch <- prometheus.MustNewConstMetric(c.maxIdleTimeClosed, prometheus.CounterValue, float64(stats.MaxIdleTimeClosed), dbName, hash)
|
ch <- prometheus.MustNewConstMetric(c.waitCount, prometheus.CounterValue,
|
||||||
|
float64(stats.WaitCount), dbName, hash)
|
||||||
|
ch <- prometheus.MustNewConstMetric(c.waitDuration, prometheus.CounterValue,
|
||||||
|
stats.WaitDuration.Seconds(), dbName, hash)
|
||||||
|
ch <- prometheus.MustNewConstMetric(c.maxIdleClosed, prometheus.CounterValue,
|
||||||
|
float64(stats.MaxIdleClosed), dbName, hash)
|
||||||
|
ch <- prometheus.MustNewConstMetric(c.maxLifetimeClosed, prometheus.CounterValue,
|
||||||
|
float64(stats.MaxLifetimeClosed), dbName, hash)
|
||||||
|
ch <- prometheus.MustNewConstMetric(c.maxIdleTimeClosed, prometheus.CounterValue,
|
||||||
|
float64(stats.MaxIdleTimeClosed), dbName, hash)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,26 +31,24 @@ var (
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type MetricsURLRewriter func(u url.URL) string
|
||||||
MetricsURLRewriter func(u url.URL) string
|
|
||||||
)
|
|
||||||
|
|
||||||
func MetricsInterceptor(name string, pr MetricsURLRewriter) Interceptor {
|
func MetricsInterceptor(name string, pr MetricsURLRewriter) Interceptor {
|
||||||
return func(r *http.Request) (*http.Request, ResponseHandler) {
|
return func(r *http.Request) (*http.Request, ResponseHandler) {
|
||||||
startTime := timex.Now()
|
startTime := timex.Now()
|
||||||
return r, func(resp *http.Response, err error) {
|
return r, func(resp *http.Response, err error) {
|
||||||
u := cleanURL(*r.URL)
|
var code int
|
||||||
method := r.Method
|
var path string
|
||||||
var (
|
|
||||||
code int
|
|
||||||
path string
|
|
||||||
)
|
|
||||||
// error or resp is nil, set code=500
|
// error or resp is nil, set code=500
|
||||||
if err != nil || resp == nil {
|
if err != nil || resp == nil {
|
||||||
code = http.StatusInternalServerError
|
code = http.StatusInternalServerError
|
||||||
} else {
|
} else {
|
||||||
code = resp.StatusCode
|
code = resp.StatusCode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u := cleanURL(*r.URL)
|
||||||
|
method := r.Method
|
||||||
if pr != nil {
|
if pr != nil {
|
||||||
path = pr(u)
|
path = pr(u)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// BuildVersion is the version of goctl.
|
// BuildVersion is the version of goctl.
|
||||||
const BuildVersion = "1.5.6"
|
const BuildVersion = "1.6.0"
|
||||||
|
|
||||||
var tag = map[string]int{"pre-alpha": 0, "alpha": 1, "pre-bata": 2, "beta": 3, "released": 4, "": 5}
|
var tag = map[string]int{"pre-alpha": 0, "alpha": 1, "pre-bata": 2, "beta": 3, "released": 4, "": 5}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user