diff options
Diffstat (limited to 'src/mongo/s/query')
-rw-r--r-- | src/mongo/s/query/cluster_aggregate.cpp | 4 | ||||
-rw-r--r-- | src/mongo/s/query/cluster_aggregation_planner.cpp | 8 | ||||
-rw-r--r-- | src/mongo/s/query/cluster_client_cursor.h | 4 | ||||
-rw-r--r-- | src/mongo/s/query/cluster_client_cursor_impl.cpp | 27 | ||||
-rw-r--r-- | src/mongo/s/query/cluster_client_cursor_impl.h | 10 | ||||
-rw-r--r-- | src/mongo/s/query/cluster_client_cursor_mock.cpp | 2 | ||||
-rw-r--r-- | src/mongo/s/query/cluster_client_cursor_mock.h | 2 | ||||
-rw-r--r-- | src/mongo/s/query/cluster_cursor_manager.cpp | 18 | ||||
-rw-r--r-- | src/mongo/s/query/cluster_cursor_manager.h | 10 | ||||
-rw-r--r-- | src/mongo/s/query/cluster_find.cpp | 8 | ||||
-rw-r--r-- | src/mongo/s/query/store_possible_cursor.cpp | 4 |
11 files changed, 48 insertions, 49 deletions
diff --git a/src/mongo/s/query/cluster_aggregate.cpp b/src/mongo/s/query/cluster_aggregate.cpp index 9fd49e2e004..6c9351efe57 100644 --- a/src/mongo/s/query/cluster_aggregate.cpp +++ b/src/mongo/s/query/cluster_aggregate.cpp @@ -56,7 +56,7 @@ #include "mongo/db/query/explain_common.h" #include "mongo/db/query/find_common.h" #include "mongo/db/query/fle/server_rewrite.h" -#include "mongo/db/query/query_stats.h" +#include "mongo/db/query/telemetry.h" #include "mongo/db/timeseries/timeseries_gen.h" #include "mongo/db/timeseries/timeseries_options.h" #include "mongo/db/views/resolved_view.h" @@ -324,7 +324,7 @@ Status ClusterAggregate::runAggregate(OperationContext* opCtx, auto startsWithDocuments = liteParsedPipeline.startsWithDocuments(); if (!shouldDoFLERewrite) { - query_stats::registerAggRequest(request, opCtx); + telemetry::registerAggRequest(request, opCtx); } // If the routing table is not already taken by the higher level, fill it now. diff --git a/src/mongo/s/query/cluster_aggregation_planner.cpp b/src/mongo/s/query/cluster_aggregation_planner.cpp index 8f2c6fcdb19..5aa643c0a85 100644 --- a/src/mongo/s/query/cluster_aggregation_planner.cpp +++ b/src/mongo/s/query/cluster_aggregation_planner.cpp @@ -360,16 +360,16 @@ BSONObj establishMergingMongosCursor(OperationContext* opCtx, int nShards = ccc->getNumRemotes(); auto&& opDebug = CurOp::get(opCtx)->debug(); - // Fill out the aggregation metrics in CurOp, and record queryStats metrics, before detaching - // the cursor from its opCtx. + // Fill out the aggregation metrics in CurOp, and record telemetry metrics, before detaching the + // cursor from its opCtx. opDebug.nShards = std::max(opDebug.nShards, nShards); opDebug.cursorExhausted = exhausted; opDebug.additiveMetrics.nBatches = 1; CurOp::get(opCtx)->setEndOfOpMetrics(responseBuilder.numDocs()); if (exhausted) { - collectQueryStatsMongos(opCtx, ccc->getRequestShapifier()); + collectTelemetryMongos(opCtx, ccc->getRequestShapifier()); } else { - collectQueryStatsMongos(opCtx, ccc); + collectTelemetryMongos(opCtx, ccc); } ccc->detachFromOperationContext(); diff --git a/src/mongo/s/query/cluster_client_cursor.h b/src/mongo/s/query/cluster_client_cursor.h index 008bacd5ef6..1f0d9be54a7 100644 --- a/src/mongo/s/query/cluster_client_cursor.h +++ b/src/mongo/s/query/cluster_client_cursor.h @@ -270,11 +270,11 @@ public: * Returns and releases ownership of the RequestShapifier associated with the request this * cursor is handling. */ - virtual std::unique_ptr<query_stats::RequestShapifier> getRequestShapifier() = 0; + virtual std::unique_ptr<telemetry::RequestShapifier> getRequestShapifier() = 0; protected: // Metrics that are accumulated over the lifetime of the cursor, incremented with each getMore. - // Useful for diagnostics like queryStats. + // Useful for diagnostics like telemetry. OpDebug::AdditiveMetrics _metrics; private: diff --git a/src/mongo/s/query/cluster_client_cursor_impl.cpp b/src/mongo/s/query/cluster_client_cursor_impl.cpp index 9da06d36881..939637d0f32 100644 --- a/src/mongo/s/query/cluster_client_cursor_impl.cpp +++ b/src/mongo/s/query/cluster_client_cursor_impl.cpp @@ -32,7 +32,7 @@ #include <memory> #include "mongo/db/curop.h" -#include "mongo/db/query/query_stats.h" +#include "mongo/db/query/telemetry.h" #include "mongo/logv2/log.h" #include "mongo/s/query/router_stage_limit.h" #include "mongo/s/query/router_stage_merge.h" @@ -75,10 +75,9 @@ ClusterClientCursorImpl::ClusterClientCursorImpl(OperationContext* opCtx, _lastUseDate(_createdDate), _queryHash(CurOp::get(opCtx)->debug().queryHash), _shouldOmitDiagnosticInformation(CurOp::get(opCtx)->debug().shouldOmitDiagnosticInformation), - _queryStatsStoreKeyHash(CurOp::get(opCtx)->debug().queryStatsStoreKeyHash), - _queryStatsStoreKey(CurOp::get(opCtx)->debug().queryStatsStoreKey), - _queryStatsRequestShapifier( - std::move(CurOp::get(opCtx)->debug().queryStatsRequestShapifier)) { + _telemetryStoreKeyHash(CurOp::get(opCtx)->debug().telemetryStoreKeyHash), + _telemetryStoreKey(CurOp::get(opCtx)->debug().telemetryStoreKey), + _telemetryRequestShapifier(std::move(CurOp::get(opCtx)->debug().telemetryRequestShapifier)) { dassert(!_params.compareWholeSortKeyOnRouter || SimpleBSONObjComparator::kInstance.evaluate( _params.sortToApplyOnRouter == AsyncResultsMerger::kWholeSortKeySortPattern)); @@ -138,13 +137,13 @@ void ClusterClientCursorImpl::kill(OperationContext* opCtx) { "Cannot kill a cluster client cursor that has already been killed", !_hasBeenKilled); - if (_queryStatsStoreKeyHash && opCtx) { - query_stats::writeQueryStats(opCtx, - _queryStatsStoreKeyHash, - _queryStatsStoreKey, - std::move(_queryStatsRequestShapifier), - _metrics.executionTime.value_or(Microseconds{0}).count(), - _metrics.nreturned.value_or(0)); + if (_telemetryStoreKeyHash && opCtx) { + telemetry::writeTelemetry(opCtx, + _telemetryStoreKeyHash, + _telemetryStoreKey, + std::move(_telemetryRequestShapifier), + _metrics.executionTime.value_or(Microseconds{0}).count(), + _metrics.nreturned.value_or(0)); } _root->kill(opCtx); @@ -286,8 +285,8 @@ bool ClusterClientCursorImpl::shouldOmitDiagnosticInformation() const { return _shouldOmitDiagnosticInformation; } -std::unique_ptr<query_stats::RequestShapifier> ClusterClientCursorImpl::getRequestShapifier() { - return std::move(_queryStatsRequestShapifier); +std::unique_ptr<telemetry::RequestShapifier> ClusterClientCursorImpl::getRequestShapifier() { + return std::move(_telemetryRequestShapifier); } } // namespace mongo diff --git a/src/mongo/s/query/cluster_client_cursor_impl.h b/src/mongo/s/query/cluster_client_cursor_impl.h index 9d9168d6afb..ecb7535715c 100644 --- a/src/mongo/s/query/cluster_client_cursor_impl.h +++ b/src/mongo/s/query/cluster_client_cursor_impl.h @@ -121,7 +121,7 @@ public: bool shouldOmitDiagnosticInformation() const final; - std::unique_ptr<query_stats::RequestShapifier> getRequestShapifier() final; + std::unique_ptr<telemetry::RequestShapifier> getRequestShapifier() final; public: /** @@ -186,12 +186,12 @@ private: bool _shouldOmitDiagnosticInformation = false; // If boost::none, telemetry should not be collected for this cursor. - boost::optional<std::size_t> _queryStatsStoreKeyHash; - // TODO: SERVER-73152 remove queryStatsStoreKey when RequestShapifier is used for agg. - boost::optional<BSONObj> _queryStatsStoreKey; + boost::optional<std::size_t> _telemetryStoreKeyHash; + // TODO: SERVER-73152 remove telemetryStoreKey when RequestShapifier is used for agg. + boost::optional<BSONObj> _telemetryStoreKey; // The RequestShapifier used by telemetry to shapify the request payload into the telemetry // store key. - std::unique_ptr<query_stats::RequestShapifier> _queryStatsRequestShapifier; + std::unique_ptr<telemetry::RequestShapifier> _telemetryRequestShapifier; // Tracks if kill() has been called on the cursor. Multiple calls to kill() is an error. bool _hasBeenKilled = false; diff --git a/src/mongo/s/query/cluster_client_cursor_mock.cpp b/src/mongo/s/query/cluster_client_cursor_mock.cpp index 1e8b3561f5c..e495227b704 100644 --- a/src/mongo/s/query/cluster_client_cursor_mock.cpp +++ b/src/mongo/s/query/cluster_client_cursor_mock.cpp @@ -170,7 +170,7 @@ bool ClusterClientCursorMock::shouldOmitDiagnosticInformation() const { return false; } -std::unique_ptr<query_stats::RequestShapifier> ClusterClientCursorMock::getRequestShapifier() { +std::unique_ptr<telemetry::RequestShapifier> ClusterClientCursorMock::getRequestShapifier() { return nullptr; } diff --git a/src/mongo/s/query/cluster_client_cursor_mock.h b/src/mongo/s/query/cluster_client_cursor_mock.h index 750a67abdde..131ca234287 100644 --- a/src/mongo/s/query/cluster_client_cursor_mock.h +++ b/src/mongo/s/query/cluster_client_cursor_mock.h @@ -121,7 +121,7 @@ public: bool shouldOmitDiagnosticInformation() const final; - std::unique_ptr<query_stats::RequestShapifier> getRequestShapifier() final; + std::unique_ptr<telemetry::RequestShapifier> getRequestShapifier() final; private: bool _killed = false; diff --git a/src/mongo/s/query/cluster_cursor_manager.cpp b/src/mongo/s/query/cluster_cursor_manager.cpp index 68436d25c6e..d8e47e55ecf 100644 --- a/src/mongo/s/query/cluster_cursor_manager.cpp +++ b/src/mongo/s/query/cluster_cursor_manager.cpp @@ -38,7 +38,7 @@ #include "mongo/db/allocate_cursor_id.h" #include "mongo/db/curop.h" #include "mongo/db/query/query_knobs_gen.h" -#include "mongo/db/query/query_stats.h" +#include "mongo/db/query/telemetry.h" #include "mongo/db/session/kill_sessions_common.h" #include "mongo/db/session/logical_session_cache.h" #include "mongo/logv2/log.h" @@ -591,25 +591,25 @@ StatusWith<ClusterClientCursorGuard> ClusterCursorManager::_detachCursor(WithLoc return std::move(cursor); } -void collectQueryStatsMongos(OperationContext* opCtx, - std::unique_ptr<query_stats::RequestShapifier> requestShapifier) { +void collectTelemetryMongos(OperationContext* opCtx, + std::unique_ptr<telemetry::RequestShapifier> requestShapifier) { // If we haven't registered a cursor to prepare for getMore requests, we record - // queryStats directly. + // telemetry directly. auto&& opDebug = CurOp::get(opCtx)->debug(); - query_stats::writeQueryStats( + telemetry::writeTelemetry( opCtx, - opDebug.queryStatsStoreKeyHash, - opDebug.queryStatsStoreKey, + opDebug.telemetryStoreKeyHash, + opDebug.telemetryStoreKey, std::move(requestShapifier), opDebug.additiveMetrics.executionTime.value_or(Microseconds{0}).count(), opDebug.additiveMetrics.nreturned.value_or(0)); } -void collectQueryStatsMongos(OperationContext* opCtx, ClusterClientCursorGuard& cursor) { +void collectTelemetryMongos(OperationContext* opCtx, ClusterClientCursorGuard& cursor) { cursor->incrementCursorMetrics(CurOp::get(opCtx)->debug().additiveMetrics); } -void collectQueryStatsMongos(OperationContext* opCtx, ClusterCursorManager::PinnedCursor& cursor) { +void collectTelemetryMongos(OperationContext* opCtx, ClusterCursorManager::PinnedCursor& cursor) { cursor->incrementCursorMetrics(CurOp::get(opCtx)->debug().additiveMetrics); } diff --git a/src/mongo/s/query/cluster_cursor_manager.h b/src/mongo/s/query/cluster_cursor_manager.h index b10824baf09..219dd773f82 100644 --- a/src/mongo/s/query/cluster_cursor_manager.h +++ b/src/mongo/s/query/cluster_cursor_manager.h @@ -600,7 +600,7 @@ private: }; /** - * Record metrics for the current operation on opDebug and aggregates those metrics for queryStats + * Record metrics for the current operation on opDebug and aggregates those metrics for telemetry * use. If a cursor is provided (via ClusterClientCursorGuard or * ClusterCursorManager::PinnedCursor), metrics are aggregated on the cursor; otherwise, metrics are * written directly to the telemetry store. @@ -610,9 +610,9 @@ private: * Currently, telemetry is only collected for find and aggregate requests (and their subsequent * getMore requests), so these should only be called from those request paths. */ -void collectQueryStatsMongos(OperationContext* opCtx, - std::unique_ptr<query_stats::RequestShapifier> requestShapifier); -void collectQueryStatsMongos(OperationContext* opCtx, ClusterClientCursorGuard& cursor); -void collectQueryStatsMongos(OperationContext* opCtx, ClusterCursorManager::PinnedCursor& cursor); +void collectTelemetryMongos(OperationContext* opCtx, + std::unique_ptr<telemetry::RequestShapifier> requestShapifier); +void collectTelemetryMongos(OperationContext* opCtx, ClusterClientCursorGuard& cursor); +void collectTelemetryMongos(OperationContext* opCtx, ClusterCursorManager::PinnedCursor& cursor); } // namespace mongo diff --git a/src/mongo/s/query/cluster_find.cpp b/src/mongo/s/query/cluster_find.cpp index d0bd48a0d51..5b340ec098a 100644 --- a/src/mongo/s/query/cluster_find.cpp +++ b/src/mongo/s/query/cluster_find.cpp @@ -48,7 +48,7 @@ #include "mongo/db/query/find_common.h" #include "mongo/db/query/getmore_command_gen.h" #include "mongo/db/query/query_planner_common.h" -#include "mongo/db/query/query_stats.h" +#include "mongo/db/query/telemetry.h" #include "mongo/executor/task_executor_pool.h" #include "mongo/logv2/log.h" #include "mongo/platform/overflow_arithmetic.h" @@ -444,7 +444,7 @@ CursorId runQueryWithoutRetrying(OperationContext* opCtx, if (shardIds.size() > 0) { updateNumHostsTargetedMetrics(opCtx, cm, shardIds.size()); } - collectQueryStatsMongos(opCtx, ccc->getRequestShapifier()); + collectTelemetryMongos(opCtx, ccc->getRequestShapifier()); return CursorId(0); } @@ -455,7 +455,7 @@ CursorId runQueryWithoutRetrying(OperationContext* opCtx, ? ClusterCursorManager::CursorLifetime::Immortal : ClusterCursorManager::CursorLifetime::Mortal; auto authUser = AuthorizationSession::get(opCtx->getClient())->getAuthenticatedUserName(); - collectQueryStatsMongos(opCtx, ccc); + collectTelemetryMongos(opCtx, ccc); auto cursorId = uassertStatusOK(cursorManager->registerCursor( opCtx, ccc.releaseCursor(), query.nss(), cursorType, cursorLifetime, authUser)); @@ -923,7 +923,7 @@ StatusWith<CursorResponse> ClusterFind::runGetMore(OperationContext* opCtx, const bool partialResultsReturned = pinnedCursor.getValue()->partialResultsReturned(); pinnedCursor.getValue()->setLeftoverMaxTimeMicros(opCtx->getRemainingMaxTimeMicros()); - collectQueryStatsMongos(opCtx, pinnedCursor.getValue()); + collectTelemetryMongos(opCtx, pinnedCursor.getValue()); // Upon successful completion, transfer ownership of the cursor back to the cursor manager. If // the cursor has been exhausted, the cursor manager will clean it up for us. diff --git a/src/mongo/s/query/store_possible_cursor.cpp b/src/mongo/s/query/store_possible_cursor.cpp index a5c6759f4d1..38cec4024ed 100644 --- a/src/mongo/s/query/store_possible_cursor.cpp +++ b/src/mongo/s/query/store_possible_cursor.cpp @@ -98,7 +98,7 @@ StatusWith<BSONObj> storePossibleCursor(OperationContext* opCtx, if (incomingCursorResponse.getValue().getCursorId() == CursorId(0)) { opDebug.cursorExhausted = true; - collectQueryStatsMongos(opCtx, std::move(opDebug.queryStatsRequestShapifier)); + collectTelemetryMongos(opCtx, std::move(opDebug.telemetryRequestShapifier)); return cmdResult; } @@ -130,7 +130,7 @@ StatusWith<BSONObj> storePossibleCursor(OperationContext* opCtx, } auto ccc = ClusterClientCursorImpl::make(opCtx, std::move(executor), std::move(params)); - collectQueryStatsMongos(opCtx, ccc); + collectTelemetryMongos(opCtx, ccc); // We don't expect to use this cursor until a subsequent getMore, so detach from the current // OperationContext until then. ccc->detachFromOperationContext(); |