summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jstests/libs/config_files/set_profiling_filter.json5
-rw-r--r--jstests/noPassthrough/profile_options.js10
-rw-r--r--src/mongo/db/pipeline/expression.cpp7
-rw-r--r--src/mongo/db/pipeline/expression.h18
-rw-r--r--src/mongo/db/profile_filter_impl.cpp2
5 files changed, 33 insertions, 9 deletions
diff --git a/jstests/libs/config_files/set_profiling_filter.json b/jstests/libs/config_files/set_profiling_filter.json
new file mode 100644
index 00000000000..78af4c63313
--- /dev/null
+++ b/jstests/libs/config_files/set_profiling_filter.json
@@ -0,0 +1,5 @@
+{
+ "operationProfiling" : {
+ "filter" : "{$expr: {$lt: [{$rand: {}}, 0.01]}}"
+ }
+}
diff --git a/jstests/noPassthrough/profile_options.js b/jstests/noPassthrough/profile_options.js
index f2707fa4b14..719d15fab6c 100644
--- a/jstests/noPassthrough/profile_options.js
+++ b/jstests/noPassthrough/profile_options.js
@@ -25,4 +25,14 @@ expectedResult = {
};
testGetCmdLineOptsMongod({config: "jstests/libs/config_files/set_profiling.json"}, expectedResult);
+jsTest.log("Testing \"operationProfiling.filter\" config file option with agg expressions");
+expectedResult = {
+ "parsed": {
+ "config": "jstests/libs/config_files/set_profiling_filter.json",
+ "operationProfiling": {"filter": "{$expr: {$lt: [{$rand: {}}, 0.01]}}"}
+ }
+};
+testGetCmdLineOptsMongod({config: "jstests/libs/config_files/set_profiling_filter.json"},
+ expectedResult);
+
print(baseName + " succeeded.");
diff --git a/src/mongo/db/pipeline/expression.cpp b/src/mongo/db/pipeline/expression.cpp
index 518bc8638ca..8d72d2da5dc 100644
--- a/src/mongo/db/pipeline/expression.cpp
+++ b/src/mongo/db/pipeline/expression.cpp
@@ -6568,4 +6568,11 @@ void ExpressionRandom::_doAddDependencies(DepsTracker* deps) const {
Value ExpressionRandom::serialize(const bool explain) const {
return Value(DOC(getOpName() << Document()));
}
+
+MONGO_INITIALIZER(expressionParserMap)(InitializerContext*) {
+ // Nothing to do. This initializer exists to tie together all the individual initializers
+ // defined by REGISTER_EXPRESSION / REGISTER_EXPRESSION_WITH_MIN_VERSION.
+ return Status::OK();
+}
+
} // namespace mongo
diff --git a/src/mongo/db/pipeline/expression.h b/src/mongo/db/pipeline/expression.h
index 527cee413c2..3eb35d8d98e 100644
--- a/src/mongo/db/pipeline/expression.h
+++ b/src/mongo/db/pipeline/expression.h
@@ -68,10 +68,11 @@ class DocumentSource;
*
* An expression registered this way can be used in any featureCompatibilityVersion.
*/
-#define REGISTER_EXPRESSION(key, parser) \
- MONGO_INITIALIZER(addToExpressionParserMap_##key)(InitializerContext*) { \
- Expression::registerExpression("$" #key, (parser), boost::none); \
- return Status::OK(); \
+#define REGISTER_EXPRESSION(key, parser) \
+ MONGO_INITIALIZER_GENERAL(addToExpressionParserMap_##key, (), ("expressionParserMap")) \
+ (InitializerContext*) { \
+ Expression::registerExpression("$" #key, (parser), boost::none); \
+ return Status::OK(); \
}
/**
@@ -83,10 +84,11 @@ class DocumentSource;
* compatibility version >= X, you would add this line:
* REGISTER_EXPRESSION_WITH_MIN_VERSION(foo, ExpressionFoo::parse, X);
*/
-#define REGISTER_EXPRESSION_WITH_MIN_VERSION(key, parser, minVersion) \
- MONGO_INITIALIZER(addToExpressionParserMap_##key)(InitializerContext*) { \
- Expression::registerExpression("$" #key, (parser), (minVersion)); \
- return Status::OK(); \
+#define REGISTER_EXPRESSION_WITH_MIN_VERSION(key, parser, minVersion) \
+ MONGO_INITIALIZER_GENERAL(addToExpressionParserMap_##key, (), ("expressionParserMap")) \
+ (InitializerContext*) { \
+ Expression::registerExpression("$" #key, (parser), (minVersion)); \
+ return Status::OK(); \
}
class Expression : public RefCountable {
diff --git a/src/mongo/db/profile_filter_impl.cpp b/src/mongo/db/profile_filter_impl.cpp
index 92c44a916a4..7f76083bd22 100644
--- a/src/mongo/db/profile_filter_impl.cpp
+++ b/src/mongo/db/profile_filter_impl.cpp
@@ -76,7 +76,7 @@ bool ProfileFilterImpl::matches(OperationContext* opCtx,
// PathlessOperatorMap is required for parsing a MatchExpression.
MONGO_INITIALIZER_GENERAL(ProfileFilterDefault,
- ("PathlessOperatorMap", "MatchExpressionParser"),
+ ("PathlessOperatorMap", "MatchExpressionParser", "expressionParserMap"),
())
(InitializerContext*) {
try {