Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector for the sql.DBStats for Prometheus (via VictoriaMetrics client).
Example ¶
package main import ( "bytes" "context" "database/sql" "time" "github.com/VictoriaMetrics/metrics" "github.com/cristalhq/sqlmetrics" ) func main() { db, err := sql.Open("driver", "<some-connection-string>") if err != nil { panic(err) } ctx := context.Background() // or any other context you have every := 3 * time.Second sqlmetrics.NewCollector(ctx, db, every, "label1", "value1", "another", "etc") // done, db metrics are registered // you can see them here w := &bytes.Buffer{} metrics.WritePrometheus(w, true) }
Output:
Click to show internal directories.
Click to hide internal directories.