Skip to content

Commit 69e25c5

Browse files
committed
adds stats section to README
1 parent 46b59c6 commit 69e25c5

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,33 @@ func GetConn(...) driver.Conn {
8484
}
8585
```
8686

87+
## metrics
88+
89+
Next to tracing, ocsql also supports OpenCensus stats. To record call stats,
90+
register the available views or create your own using the provided Measures.
91+
92+
```go
93+
// register default views
94+
ocsql.RegisterAllViews()
95+
96+
```
97+
98+
From Go 1.11 and up, ocsql also has the ability to record database connection
99+
pool details. Use the `RecordStats` function and provide a `*sql.DB` to record
100+
details on, as well as the required record interval.
101+
102+
```go
103+
// register default views
104+
ocsql.RegisterAllViews()
105+
106+
// Connect to a SQLite3 database using the ocsql driver wrapper
107+
db, err = sql.Open("ocsql-sqlite3", "resource.db")
108+
109+
// Record DB stats every 5 seconds
110+
ocsql.RecordStats(db, 5 * time.Second)
111+
112+
```
113+
87114
## jmoiron/sqlx
88115

89116
If using the `sqlx` library with named queries you will need to use the

0 commit comments

Comments
 (0)