diff options
Diffstat (limited to 'jstests/noPassthrough/log_format_slowms_samplerate_loglevel.js')
-rw-r--r-- | jstests/noPassthrough/log_format_slowms_samplerate_loglevel.js | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/jstests/noPassthrough/log_format_slowms_samplerate_loglevel.js b/jstests/noPassthrough/log_format_slowms_samplerate_loglevel.js index 9de22e79de5..5d1e2c4f98d 100644 --- a/jstests/noPassthrough/log_format_slowms_samplerate_loglevel.js +++ b/jstests/noPassthrough/log_format_slowms_samplerate_loglevel.js @@ -4,6 +4,8 @@ * protocols. * @tags: [requires_replication, requires_sharding] */ +load("jstests/libs/logv2_helpers.js"); + (function() { "use strict"; @@ -97,7 +99,7 @@ function runLoggingTests({db, readWriteMode, slowMs, logLevel, sampleRate}) { // which we do not expect them to appear. const ignoreFields = (isMongos - ? ["docsExamined", "keysExamined", "keysInserted", "keysDeleted", "planSummary", + ? ["docsExamined", "keysExamined", "keysInserted", "keysDeleted", "planSummary", "usedDisk", "hasSortStage"] : ["nShards"]); @@ -419,9 +421,16 @@ function findMatchingLogLine(logLines, fields, ignoreFields) { Object.keys(fields).filter((fieldName) => !ignoreFields.includes(fieldName)); return fieldNames.every((fieldName) => { const fieldValue = fields[fieldName]; - let regex = escapeRegex(fieldName) + ":? ?(" + - escapeRegex(checkLog.formatAsLogLine(fieldValue)) + "|" + - escapeRegex(checkLog.formatAsLogLine(fieldValue, true)) + ")"; + let regex; + if (isJsonLogNoConn()) { + regex = "\"" + escapeRegex(fieldName) + "\":? ?(" + + escapeRegex(checkLog.formatAsJsonLogLine(fieldValue)) + "|" + + escapeRegex(checkLog.formatAsJsonLogLine(fieldValue, true)) + ")"; + } else { + regex = escapeRegex(fieldName) + ":? ?(" + + escapeRegex(checkLog.formatAsLogLine(fieldValue)) + "|" + + escapeRegex(checkLog.formatAsLogLine(fieldValue, true)) + ")"; + } const match = line.match(regex); return match && match[0]; }); |