@@ -16,8 +16,8 @@ import (
16
16
17
17
"github.com/aws/aws-lambda-go/events"
18
18
"github.com/aws/aws-lambda-go/lambda"
19
- "go.mongodb.org/mongo-driver/event"
20
19
"go.mongodb.org/mongo-driver/mongo"
20
+ "go.mongodb.org/mongo-driver/event"
21
21
"go.mongodb.org/mongo-driver/mongo/options"
22
22
)
23
23
@@ -41,12 +41,12 @@ type eventListener struct {
41
41
func (listener * eventListener ) commandMonitor () * event.CommandMonitor {
42
42
succeeded := func (_ context.Context , e * event.CommandSucceededEvent ) {
43
43
listener .commandCount ++
44
- listener .commandDuration += e .DurationNanos
44
+ listener .commandDuration += e .Duration . Nanoseconds ()
45
45
}
46
46
47
47
failed := func (_ context.Context , e * event.CommandFailedEvent ) {
48
48
listener .commandCount ++
49
- listener .commandDuration += e .DurationNanos
49
+ listener .commandDuration += e .Duration . Nanoseconds ()
50
50
}
51
51
52
52
return & event.CommandMonitor {
@@ -61,7 +61,7 @@ func (listener *eventListener) commandMonitor() *event.CommandMonitor {
61
61
func (listener * eventListener ) serverMonitor () * event.ServerMonitor {
62
62
succeeded := func (e * event.ServerHeartbeatSucceededEvent ) {
63
63
listener .heartbeatCount ++
64
- listener .heartbeatDuration += e .DurationNanos
64
+ listener .heartbeatDuration += e .Duration . Nanoseconds ()
65
65
66
66
if e .Awaited {
67
67
listener .heartbeatAwaitedCount ++
@@ -70,7 +70,7 @@ func (listener *eventListener) serverMonitor() *event.ServerMonitor {
70
70
71
71
failed := func (e * event.ServerHeartbeatFailedEvent ) {
72
72
listener .heartbeatCount ++
73
- listener .heartbeatDuration += e .DurationNanos
73
+ listener .heartbeatDuration += e .Duration . Nanoseconds ()
74
74
75
75
if e .Awaited {
76
76
listener .heartbeatAwaitedCount ++
@@ -130,16 +130,11 @@ func handler(ctx context.Context, request events.APIGatewayProxyRequest) (events
130
130
131
131
// Create a MongoClient that points to MONGODB_URI and listens to the
132
132
// ComandMonitor, ServerMonitor, and PoolMonitor events.
133
- client , err := mongo .NewClient (clientOptions )
133
+ client , err := mongo .Connect (clientOptions )
134
134
if err != nil {
135
135
return gateway500 (), fmt .Errorf ("failed to create client: %w" , err )
136
136
}
137
137
138
- // Attempt to connect to the client with a timeout.
139
- if err = client .Connect (ctx ); err != nil {
140
- return gateway500 (), fmt .Errorf ("failed to connect: %w" , err )
141
- }
142
-
143
138
defer client .Disconnect (ctx )
144
139
145
140
collection := client .Database ("faas" ).Collection ("lambda" )
0 commit comments