Source File
dbstats_go1.11.go
Belonging Package
contrib.go.opencensus.io/integrations/ocsql
package ocsql
import (
)
func ( *sql.DB, time.Duration) ( func()) {
var (
sync.Once
= context.Background()
= time.NewTicker()
= make(chan struct{})
)
go func() {
for {
select {
case <-.C:
:= .Stats()
stats.Record(,
MeasureOpenConnections.M(int64(.OpenConnections)),
MeasureIdleConnections.M(int64(.Idle)),
MeasureActiveConnections.M(int64(.InUse)),
MeasureWaitCount.M(.WaitCount),
MeasureWaitDuration.M(float64(.WaitDuration.Nanoseconds())/1e6),
MeasureIdleClosed.M(.MaxIdleClosed),
MeasureLifetimeClosed.M(.MaxLifetimeClosed),
)
case <-:
.Stop()
return
}
}
}()
return func() {
.Do(func() {
close()
})
}
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |