@@ -358,12 +358,13 @@ func canMonitor(cmd string) bool {
358
358
return true
359
359
}
360
360
361
- func (c * connection ) commandStartedEvent (wm wiremessage.WireMessage ) error {
361
+ func (c * connection ) commandStartedEvent (ctx context. Context , wm wiremessage.WireMessage ) error {
362
362
if c .cmdMonitor == nil || c .cmdMonitor .Started == nil {
363
363
return nil
364
364
}
365
365
366
366
startedEvent := & event.CommandStartedEvent {
367
+ Context : ctx ,
367
368
ConnectionID : c .id ,
368
369
}
369
370
@@ -426,6 +427,7 @@ func (c *connection) commandStartedEvent(wm wiremessage.WireMessage) error {
426
427
427
428
// unack writes must provide a CommandSucceededEvent with an { ok: 1 } reply
428
429
finishedEvent := event.CommandFinishedEvent {
430
+ Context : ctx ,
429
431
DurationNanos : 0 ,
430
432
CommandName : startedEvent .CommandName ,
431
433
RequestID : startedEvent .RequestID ,
@@ -489,7 +491,7 @@ func processReply(reply *bson.Document) (bool, string) {
489
491
return false , fullErrMsg
490
492
}
491
493
492
- func (c * connection ) commandFinishedEvent (wm wiremessage.WireMessage ) error {
494
+ func (c * connection ) commandFinishedEvent (ctx context. Context , wm wiremessage.WireMessage ) error {
493
495
if c .cmdMonitor == nil {
494
496
return nil
495
497
}
@@ -520,6 +522,7 @@ func (c *connection) commandFinishedEvent(wm wiremessage.WireMessage) error {
520
522
}
521
523
522
524
finishedEvent := event.CommandFinishedEvent {
525
+ Context : ctx ,
523
526
DurationNanos : cmdMetadata .TimeDifference (),
524
527
CommandName : cmdMetadata .Name ,
525
528
RequestID : requestID ,
@@ -639,7 +642,7 @@ func (c *connection) WriteWireMessage(ctx context.Context, wm wiremessage.WireMe
639
642
}
640
643
641
644
c .bumpIdleDeadline ()
642
- err = c .commandStartedEvent (wm )
645
+ err = c .commandStartedEvent (ctx , wm )
643
646
if err != nil {
644
647
return err
645
648
}
@@ -790,7 +793,7 @@ func (c *connection) ReadWireMessage(ctx context.Context) (wiremessage.WireMessa
790
793
}
791
794
792
795
c .bumpIdleDeadline ()
793
- err = c .commandFinishedEvent (wm )
796
+ err = c .commandFinishedEvent (ctx , wm )
794
797
if err != nil {
795
798
return nil , err // TODO: do we care if monitoring fails?
796
799
}
0 commit comments