Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bab2833cf7 | |||
| 564efef60b | |||
| cb9d32bf1c | |||
| c363033abd |
9
.gitignore
vendored
9
.gitignore
vendored
@@ -4,6 +4,7 @@
|
|||||||
*.dll
|
*.dll
|
||||||
*.so
|
*.so
|
||||||
*.dylib
|
*.dylib
|
||||||
|
bin
|
||||||
|
|
||||||
# Test binary, built with `go test -c`
|
# Test binary, built with `go test -c`
|
||||||
*.test
|
*.test
|
||||||
@@ -13,3 +14,11 @@
|
|||||||
|
|
||||||
# Dependency directories (remove the comment below to include it)
|
# Dependency directories (remove the comment below to include it)
|
||||||
# vendor/
|
# vendor/
|
||||||
|
|
||||||
|
# Go workspace file
|
||||||
|
go.work
|
||||||
|
|
||||||
|
# General
|
||||||
|
.DS_Store
|
||||||
|
.idea
|
||||||
|
.vscode
|
||||||
12
options.go
12
options.go
@@ -2,6 +2,8 @@ package wrapper
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"database/sql"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -18,7 +20,7 @@ var (
|
|||||||
// DefaultLoggerObserver used to prepare labels for logger
|
// DefaultLoggerObserver used to prepare labels for logger
|
||||||
DefaultLoggerObserver = func(ctx context.Context, method string, query string, td time.Duration, err error) []interface{} {
|
DefaultLoggerObserver = func(ctx context.Context, method string, query string, td time.Duration, err error) []interface{} {
|
||||||
labels := []interface{}{"db.method", method, "took", fmt.Sprintf("%v", td)}
|
labels := []interface{}{"db.method", method, "took", fmt.Sprintf("%v", td)}
|
||||||
if err != nil {
|
if err != nil && !errors.Is(err, sql.ErrNoRows) {
|
||||||
labels = append(labels, "error", err.Error())
|
labels = append(labels, "error", err.Error())
|
||||||
}
|
}
|
||||||
if query != labelUnknown {
|
if query != labelUnknown {
|
||||||
@@ -44,13 +46,13 @@ var (
|
|||||||
meterRequestDurationSeconds = "request_duration_seconds"
|
meterRequestDurationSeconds = "request_duration_seconds"
|
||||||
|
|
||||||
labelUnknown = "unknown"
|
labelUnknown = "unknown"
|
||||||
labelQuery = "db.statement"
|
labelQuery = "db_statement"
|
||||||
labelMethod = "db.method"
|
labelMethod = "db_method"
|
||||||
labelStatus = "status"
|
labelStatus = "status"
|
||||||
labelSuccess = "success"
|
labelSuccess = "success"
|
||||||
labelFailure = "failure"
|
labelFailure = "failure"
|
||||||
labelHost = "db.host"
|
labelHost = "db_host"
|
||||||
labelDatabase = "db.name"
|
labelDatabase = "db_name"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Options struct holds wrapper options
|
// Options struct holds wrapper options
|
||||||
|
|||||||
Reference in New Issue
Block a user