summaryrefslogtreecommitdiff
path: root/src/mongo/db/clientcursor.cpp
diff options
context:
space:
mode:
authorWill Buerger <will.buerger@mongodb.com>2023-03-01 17:27:23 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-03-01 21:26:19 +0000
commit12f2e3d221ac01156db60f307d433b56340115c3 (patch)
tree78cefa99ff44c7215c04d0a41777dcc7e90486a5 /src/mongo/db/clientcursor.cpp
parentc80ca4373ac767037563691c9dd69f57258f2756 (diff)
downloadmongo-12f2e3d221ac01156db60f307d433b56340115c3.tar.gz
SERVER-73727: Aggregate mongos metrics in ClusterClientCursor
Diffstat (limited to 'src/mongo/db/clientcursor.cpp')
-rw-r--r--src/mongo/db/clientcursor.cpp65
1 files changed, 21 insertions, 44 deletions
diff --git a/src/mongo/db/clientcursor.cpp b/src/mongo/db/clientcursor.cpp
index 6c74f6be1ec..0fd963220a3 100644
--- a/src/mongo/db/clientcursor.cpp
+++ b/src/mongo/db/clientcursor.cpp
@@ -157,13 +157,7 @@ void ClientCursor::dispose(OperationContext* opCtx, boost::optional<Date_t> now)
}
if (_telemetryStoreKey && opCtx) {
- telemetry::writeTelemetry(opCtx,
- _telemetryStoreKey,
- _queryOptMicros,
- _queryExecMicros,
- _docsReturned,
- _metrics.docsExamined.value_or(0),
- _metrics.keysExamined.value_or(0));
+ telemetry::writeTelemetry(opCtx, _telemetryStoreKey, _queryExecMicros, _docsReturned);
}
if (now) {
@@ -386,44 +380,27 @@ void startClientCursorMonitor() {
getClientCursorMonitor(getGlobalServiceContext()).go();
}
-void collectTelemetry(OperationContext* opCtx,
- boost::optional<ClientCursorPin&> pinnedCursor,
- bool isGetMoreOp) {
+void collectTelemetryMongod(OperationContext* opCtx, ClientCursorPin& pinnedCursor) {
auto&& opDebug = CurOp::get(opCtx)->debug();
- if (pinnedCursor) {
- auto cursor = pinnedCursor->getCursor();
- // TODO SERVER-73727 setting shouldRecordTelemetry to boost::none is only
- // temporarily necessary to avoid collecting metrics a second time in
- // CurOp::completeAndLogOperation
- opDebug.telemetryStoreKey = boost::none;
-
- // We have to use `elapsedTimeExcludingPauses` to count execution time since
- // additiveMetrics.queryExecMicros isn't set until curOp is closing out.
- cursor->incCursorMetrics(opDebug.additiveMetrics,
- CurOp::get(opCtx)->elapsedTimeExcludingPauses().count(),
- opDebug.nreturned);
-
- // If the current operation is a getMore, planning time was already aggregated on the
- // initial operation.
- if (!isGetMoreOp) {
- cursor->setQueryOptMicros(opDebug.planningTime.count());
- }
- } else {
- tassert(7301701, "getMore operations should aggregate metrics on the cursor", !isGetMoreOp);
- auto&& opDebug = CurOp::get(opCtx)->debug();
- // If we haven't registered a cursor to prepare for getMore requests, we record
- // telemetry directly.
- //
- // We have to use `elapsedTimeExcludingPauses` to count execution time since
- // additiveMetrics.queryExecMicros isn't set until curOp is closing out.
- telemetry::writeTelemetry(opCtx,
- opDebug.telemetryStoreKey,
- opDebug.planningTime.count(),
- CurOp::get(opCtx)->elapsedTimeExcludingPauses().count(),
- opDebug.nreturned,
- opDebug.additiveMetrics.docsExamined.value_or(0),
- opDebug.additiveMetrics.keysExamined.value_or(0));
- }
+
+ // We have to use `elapsedTimeExcludingPauses` to count execution time since
+ // additiveMetrics.queryExecMicros isn't set until curOp is closing out.
+ pinnedCursor->incrementCursorMetrics(opDebug.additiveMetrics,
+ CurOp::get(opCtx)->elapsedTimeExcludingPauses().count(),
+ opDebug.nreturned);
+}
+
+void collectTelemetryMongod(OperationContext* opCtx) {
+ auto&& opDebug = CurOp::get(opCtx)->debug();
+ // If we haven't registered a cursor to prepare for getMore requests, we record
+ // telemetry directly.
+ //
+ // We have to use `elapsedTimeExcludingPauses` to count execution time since
+ // additiveMetrics.queryExecMicros isn't set until curOp is closing out.
+ telemetry::writeTelemetry(opCtx,
+ opDebug.telemetryStoreKey,
+ CurOp::get(opCtx)->elapsedTimeExcludingPauses().count(),
+ opDebug.nreturned);
}
} // namespace mongo