summaryrefslogtreecommitdiff
path: root/src/mongo/db/query
diff options
context:
space:
mode:
authorJennifer Peshansky <jennifer.peshansky@mongodb.com>2022-10-31 20:43:33 +0000
committerJennifer Peshansky <jennifer.peshansky@mongodb.com>2022-10-31 20:43:33 +0000
commit36d06124197a0f6a6b17aa0b45eaeb99f8db225b (patch)
tree77415256e81f8d78778c937306d1548639c09dff /src/mongo/db/query
parent4bd264e8772c3955382c2686d6eeefa8602d809b (diff)
downloadmongo-36d06124197a0f6a6b17aa0b45eaeb99f8db225b.tar.gz
SERVER-70854 Code review comments
Diffstat (limited to 'src/mongo/db/query')
-rw-r--r--src/mongo/db/query/SConscript1
-rw-r--r--src/mongo/db/query/query_knobs.idl31
-rw-r--r--src/mongo/db/query/telemetry_util.cpp52
-rw-r--r--src/mongo/db/query/telemetry_util.h50
4 files changed, 123 insertions, 11 deletions
diff --git a/src/mongo/db/query/SConscript b/src/mongo/db/query/SConscript
index 4db9f6b6920..10dbd5ba849 100644
--- a/src/mongo/db/query/SConscript
+++ b/src/mongo/db/query/SConscript
@@ -261,6 +261,7 @@ env.Library(
'query_feature_flags.idl',
'query_knobs.idl',
'sbe_plan_cache_on_parameter_change.cpp',
+ 'telemetry_util.cpp',
],
LIBDEPS_PRIVATE=[
'$BUILD_DIR/mongo/db/server_base',
diff --git a/src/mongo/db/query/query_knobs.idl b/src/mongo/db/query/query_knobs.idl
index 171accf9c06..899dddc41c9 100644
--- a/src/mongo/db/query/query_knobs.idl
+++ b/src/mongo/db/query/query_knobs.idl
@@ -32,6 +32,7 @@ global:
- "mongo/db/query/ce_mode_parameter.h"
- "mongo/db/query/plan_cache_size_parameter.h"
- "mongo/db/query/sbe_plan_cache_on_parameter_change.h"
+ - "mongo/db/query/telemetry_util.h"
- "mongo/platform/atomic_proxy.h"
- "mongo/platform/atomic_word.h"
@@ -946,22 +947,30 @@ server_parameters:
default:
expr: false
- internalQueryConfigureTelemetryCacheSize:
- description: "Knob to configure the maximum cache size for telemetry collection."
+ internalQueryConfigureTelemetrySamplingRate:
+ description: "The maximum number of queries per second that are sampled for query telemetry.
+ If the rate of queries goes above this number, then rate limiting will kick in, and any
+ further queries will not be sampled. The default is INT_MAX, effectively meaning that all
+ queries will be sampled. This can be set to 0 to turn telemetry off completely."
set_at: [ startup, runtime ]
- cpp_varname: "queryTelemetryCacheSize"
+ cpp_varname: "queryTelemetrySamplingRate"
cpp_vartype: AtomicWord<int>
- default: 5000
+ default: 2147483647
- internalQueryConfigureTelemetrySamplingPercentage:
- description: "Knob to configure the percentage of queries that are sampled for telemetry."
+ internalQueryConfigureTelemetryCacheSize:
+ description: "The maximum amount of memory that the system will allocate for the query telemetry
+ cache. This will accept values in either of the following formats:
+ 1. <number>% indicates a percentage of the physical memory available to the process. E.g.: 15%.
+ 2. <number>(MB|GB), indicates the amount of memory in MB or GB. E.g.: 1.5GB, 100MB.
+ The default value is 5%, which means 5% of the physical memory available to the process."
set_at: [ startup, runtime ]
- cpp_varname: "queryTelemetrySamplingPercentage"
- cpp_vartype: AtomicDouble
- default: 0.7
+ cpp_varname: "queryTelemetryCacheSize"
+ cpp_vartype: synchronized_value<std::string>
+ default: "5%"
+ on_update: telemetry_util::onTelemetryCacheSizeUpdate
validator:
- gt: 0.0
- lte: 1.0
+ callback: telemetry_util::validateTelemetryCacheSize
+
# Note for adding additional query knobs:
#
diff --git a/src/mongo/db/query/telemetry_util.cpp b/src/mongo/db/query/telemetry_util.cpp
new file mode 100644
index 00000000000..cb410cf63a2
--- /dev/null
+++ b/src/mongo/db/query/telemetry_util.cpp
@@ -0,0 +1,52 @@
+/**
+ * Copyright (C) 2020-present MongoDB, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the Server Side Public License, version 1,
+ * as published by MongoDB, Inc.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * Server Side Public License for more details.
+ *
+ * You should have received a copy of the Server Side Public License
+ * along with this program. If not, see
+ * <http://www.mongodb.com/licensing/server-side-public-license>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the Server Side Public License in all respects for
+ * all of the code used other than as permitted herein. If you modify file(s)
+ * with this exception, you may extend this exception to your version of the
+ * file(s), but you are not obligated to do so. If you do not wish to do so,
+ * delete this exception statement from your version. If you delete this
+ * exception statement from all source files in the program, then also delete
+ * it in the license file.
+ */
+
+#include "mongo/db/query/telemetry_util.h"
+#include "mongo/db/query/plan_cache_size_parameter.h"
+
+namespace mongo {
+namespace telemetry_util {
+
+Status onTelemetryCacheSizeUpdate(const std::string& str) {
+ auto newSize = plan_cache_util::PlanCacheSizeParameter::parse(str);
+ if (!newSize.isOK()) {
+ return newSize.getStatus();
+ }
+
+ // TODO update telemetry cache size wherever it is stored
+
+ return Status::OK();
+}
+
+Status validateTelemetryCacheSize(const std::string& str, const boost::optional<TenantId>&) {
+ return plan_cache_util::PlanCacheSizeParameter::parse(str).getStatus();
+}
+
+} // namespace telemetry_util
+} // namespace mongo
diff --git a/src/mongo/db/query/telemetry_util.h b/src/mongo/db/query/telemetry_util.h
new file mode 100644
index 00000000000..719174edd32
--- /dev/null
+++ b/src/mongo/db/query/telemetry_util.h
@@ -0,0 +1,50 @@
+/**
+ * Copyright (C) 2020-present MongoDB, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the Server Side Public License, version 1,
+ * as published by MongoDB, Inc.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * Server Side Public License for more details.
+ *
+ * You should have received a copy of the Server Side Public License
+ * along with this program. If not, see
+ * <http://www.mongodb.com/licensing/server-side-public-license>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the Server Side Public License in all respects for
+ * all of the code used other than as permitted herein. If you modify file(s)
+ * with this exception, you may extend this exception to your version of the
+ * file(s), but you are not obligated to do so. If you do not wish to do so,
+ * delete this exception statement from your version. If you delete this
+ * exception statement from all source files in the program, then also delete
+ * it in the license file.
+ */
+
+#pragma once
+
+#include "mongo/base/status.h"
+#include "mongo/db/service_context.h"
+
+namespace mongo {
+
+namespace telemetry_util {
+
+/**
+ * Callback called on a change of telemetryCacheSize parameter.
+ */
+Status onTelemetryCacheSizeUpdate(const std::string& str);
+
+/**
+ * Callback called on validation of telemetryCacheSize parameter.
+ */
+Status validateTelemetryCacheSize(const std::string& str, const boost::optional<TenantId>&);
+
+} // namespace telemetry_util
+} // namespace mongo