fix ping
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
8b1e334b21
commit
8369576f3c
45
conn.go
45
conn.go
@ -241,8 +241,15 @@ func (w *wrapperConn) Exec(query string, args []driver.Value) (driver.Result, er
|
||||
ctx = context.Background()
|
||||
}
|
||||
// nolint:staticcheck
|
||||
execer, ok := w.conn.(driver.Execer)
|
||||
if !ok {
|
||||
if w.opts.LoggerEnabled {
|
||||
w.opts.Logger.Fields(w.opts.LoggerObserver(ctx, "Exec", labelUnknown, 0, ErrUnsupported)...).Log(ctx, w.opts.LoggerLevel)
|
||||
}
|
||||
return nil, ErrUnsupported
|
||||
}
|
||||
|
||||
labels := []string{labelMethod, "Exec", labelQuery, labelUnknown}
|
||||
if execer, ok := w.conn.(driver.Execer); ok {
|
||||
ts := time.Now()
|
||||
res, err := execer.Exec(query, args)
|
||||
td := time.Since(ts)
|
||||
@ -259,11 +266,6 @@ func (w *wrapperConn) Exec(query string, args []driver.Value) (driver.Result, er
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
if w.opts.LoggerEnabled {
|
||||
w.opts.Logger.Fields(w.opts.LoggerObserver(ctx, "Exec", labelUnknown, 0, ErrUnsupported)...).Log(ctx, w.opts.LoggerLevel)
|
||||
}
|
||||
return nil, ErrUnsupported
|
||||
}
|
||||
|
||||
// Exec implements driver.StmtExecContext ExecContext
|
||||
func (w *wrapperConn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error) {
|
||||
@ -337,7 +339,14 @@ func (w *wrapperConn) ExecContext(ctx context.Context, query string, args []driv
|
||||
|
||||
// Ping implements driver.Pinger Ping
|
||||
func (w *wrapperConn) Ping(ctx context.Context) error {
|
||||
if conn, ok := w.conn.(driver.Pinger); ok {
|
||||
conn, ok := w.conn.(driver.Pinger)
|
||||
if !ok {
|
||||
if w.opts.LoggerEnabled {
|
||||
w.opts.Logger.Fields(w.opts.LoggerObserver(ctx, "Ping", labelUnknown, 0, ErrUnsupported)...).Log(ctx, w.opts.LoggerLevel)
|
||||
}
|
||||
return ErrUnsupported
|
||||
}
|
||||
|
||||
var nctx context.Context
|
||||
var span tracer.Span
|
||||
if w.ctx != nil {
|
||||
@ -364,11 +373,8 @@ func (w *wrapperConn) Ping(ctx context.Context) error {
|
||||
}
|
||||
w.opts.Meter.Summary(meterRequestLatencyMicroseconds, labels...).Update(te)
|
||||
w.opts.Meter.Histogram(meterRequestDurationSeconds, labels...).Update(te)
|
||||
}
|
||||
if w.opts.LoggerEnabled {
|
||||
w.opts.Logger.Fields(w.opts.LoggerObserver(ctx, "Ping", labelUnknown, 0, ErrUnsupported)...).Log(ctx, w.opts.LoggerLevel)
|
||||
}
|
||||
return ErrUnsupported
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Query implements driver.Queryer Query
|
||||
@ -379,8 +385,16 @@ func (w *wrapperConn) Query(query string, args []driver.Value) (driver.Rows, err
|
||||
} else {
|
||||
ctx = context.Background()
|
||||
}
|
||||
|
||||
//nolint:staticcheck
|
||||
if conn, ok := w.conn.(driver.Queryer); ok {
|
||||
conn, ok := w.conn.(driver.Queryer)
|
||||
if !ok {
|
||||
if w.opts.LoggerEnabled {
|
||||
w.opts.Logger.Fields(w.opts.LoggerObserver(ctx, "Query", labelUnknown, 0, ErrUnsupported)...).Log(ctx, w.opts.LoggerLevel)
|
||||
}
|
||||
return nil, ErrUnsupported
|
||||
}
|
||||
|
||||
labels := []string{labelMethod, "Query", labelQuery, labelUnknown}
|
||||
ts := time.Now()
|
||||
rows, err := conn.Query(query, args)
|
||||
@ -398,11 +412,6 @@ func (w *wrapperConn) Query(query string, args []driver.Value) (driver.Rows, err
|
||||
}
|
||||
return rows, err
|
||||
}
|
||||
if w.opts.LoggerEnabled {
|
||||
w.opts.Logger.Fields(w.opts.LoggerObserver(ctx, "Query", labelUnknown, 0, ErrUnsupported)...).Log(ctx, w.opts.LoggerLevel)
|
||||
}
|
||||
return nil, ErrUnsupported
|
||||
}
|
||||
|
||||
// QueryContext implements Driver.QueryerContext QueryContext
|
||||
func (w *wrapperConn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user