added monitor only for command 'find'

This commit is contained in:
Pavel 2024-08-04 10:20:29 +03:00
parent e4a4459c1e
commit 436a9f8484

@ -30,28 +30,16 @@ func Connect(ctx context.Context, deps *ConnectDeps) (*mongo.Database, error) {
cmdMonitor := &event.CommandMonitor{ cmdMonitor := &event.CommandMonitor{
Started: func(_ context.Context, evt *event.CommandStartedEvent) { Started: func(_ context.Context, evt *event.CommandStartedEvent) {
if evt.CommandName == "getMore" {
log.Println(evt.Command)
}
if evt.CommandName == "find" { if evt.CommandName == "find" {
log.Println(evt.Command) log.Println(evt.Command)
} }
}, },
Succeeded: func(_ context.Context, evt *event.CommandSucceededEvent) { Succeeded: func(_ context.Context, evt *event.CommandSucceededEvent) {
if evt.CommandName == "getMore" {
log.Println(evt.Reply)
}
if evt.CommandName == "find" { if evt.CommandName == "find" {
log.Println(evt.Reply) log.Println(evt.Reply)
} }
}, },
Failed: func(_ context.Context, evt *event.CommandFailedEvent) { Failed: func(_ context.Context, evt *event.CommandFailedEvent) {
if evt.CommandName == "getMore" {
log.Println(evt.Failure)
}
if evt.CommandName == "find" { if evt.CommandName == "find" {
log.Println(evt.Failure) log.Println(evt.Failure)
} }