From b7d4d38da2f5faa2401611da7bf1b7e824e0f005 Mon Sep 17 00:00:00 2001 From: Preston Vasquez Date: Tue, 30 Jul 2024 13:13:06 -0600 Subject: [PATCH] Pass context to custom monitor --- mongo/integration/mtest/mongotest.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mongo/integration/mtest/mongotest.go b/mongo/integration/mtest/mongotest.go index f92b5c583f..25f30849b0 100644 --- a/mongo/integration/mtest/mongotest.go +++ b/mongo/integration/mtest/mongotest.go @@ -639,25 +639,25 @@ func (t *T) createTestClient() { // Setup command monitor var customMonitor = clientOpts.Monitor clientOpts.SetMonitor(&event.CommandMonitor{ - Started: func(_ context.Context, cse *event.CommandStartedEvent) { + Started: func(ctx context.Context, cse *event.CommandStartedEvent) { if customMonitor != nil && customMonitor.Started != nil { - customMonitor.Started(context.Background(), cse) + customMonitor.Started(ctx, cse) } t.monitorLock.Lock() defer t.monitorLock.Unlock() t.started = append(t.started, cse) }, - Succeeded: func(_ context.Context, cse *event.CommandSucceededEvent) { + Succeeded: func(ctx context.Context, cse *event.CommandSucceededEvent) { if customMonitor != nil && customMonitor.Succeeded != nil { - customMonitor.Succeeded(context.Background(), cse) + customMonitor.Succeeded(ctx, cse) } t.monitorLock.Lock() defer t.monitorLock.Unlock() t.succeeded = append(t.succeeded, cse) }, - Failed: func(_ context.Context, cfe *event.CommandFailedEvent) { + Failed: func(ctx context.Context, cfe *event.CommandFailedEvent) { if customMonitor != nil && customMonitor.Failed != nil { - customMonitor.Failed(context.Background(), cfe) + customMonitor.Failed(ctx, cfe) } t.monitorLock.Lock() defer t.monitorLock.Unlock()