[GODRIVER-515] Add Context to CommandMonitor Events Created: 31/Jul/18  Updated: 28/Oct/23  Resolved: 06/Sep/18

Status: Closed
Project: Go Driver
Component/s: Monitoring
Affects Version/s: None
Fix Version/s: 0.0.13

Type: Improvement Priority: Minor - P4
Reporter: Caleb Doxsey Assignee: Kristofer Brandow (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

I'm working on adding Datadog APM tracing support to this library. The CommandMonitor looked like the easiest way to hook into the library. Would it be possible to add the relevant context to the CommandMonitor:

type CommandMonitor struct {
    Started func(*CommandStartedEvent)
    Succeeded func(*CommandSucceededEvent)
    Failed func(*CommandFailedEvent)
}

type CommandStartedEvent struct {
    Command *bson.Document
    DatabaseName string
    CommandName string
    RequestID int64
    ConnectionID string
}

The event would become:

type CommandStartedEvent struct {
    Context context.Context
    Command *bson.Document
    DatabaseName string
    CommandName string
    RequestID int64
    ConnectionID string
}

Passing the context through would help us to tie trace spans together.

I believe this change is relatively minor, and I could work on a PR to implement it.



 Comments   
Comment by Rathi Gnanasekaran [ 04/Sep/18 ]

 

 

Comment by Caleb Doxsey [ 08/Aug/18 ]

I updated the PR to pass the context as the first argument to each callback function.

Comment by Caleb Doxsey [ 08/Aug/18 ]

Hi Kris,

Sure I can change it. I'll update my PR.

Thanks,

  • Caleb
Comment by Kristofer Brandow (Inactive) [ 08/Aug/18 ]

Hi dd-caleb,

We've been thinking about how to incorporate APM information into the driver. I dislike placing a context on a struct, but how about passing it as a parameter to the functions? I think that would align better with how Go usually wants context.Context instances to be handled.

--Kris

Generated at Thu Feb 08 08:34:23 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.