Compare commits

...

3 Commits

Author SHA1 Message Date
bab2833cf7 Merge pull request 'add err skip' (#81) from devstigneev/micro-wrapper-sql:issue_73 into master
Some checks failed
build / test (push) Successful in 1m54s
build / lint (push) Successful in 9m17s
codeql / analyze (go) (push) Failing after 13m49s
Reviewed-on: #81
2024-04-11 11:40:28 +03:00
564efef60b moved compare error to LoggerObserver
Some checks failed
automerge / automerge (pull_request) Has been skipped
dependabot-automerge / automerge (pull_request) Has been skipped
autoapprove / autoapprove (pull_request) Successful in 8s
codeql / analyze (go) (pull_request) Has been cancelled
prbuild / test (pull_request) Has been cancelled
prbuild / lint (pull_request) Has been cancelled
2024-04-11 11:38:09 +03:00
cb9d32bf1c add err skip
Some checks failed
automerge / automerge (pull_request) Has been skipped
dependabot-automerge / automerge (pull_request) Has been skipped
autoapprove / autoapprove (pull_request) Successful in 8s
codeql / analyze (go) (pull_request) Has been cancelled
prbuild / test (pull_request) Has been cancelled
prbuild / lint (pull_request) Has been cancelled
2024-04-07 22:12:39 +03:00
2 changed files with 12 additions and 1 deletions

9
.gitignore vendored
View File

@ -4,6 +4,7 @@
*.dll
*.so
*.dylib
bin
# Test binary, built with `go test -c`
*.test
@ -13,3 +14,11 @@
# Dependency directories (remove the comment below to include it)
# vendor/
# Go workspace file
go.work
# General
.DS_Store
.idea
.vscode

View File

@ -2,6 +2,8 @@ package wrapper
import (
"context"
"database/sql"
"errors"
"fmt"
"time"
@ -18,7 +20,7 @@ var (
// DefaultLoggerObserver used to prepare labels for logger
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)}
if err != nil {
if err != nil && !errors.Is(err, sql.ErrNoRows) {
labels = append(labels, "error", err.Error())
}
if query != labelUnknown {