You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
529 B
24 lines
529 B
package hbase
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/tsuna/gohbase/hrpc"
|
|
|
|
"github.com/bilibili/kratos/pkg/log"
|
|
)
|
|
|
|
// NewSlowLogHook log slow operation.
|
|
func NewSlowLogHook(threshold time.Duration) HookFunc {
|
|
return func(ctx context.Context, call hrpc.Call, customName string) func(err error) {
|
|
start := time.Now()
|
|
return func(error) {
|
|
duration := time.Since(start)
|
|
if duration < threshold {
|
|
return
|
|
}
|
|
log.Warn("hbase slow log: %s %s %s time: %s", customName, call.Table(), call.Key(), duration)
|
|
}
|
|
}
|
|
}
|
|
|