We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
类似qmgo的CommandMonitor,比如我想在qmgo里设置一个监听每次MongoDB成功和失败操作请求的监视器来打印日志,便于维护和定位问题,在qmgo里代码类似这样:
// 创建cmdMonitor,用于打印日志 startedCommands := sync.Map{} cmdMonitor := &event.CommandMonitor{ Started: func(_ context.Context, evt *event.CommandStartedEvent) { startedCommands.Store(evt.RequestID, evt.Command) }, Succeeded: func(_ context.Context, evt *event.CommandSucceededEvent) { var commands bson.Raw v, ok := startedCommands.Load(evt.RequestID) if ok { commands = v.(bson.Raw) } defer mLog.Sync() mLog.Infof("\n[MongoDB] [%.3fms] [%v] %v \n", float64(evt.DurationNanos)/1e6, commands, evt.Reply) }, Failed: func(_ context.Context, evt *event.CommandFailedEvent) { var commands bson.Raw v, ok := startedCommands.Load(evt.RequestID) if ok { commands = v.(bson.Raw) } defer mLog.Sync() mLog.Fatalf("\n[MongoDB] [%.3fms] [%v] \n %v \n", float64(evt.DurationNanos)/1e6, commands, evt.Failure) }, } ops.SetMonitor(cmdMonitor)
The text was updated successfully, but these errors were encountered:
目前还不支持,这段时间会优先支持事件监听器
Sorry, something went wrong.
@ycvk tag: v1.0.4已支持,用例请参考README.md
Successfully merging a pull request may close this issue.
类似qmgo的CommandMonitor,比如我想在qmgo里设置一个监听每次MongoDB成功和失败操作请求的监视器来打印日志,便于维护和定位问题,在qmgo里代码类似这样:
The text was updated successfully, but these errors were encountered: