Skip to content

Commit 9a2f76b

Browse files
authored
DRIVERS-1141 Add serverConnectionId to command monitoring events (#1050)
Bump UTF schema version to 1.6 and add hasServerConnectionId field to expectedCommandEvents
1 parent 5fad277 commit 9a2f76b

14 files changed

+956
-1
lines changed

source/command-monitoring/command-monitoring.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,14 @@ See the `Load Balancer Specification <../load-balancers/load-balancers.rst#event
299299
*/
300300
connectionId: ConnectionId;
301301
302+
/**
303+
* Returns the server connection id for the command. The server connection id is distinct from
304+
* the connection id and is returned by the hello or legacy hello response as "connectionId"
305+
* from the server on 4.2+. Drivers MAY use a wider type to represent the server connection ID
306+
* value, but the server's behavior is to return an Int32.
307+
*/
308+
serverConnectionId: Optional<Int32>;
309+
302310
/**
303311
* Returns the service id for the command when the driver is in load balancer mode.
304312
* For drivers that wish to include this in their ConnectionId object, this field is
@@ -345,6 +353,14 @@ See the `Load Balancer Specification <../load-balancers/load-balancers.rst#event
345353
*/
346354
connectionId: ConnectionId;
347355
356+
/**
357+
* Returns the server connection id for the command. The server connection id is distinct from
358+
* the connection id and is returned by the hello or legacy hello response as "connectionId"
359+
* from the server on 4.2+. Drivers MAY use a wider type to represent the server connection ID
360+
* value, but the server's behavior is to return an Int32.
361+
*/
362+
serverConnectionId: Optional<Int32>;
363+
348364
/**
349365
* Returns the service id for the command when the driver is in load balancer mode.
350366
* For drivers that wish to include this in their ConnectionId object, this field is
@@ -392,6 +408,14 @@ See the `Load Balancer Specification <../load-balancers/load-balancers.rst#event
392408
*/
393409
connectionId: ConnectionId;
394410
411+
/**
412+
* Returns the server connection id for the command. The server connection id is distinct from
413+
* the connection id and is returned by the hello or legacy hello response as "connectionId"
414+
* from the server on 4.2+. Drivers MAY use a wider type to represent the server connection ID
415+
* value, but the server's behavior is to return an Int32.
416+
*/
417+
serverConnectionId: Optional<Int32>;
418+
395419
/**
396420
* Returns the service id for the command when the driver is in load balancer mode.
397421
* For drivers that wish to include this in their ConnectionId object, this field is
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
{
2+
"description": "pre-42-server-connection-id",
3+
"schemaVersion": "1.6",
4+
"runOnRequirements": [
5+
{
6+
"maxServerVersion": "4.0.99"
7+
}
8+
],
9+
"createEntities": [
10+
{
11+
"client": {
12+
"id": "client",
13+
"observeEvents": [
14+
"commandStartedEvent",
15+
"commandSucceededEvent",
16+
"commandFailedEvent"
17+
]
18+
}
19+
},
20+
{
21+
"database": {
22+
"id": "database",
23+
"client": "client",
24+
"databaseName": "server-connection-id-tests"
25+
}
26+
},
27+
{
28+
"collection": {
29+
"id": "collection",
30+
"database": "database",
31+
"collectionName": "coll"
32+
}
33+
}
34+
],
35+
"initialData": [
36+
{
37+
"databaseName": "server-connection-id-tests",
38+
"collectionName": "coll",
39+
"documents": []
40+
}
41+
],
42+
"tests": [
43+
{
44+
"description": "command events do not include server connection id",
45+
"operations": [
46+
{
47+
"name": "insertOne",
48+
"object": "collection",
49+
"arguments": {
50+
"document": {
51+
"x": 1
52+
}
53+
}
54+
},
55+
{
56+
"name": "find",
57+
"object": "collection",
58+
"arguments": {
59+
"filter": {
60+
"$or": true
61+
}
62+
},
63+
"expectError": {
64+
"isError": true
65+
}
66+
}
67+
],
68+
"expectEvents": [
69+
{
70+
"client": "client",
71+
"events": [
72+
{
73+
"commandStartedEvent": {
74+
"commandName": "insert",
75+
"hasServerConnectionId": false
76+
}
77+
},
78+
{
79+
"commandSucceededEvent": {
80+
"commandName": "insert",
81+
"hasServerConnectionId": false
82+
}
83+
},
84+
{
85+
"commandStartedEvent": {
86+
"commandName": "find",
87+
"hasServerConnectionId": false
88+
}
89+
},
90+
{
91+
"commandFailedEvent": {
92+
"commandName": "find",
93+
"hasServerConnectionId": false
94+
}
95+
}
96+
]
97+
}
98+
]
99+
}
100+
]
101+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
description: "pre-42-server-connection-id"
2+
3+
schemaVersion: "1.6"
4+
5+
runOnRequirements:
6+
- maxServerVersion: "4.0.99"
7+
8+
createEntities:
9+
- client:
10+
id: &client client
11+
observeEvents:
12+
- commandStartedEvent
13+
- commandSucceededEvent
14+
- commandFailedEvent
15+
- database:
16+
id: &database database
17+
client: *client
18+
databaseName: &databaseName server-connection-id-tests
19+
- collection:
20+
id: &collection collection
21+
database: *database
22+
collectionName: &collectionName coll
23+
24+
initialData:
25+
- databaseName: *databaseName
26+
collectionName: *collectionName
27+
documents: []
28+
29+
tests:
30+
- description: "command events do not include server connection id"
31+
operations:
32+
- name: insertOne
33+
object: *collection
34+
arguments:
35+
document: { x: 1 }
36+
- name: find
37+
object: *collection
38+
arguments:
39+
filter: { $or: true }
40+
expectError:
41+
isError: true
42+
expectEvents:
43+
- client: *client
44+
events:
45+
- commandStartedEvent:
46+
commandName: insert
47+
hasServerConnectionId: false
48+
- commandSucceededEvent:
49+
commandName: insert
50+
hasServerConnectionId: false
51+
- commandStartedEvent:
52+
commandName: find
53+
hasServerConnectionId: false
54+
- commandFailedEvent:
55+
commandName: find
56+
hasServerConnectionId: false
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
{
2+
"description": "server-connection-id",
3+
"schemaVersion": "1.6",
4+
"runOnRequirements": [
5+
{
6+
"minServerVersion": "4.2"
7+
}
8+
],
9+
"createEntities": [
10+
{
11+
"client": {
12+
"id": "client",
13+
"observeEvents": [
14+
"commandStartedEvent",
15+
"commandSucceededEvent",
16+
"commandFailedEvent"
17+
]
18+
}
19+
},
20+
{
21+
"database": {
22+
"id": "database",
23+
"client": "client",
24+
"databaseName": "server-connection-id-tests"
25+
}
26+
},
27+
{
28+
"collection": {
29+
"id": "collection",
30+
"database": "database",
31+
"collectionName": "coll"
32+
}
33+
}
34+
],
35+
"initialData": [
36+
{
37+
"databaseName": "server-connection-id-tests",
38+
"collectionName": "coll",
39+
"documents": []
40+
}
41+
],
42+
"tests": [
43+
{
44+
"description": "command events include server connection id",
45+
"operations": [
46+
{
47+
"name": "insertOne",
48+
"object": "collection",
49+
"arguments": {
50+
"document": {
51+
"x": 1
52+
}
53+
}
54+
},
55+
{
56+
"name": "find",
57+
"object": "collection",
58+
"arguments": {
59+
"filter": {
60+
"$or": true
61+
}
62+
},
63+
"expectError": {
64+
"isError": true
65+
}
66+
}
67+
],
68+
"expectEvents": [
69+
{
70+
"client": "client",
71+
"events": [
72+
{
73+
"commandStartedEvent": {
74+
"commandName": "insert",
75+
"hasServerConnectionId": true
76+
}
77+
},
78+
{
79+
"commandSucceededEvent": {
80+
"commandName": "insert",
81+
"hasServerConnectionId": true
82+
}
83+
},
84+
{
85+
"commandStartedEvent": {
86+
"commandName": "find",
87+
"hasServerConnectionId": true
88+
}
89+
},
90+
{
91+
"commandFailedEvent": {
92+
"commandName": "find",
93+
"hasServerConnectionId": true
94+
}
95+
}
96+
]
97+
}
98+
]
99+
}
100+
]
101+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
description: "server-connection-id"
2+
3+
schemaVersion: "1.6"
4+
5+
runOnRequirements:
6+
- minServerVersion: "4.2"
7+
8+
createEntities:
9+
- client:
10+
id: &client client
11+
observeEvents:
12+
- commandStartedEvent
13+
- commandSucceededEvent
14+
- commandFailedEvent
15+
- database:
16+
id: &database database
17+
client: *client
18+
databaseName: &databaseName server-connection-id-tests
19+
- collection:
20+
id: &collection collection
21+
database: *database
22+
collectionName: &collectionName coll
23+
24+
initialData:
25+
- databaseName: *databaseName
26+
collectionName: *collectionName
27+
documents: []
28+
29+
tests:
30+
- description: "command events include server connection id"
31+
operations:
32+
- name: insertOne
33+
object: *collection
34+
arguments:
35+
document: { x: 1 }
36+
- name: find
37+
object: *collection
38+
arguments:
39+
filter: { $or: true }
40+
expectError:
41+
isError: true
42+
expectEvents:
43+
- client: *client
44+
events:
45+
- commandStartedEvent:
46+
commandName: insert
47+
hasServerConnectionId: true
48+
- commandSucceededEvent:
49+
commandName: insert
50+
hasServerConnectionId: true
51+
- commandStartedEvent:
52+
commandName: find
53+
hasServerConnectionId: true
54+
- commandFailedEvent:
55+
commandName: find
56+
hasServerConnectionId: true

0 commit comments

Comments
 (0)