update for latest micro logger changes
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
7ac873c62f
commit
3b6167f7da
42
conn.go
42
conn.go
@ -43,7 +43,7 @@ func (w *wrapperConn) Close() error {
|
||||
} else {
|
||||
ctx = context.Background()
|
||||
}
|
||||
|
||||
_ = ctx
|
||||
labels := []string{labelMethod, "Close"}
|
||||
ts := time.Now()
|
||||
err := w.conn.Close()
|
||||
@ -56,11 +56,11 @@ func (w *wrapperConn) Close() error {
|
||||
}
|
||||
w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te)
|
||||
w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te)
|
||||
|
||||
/*
|
||||
if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
|
||||
w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "Close", getCallerName(), td, err)...)
|
||||
}
|
||||
|
||||
*/
|
||||
return err
|
||||
}
|
||||
|
||||
@ -82,18 +82,21 @@ func (w *wrapperConn) Begin() (driver.Tx, error) {
|
||||
w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelFailure)...).Inc()
|
||||
w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te)
|
||||
w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te)
|
||||
/*
|
||||
if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
|
||||
w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "Begin", getCallerName(), td, err)...)
|
||||
}
|
||||
*/
|
||||
return nil, err
|
||||
}
|
||||
w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelSuccess)...).Inc()
|
||||
w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te)
|
||||
w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te)
|
||||
/*
|
||||
if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
|
||||
w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "Begin", getCallerName(), td, err)...)
|
||||
}
|
||||
|
||||
*/
|
||||
return &wrapperTx{tx: tx, opts: w.opts, ctx: ctx}, nil
|
||||
}
|
||||
|
||||
@ -122,15 +125,19 @@ func (w *wrapperConn) BeginTx(ctx context.Context, opts driver.TxOptions) (drive
|
||||
w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te)
|
||||
w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te)
|
||||
span.SetStatus(tracer.SpanStatusError, err.Error())
|
||||
/*
|
||||
if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
|
||||
w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "BeginTx", getCallerName(), td, err)...)
|
||||
}
|
||||
*/
|
||||
return nil, err
|
||||
}
|
||||
w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelSuccess)...).Inc()
|
||||
/*
|
||||
if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
|
||||
w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "BeginTx", getCallerName(), td, err)...)
|
||||
}
|
||||
*/
|
||||
return &wrapperTx{tx: tx, opts: w.opts, ctx: ctx, span: span}, nil
|
||||
}
|
||||
|
||||
@ -142,7 +149,7 @@ func (w *wrapperConn) Prepare(query string) (driver.Stmt, error) {
|
||||
} else {
|
||||
ctx = context.Background()
|
||||
}
|
||||
|
||||
_ = ctx
|
||||
labels := []string{labelMethod, "Prepare", labelQuery, getCallerName()}
|
||||
ts := time.Now()
|
||||
stmt, err := w.conn.Prepare(query)
|
||||
@ -152,19 +159,21 @@ func (w *wrapperConn) Prepare(query string) (driver.Stmt, error) {
|
||||
w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelFailure)...).Inc()
|
||||
w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te)
|
||||
w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te)
|
||||
/*
|
||||
if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
|
||||
w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "Prepare", getCallerName(), td, err)...)
|
||||
}
|
||||
*/
|
||||
return nil, err
|
||||
}
|
||||
w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelSuccess)...).Inc()
|
||||
w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te)
|
||||
w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te)
|
||||
|
||||
/*
|
||||
if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
|
||||
w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "Prepare", getCallerName(), td, err)...)
|
||||
}
|
||||
|
||||
*/
|
||||
return wrapStmt(stmt, query, w.opts), nil
|
||||
}
|
||||
|
||||
@ -199,18 +208,21 @@ func (w *wrapperConn) PrepareContext(ctx context.Context, query string) (driver.
|
||||
w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te)
|
||||
w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te)
|
||||
span.SetStatus(tracer.SpanStatusError, err.Error())
|
||||
/*
|
||||
if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
|
||||
w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "PrepareContext", getCallerName(), td, err)...)
|
||||
}
|
||||
*/
|
||||
return nil, err
|
||||
}
|
||||
w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelSuccess)...).Inc()
|
||||
w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te)
|
||||
w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te)
|
||||
/*
|
||||
if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
|
||||
w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "PrepareContext", getCallerName(), td, err)...)
|
||||
}
|
||||
|
||||
*/
|
||||
return wrapStmt(stmt, query, w.opts), nil
|
||||
}
|
||||
|
||||
@ -222,6 +234,7 @@ func (w *wrapperConn) Exec(query string, args []driver.Value) (driver.Result, er
|
||||
} else {
|
||||
ctx = context.Background()
|
||||
}
|
||||
_ = ctx
|
||||
labels := []string{labelMethod, "Exec", labelQuery, getCallerName()}
|
||||
|
||||
// nolint:staticcheck
|
||||
@ -241,9 +254,11 @@ func (w *wrapperConn) Exec(query string, args []driver.Value) (driver.Result, er
|
||||
}
|
||||
w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te)
|
||||
w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te)
|
||||
/*
|
||||
if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
|
||||
w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "Exec", getCallerName(), td, err)...)
|
||||
}
|
||||
*/
|
||||
return res, err
|
||||
}
|
||||
|
||||
@ -288,10 +303,11 @@ func (w *wrapperConn) ExecContext(ctx context.Context, query string, args []driv
|
||||
w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelSuccess)...).Inc()
|
||||
w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te)
|
||||
w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te)
|
||||
/*
|
||||
if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
|
||||
w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "ExecContext", getCallerName(), td, err)...)
|
||||
}
|
||||
|
||||
*/
|
||||
return res, err
|
||||
}
|
||||
|
||||
@ -328,9 +344,11 @@ func (w *wrapperConn) Ping(ctx context.Context) error {
|
||||
if err != nil {
|
||||
w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelFailure)...).Inc()
|
||||
// span.SetStatus(tracer.SpanStatusError, err.Error())
|
||||
/*
|
||||
if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
|
||||
w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "Ping", getCallerName(), td, err)...)
|
||||
}
|
||||
*/
|
||||
return err
|
||||
} else {
|
||||
w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelSuccess)...).Inc()
|
||||
@ -349,6 +367,7 @@ func (w *wrapperConn) Query(query string, args []driver.Value) (driver.Rows, err
|
||||
} else {
|
||||
ctx = context.Background()
|
||||
}
|
||||
_ = ctx
|
||||
// nolint:staticcheck
|
||||
conn, ok := w.conn.(driver.Queryer)
|
||||
if !ok {
|
||||
@ -367,9 +386,11 @@ func (w *wrapperConn) Query(query string, args []driver.Value) (driver.Rows, err
|
||||
}
|
||||
w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te)
|
||||
w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te)
|
||||
/*
|
||||
if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
|
||||
w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "Query", getCallerName(), td, err)...)
|
||||
}
|
||||
*/
|
||||
return rows, err
|
||||
}
|
||||
|
||||
@ -411,10 +432,11 @@ func (w *wrapperConn) QueryContext(ctx context.Context, query string, args []dri
|
||||
}
|
||||
w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te)
|
||||
w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te)
|
||||
/*
|
||||
if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
|
||||
w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "QueryContext", getCallerName(), td, err)...)
|
||||
}
|
||||
|
||||
*/
|
||||
return rows, err
|
||||
}
|
||||
|
||||
|
@ -78,10 +78,12 @@ func (w *wrapperDriver) Open(name string) (driver.Conn, error) {
|
||||
ts := time.Now()
|
||||
c, err := w.driver.Open(name)
|
||||
td := time.Since(ts)
|
||||
|
||||
/*
|
||||
if w.opts.LoggerEnabled {
|
||||
w.opts.Logger.Log(w.ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(w.ctx, "Open", getCallerName(), td, err)...)
|
||||
}
|
||||
*/
|
||||
_ = td
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
14
go.mod
14
go.mod
@ -1,18 +1,18 @@
|
||||
module go.unistack.org/micro-wrapper-sql/v3
|
||||
|
||||
go 1.21
|
||||
go 1.22
|
||||
|
||||
toolchain go1.23.1
|
||||
toolchain go1.23.2
|
||||
|
||||
require (
|
||||
go.unistack.org/micro-wrapper-requestid/v3 v3.9.2
|
||||
go.unistack.org/micro/v3 v3.10.91
|
||||
go.unistack.org/micro/v3 v3.10.97
|
||||
)
|
||||
|
||||
require (
|
||||
go.unistack.org/micro-proto/v3 v3.4.1 // indirect
|
||||
golang.org/x/sys v0.25.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
|
||||
google.golang.org/grpc v1.67.0 // indirect
|
||||
google.golang.org/protobuf v1.34.2 // indirect
|
||||
golang.org/x/sys v0.26.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9 // indirect
|
||||
google.golang.org/grpc v1.67.1 // indirect
|
||||
google.golang.org/protobuf v1.35.1 // indirect
|
||||
)
|
||||
|
10
go.sum
10
go.sum
@ -9,21 +9,31 @@ go.unistack.org/micro/v3 v3.10.57 h1:VxG7Cs7kBOgxgQlP+K8TvTxIgh2pmqAwmAaKdTAQNtQ
|
||||
go.unistack.org/micro/v3 v3.10.57/go.mod h1:erMgt3Bl7vQQ0e9UpQyR5NlLiZ9pKeEJ9+1tfYFaqUg=
|
||||
go.unistack.org/micro/v3 v3.10.91 h1:vuJY4tXwpqimwIkEJ3TozMYNVQQs+C5QMlQWPgSY/YM=
|
||||
go.unistack.org/micro/v3 v3.10.91/go.mod h1:erMgt3Bl7vQQ0e9UpQyR5NlLiZ9pKeEJ9+1tfYFaqUg=
|
||||
go.unistack.org/micro/v3 v3.10.97 h1:8l7fv+i06/PjPrBBhRC/ZQkWGIOuHPg3jJN0vktYE78=
|
||||
go.unistack.org/micro/v3 v3.10.97/go.mod h1:YzMldzHN9Ei+zy5t/Psu7RUWDZwUfrNYiStSQtTz90g=
|
||||
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
|
||||
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
|
||||
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
|
||||
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
|
||||
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda h1:LI5DOvAxUPMv/50agcLLoo+AdWc1irS9Rzz4vPuD1V4=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 h1:pPJltXNxVzT4pK9yD8vR9X75DaWYYmLGMsEvBfFQZzQ=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9 h1:QCqS/PdaHTSWGvupk2F/ehwHtGc0/GYkT+3GAcR1CCc=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI=
|
||||
google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM=
|
||||
google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA=
|
||||
google.golang.org/grpc v1.67.0 h1:IdH9y6PF5MPSdAntIcpjQ+tXO41pcQsfZV2RxtQgVcw=
|
||||
google.golang.org/grpc v1.67.0/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
|
||||
google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E=
|
||||
google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
|
||||
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
|
||||
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
|
||||
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
|
||||
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
|
||||
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||
|
@ -88,7 +88,7 @@ func NewOptions(opts ...Option) Options {
|
||||
),
|
||||
)
|
||||
|
||||
options.Logger = options.Logger.Clone(logger.WithCallerSkipCount(1))
|
||||
options.Logger = options.Logger.Clone(logger.WithAddCallerSkipCount(1))
|
||||
|
||||
return options
|
||||
}
|
||||
|
34
stmt.go
34
stmt.go
@ -33,6 +33,7 @@ func (w *wrapperStmt) Close() error {
|
||||
} else {
|
||||
ctx = context.Background()
|
||||
}
|
||||
_ = ctx
|
||||
labels := []string{labelMethod, "Close"}
|
||||
ts := time.Now()
|
||||
err := w.stmt.Close()
|
||||
@ -45,10 +46,11 @@ func (w *wrapperStmt) Close() error {
|
||||
}
|
||||
w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te)
|
||||
w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te)
|
||||
|
||||
/*
|
||||
if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
|
||||
w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "Close", getCallerName(), td, err)...)
|
||||
}
|
||||
*/
|
||||
return err
|
||||
}
|
||||
|
||||
@ -74,6 +76,7 @@ func (w *wrapperStmt) Exec(args []driver.Value) (driver.Result, error) {
|
||||
} else {
|
||||
ctx = context.Background()
|
||||
}
|
||||
_ = ctx
|
||||
labels := []string{labelMethod, "Exec"}
|
||||
ts := time.Now()
|
||||
res, err := w.stmt.Exec(args) // nolint:staticcheck
|
||||
@ -86,11 +89,11 @@ func (w *wrapperStmt) Exec(args []driver.Value) (driver.Result, error) {
|
||||
}
|
||||
w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te)
|
||||
w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te)
|
||||
|
||||
/*
|
||||
if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
|
||||
w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "Exec", getCallerName(), td, err)...)
|
||||
}
|
||||
|
||||
*/
|
||||
return res, err
|
||||
}
|
||||
|
||||
@ -102,6 +105,7 @@ func (w *wrapperStmt) Query(args []driver.Value) (driver.Rows, error) {
|
||||
} else {
|
||||
ctx = context.Background()
|
||||
}
|
||||
_ = ctx
|
||||
labels := []string{labelMethod, "Query"}
|
||||
ts := time.Now()
|
||||
rows, err := w.stmt.Query(args) // nolint:staticcheck
|
||||
@ -114,11 +118,11 @@ func (w *wrapperStmt) Query(args []driver.Value) (driver.Rows, error) {
|
||||
}
|
||||
w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te)
|
||||
w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te)
|
||||
|
||||
/*
|
||||
if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
|
||||
w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "Query", getCallerName(), td, err)...)
|
||||
}
|
||||
|
||||
*/
|
||||
return rows, err
|
||||
}
|
||||
|
||||
@ -166,10 +170,11 @@ func (w *wrapperStmt) ExecContext(ctx context.Context, args []driver.NamedValue)
|
||||
}
|
||||
w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te)
|
||||
w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te)
|
||||
|
||||
/*
|
||||
if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
|
||||
w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "ExecContext", name, td, err)...)
|
||||
}
|
||||
*/
|
||||
return res, err
|
||||
}
|
||||
|
||||
@ -177,10 +182,11 @@ func (w *wrapperStmt) ExecContext(ctx context.Context, args []driver.NamedValue)
|
||||
if err != nil {
|
||||
w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelFailure)...).Inc()
|
||||
span.SetStatus(tracer.SpanStatusError, err.Error())
|
||||
|
||||
/*
|
||||
if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
|
||||
w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "ExecContext", name, 0, err)...)
|
||||
}
|
||||
*/
|
||||
return nil, err
|
||||
}
|
||||
ts := time.Now()
|
||||
@ -196,11 +202,11 @@ func (w *wrapperStmt) ExecContext(ctx context.Context, args []driver.NamedValue)
|
||||
|
||||
w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te)
|
||||
w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te)
|
||||
|
||||
/*
|
||||
if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
|
||||
w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "ExecContext", name, td, err)...)
|
||||
}
|
||||
|
||||
*/
|
||||
return res, err
|
||||
}
|
||||
|
||||
@ -239,10 +245,11 @@ func (w *wrapperStmt) QueryContext(ctx context.Context, args []driver.NamedValue
|
||||
|
||||
w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te)
|
||||
w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te)
|
||||
|
||||
/*
|
||||
if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
|
||||
w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "QueryContext", name, td, err)...)
|
||||
}
|
||||
*/
|
||||
return rows, err
|
||||
}
|
||||
|
||||
@ -251,10 +258,11 @@ func (w *wrapperStmt) QueryContext(ctx context.Context, args []driver.NamedValue
|
||||
w.opts.Meter.Counter(meterRequestTotal, append(labels, labelStatus, labelFailure)...).Inc()
|
||||
|
||||
span.SetStatus(tracer.SpanStatusError, err.Error())
|
||||
|
||||
/*
|
||||
if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
|
||||
w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "QueryContext", name, 0, err)...)
|
||||
}
|
||||
*/
|
||||
return nil, err
|
||||
}
|
||||
ts := time.Now()
|
||||
@ -270,10 +278,10 @@ func (w *wrapperStmt) QueryContext(ctx context.Context, args []driver.NamedValue
|
||||
|
||||
w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te)
|
||||
w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te)
|
||||
|
||||
/*
|
||||
if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
|
||||
w.opts.Logger.Log(ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(ctx, "QueryContext", name, td, err)...)
|
||||
}
|
||||
|
||||
*/
|
||||
return rows, err
|
||||
}
|
||||
|
12
tx.go
12
tx.go
@ -23,18 +23,18 @@ func (w *wrapperTx) Commit() error {
|
||||
ts := time.Now()
|
||||
err := w.tx.Commit()
|
||||
td := time.Since(ts)
|
||||
|
||||
_ = td
|
||||
if w.span != nil {
|
||||
if err != nil {
|
||||
w.span.SetStatus(tracer.SpanStatusError, err.Error())
|
||||
}
|
||||
w.span.Finish()
|
||||
}
|
||||
|
||||
/*
|
||||
if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
|
||||
w.opts.Logger.Log(w.ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(w.ctx, "Commit", getCallerName(), td, err)...)
|
||||
}
|
||||
|
||||
*/
|
||||
w.ctx = nil
|
||||
|
||||
return err
|
||||
@ -45,18 +45,18 @@ func (w *wrapperTx) Rollback() error {
|
||||
ts := time.Now()
|
||||
err := w.tx.Rollback()
|
||||
td := time.Since(ts)
|
||||
|
||||
_ = td
|
||||
if w.span != nil {
|
||||
if err != nil {
|
||||
w.span.SetStatus(tracer.SpanStatusError, err.Error())
|
||||
}
|
||||
w.span.Finish()
|
||||
}
|
||||
|
||||
/*
|
||||
if w.opts.LoggerEnabled && w.opts.Logger.V(w.opts.LoggerLevel) {
|
||||
w.opts.Logger.Log(w.ctx, w.opts.LoggerLevel, w.opts.LoggerObserver(w.ctx, "Rollback", getCallerName(), td, err)...)
|
||||
}
|
||||
|
||||
*/
|
||||
w.ctx = nil
|
||||
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user