Skip to content

Commit b7f0ee8

Browse files
add to defaultLogTransform
1 parent 8a21e13 commit b7f0ee8

File tree

6 files changed

+50
-0
lines changed

6 files changed

+50
-0
lines changed

src/mongo_logger.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ export function defaultLogTransform(
604604
log = attachConnectionFields(log, logObject);
605605
log.message = 'Connection ready';
606606
log.driverConnectionId = logObject.connectionId;
607+
log.durationMS = logObject.durationMS;
607608
return log;
608609
case CONNECTION_CLOSED:
609610
log = attachConnectionFields(log, logObject);
@@ -649,6 +650,7 @@ export function defaultLogTransform(
649650
if (logObject.error) {
650651
log.error = logObject.error;
651652
}
653+
log.durationMS = logObject.durationMS;
652654
break;
653655
default:
654656
log.reason = `Unknown close reason: ${logObject.reason}`;
@@ -658,6 +660,7 @@ export function defaultLogTransform(
658660
log = attachConnectionFields(log, logObject);
659661
log.message = 'Connection checked out';
660662
log.driverConnectionId = logObject.connectionId;
663+
log.durationMS = logObject.durationMS;
661664
return log;
662665
case CONNECTION_CHECKED_IN:
663666
log = attachConnectionFields(log, logObject);

test/integration/connection-monitoring-and-pooling/unified-cmap-node-specs/connection-logging.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,13 @@
110110
"int",
111111
"long"
112112
]
113+
},
114+
"durationMS": {
115+
"$$type": [
116+
"double",
117+
"int",
118+
"long"
119+
]
113120
}
114121
}
115122
},

test/spec/connection-monitoring-and-pooling/logging/connection-logging.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@
140140
"int",
141141
"long"
142142
]
143+
},
144+
"durationMS": {
145+
"$$type": [
146+
"double",
147+
"int",
148+
"long"
149+
]
143150
}
144151
}
145152
},
@@ -162,6 +169,13 @@
162169
"int",
163170
"long"
164171
]
172+
},
173+
"durationMS": {
174+
"$$type": [
175+
"double",
176+
"int",
177+
"long"
178+
]
165179
}
166180
}
167181
},
@@ -222,6 +236,13 @@
222236
"int",
223237
"long"
224238
]
239+
},
240+
"durationMS": {
241+
"$$type": [
242+
"double",
243+
"int",
244+
"long"
245+
]
225246
}
226247
}
227248
},
@@ -484,6 +505,13 @@
484505
"reason": "An error occurred while trying to establish a new connection",
485506
"error": {
486507
"$$exists": true
508+
},
509+
"durationMS": {
510+
"$$type": [
511+
"double",
512+
"int",
513+
"long"
514+
]
487515
}
488516
}
489517
}

test/spec/connection-monitoring-and-pooling/logging/connection-logging.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ tests:
6666
driverConnectionId: { $$type: [int, long] }
6767
serverHost: { $$type: string }
6868
serverPort: { $$type: [int, long] }
69+
durationMS: { $$type: [double, int, long] }
6970

7071
- level: debug
7172
component: connection
@@ -74,6 +75,7 @@ tests:
7475
driverConnectionId: { $$type: [int, long] }
7576
serverHost: { $$type: string }
7677
serverPort: { $$type: [int, long] }
78+
durationMS: { $$type: [double, int, long] }
7779

7880
- level: debug
7981
component: connection
@@ -98,6 +100,7 @@ tests:
98100
driverConnectionId: { $$type: [int, long] }
99101
serverHost: { $$type: string }
100102
serverPort: { $$type: [int, long] }
103+
durationMS: { $$type: [double, int, long] }
101104

102105
- level: debug
103106
component: connection
@@ -218,3 +221,4 @@ tests:
218221
serverPort: { $$type: [int, long] }
219222
reason: "An error occurred while trying to establish a new connection"
220223
error: { $$exists: true }
224+
durationMS: { $$type: [double, int, long] }

test/spec/connection-monitoring-and-pooling/logging/connection-pool-options.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,13 @@
128128
"int",
129129
"long"
130130
]
131+
},
132+
"durationMS": {
133+
"$$type": [
134+
"double",
135+
"int",
136+
"long"
137+
]
131138
}
132139
}
133140
}

test/spec/connection-monitoring-and-pooling/logging/connection-pool-options.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ tests:
7171
driverConnectionId: { $$type: [int, long] }
7272
serverHost: { $$type: string }
7373
serverPort: { $$type: [int, long] }
74+
durationMS: { $$type: [double, int, long] }
7475

7576
# Drivers who have not done DRIVERS-1943 will need to skip this test.
7677
- description: "maxConnecting should be included in connection pool created message when specified"

0 commit comments

Comments
 (0)