summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@mongodb.com>2015-06-02 15:06:22 -0400
committerAndy Schwerin <schwerin@mongodb.com>2015-06-05 14:21:57 -0400
commit54040db4fa000284cb1148b93e85f81c54ca12d6 (patch)
tree1e2affd65adaecfb35507ddf64aa507b8e606d85 /src
parentf4ca1b7eb3850719049d938b4b4562b6324ec284 (diff)
downloadmongo-54040db4fa000284cb1148b93e85f81c54ca12d6.tar.gz
SERVER-18277 Move server status metrics code out of curop.cpp into curop_metrics.cpp.
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/SConscript4
-rw-r--r--src/mongo/db/commands/write_commands/batch_executor.cpp3
-rw-r--r--src/mongo/db/curop.cpp52
-rw-r--r--src/mongo/db/curop.h2
-rw-r--r--src/mongo/db/curop_metrics.cpp90
-rw-r--r--src/mongo/db/curop_metrics.h37
-rw-r--r--src/mongo/db/instance.cpp3
7 files changed, 133 insertions, 58 deletions
diff --git a/src/mongo/db/SConscript b/src/mongo/db/SConscript
index 249f88ee574..5d809eba476 100644
--- a/src/mongo/db/SConscript
+++ b/src/mongo/db/SConscript
@@ -139,11 +139,10 @@ env.Library(
],
LIBDEPS=[
'$BUILD_DIR/mongo/bson/mutable/mutable_bson',
- '$BUILD_DIR/mongo/db/commands/server_status_core',
'$BUILD_DIR/mongo/db/concurrency/lock_manager',
+ '$BUILD_DIR/mongo/db/service_context',
'$BUILD_DIR/mongo/util/fail_point',
'$BUILD_DIR/mongo/util/net/network',
- '$BUILD_DIR/mongo/db/service_context',
'$BUILD_DIR/mongo/util/progress_meter',
],
)
@@ -551,6 +550,7 @@ serverOnlyFiles = [
"commands/write_commands/batch_executor.cpp",
"commands/write_commands/write_commands.cpp",
"commands/writeback_compatibility_shim.cpp",
+ "curop_metrics.cpp",
"db_raii.cpp",
"dbcommands.cpp",
"dbdirectclient.cpp",
diff --git a/src/mongo/db/commands/write_commands/batch_executor.cpp b/src/mongo/db/commands/write_commands/batch_executor.cpp
index acc7b27df62..1bcc3679b77 100644
--- a/src/mongo/db/commands/write_commands/batch_executor.cpp
+++ b/src/mongo/db/commands/write_commands/batch_executor.cpp
@@ -43,6 +43,7 @@
#include "mongo/db/clientcursor.h"
#include "mongo/db/commands.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
+#include "mongo/db/curop_metrics.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/exec/delete.h"
#include "mongo/db/exec/update.h"
@@ -589,7 +590,7 @@ namespace mongo {
CurOp* currentOp = CurOp::get(txn);
currentOp->done();
int executionTime = currentOp->debug().executionTime = currentOp->totalTimeMillis();
- currentOp->debug().recordStats();
+ recordCurOpMetrics(txn);
Top::get(txn->getClient()->getServiceContext()).record(
currentOp->getNS(),
currentOp->getOp(),
diff --git a/src/mongo/db/curop.cpp b/src/mongo/db/curop.cpp
index 2998492b145..cbb38a83ca3 100644
--- a/src/mongo/db/curop.cpp
+++ b/src/mongo/db/curop.cpp
@@ -32,7 +32,6 @@
#include "mongo/db/curop.h"
-#include "mongo/base/counter.h"
#include "mongo/base/disallow_copying.h"
#include "mongo/bson/mutable/document.h"
#include "mongo/db/client.h"
@@ -373,57 +372,6 @@ namespace mongo {
return _targetEpochMicros - now;
}
-
- static Counter64 returnedCounter;
- static Counter64 insertedCounter;
- static Counter64 updatedCounter;
- static Counter64 deletedCounter;
- static Counter64 scannedCounter;
- static Counter64 scannedObjectCounter;
-
- static ServerStatusMetricField<Counter64> displayReturned( "document.returned", &returnedCounter );
- static ServerStatusMetricField<Counter64> displayUpdated( "document.updated", &updatedCounter );
- static ServerStatusMetricField<Counter64> displayInserted( "document.inserted", &insertedCounter );
- static ServerStatusMetricField<Counter64> displayDeleted( "document.deleted", &deletedCounter );
- static ServerStatusMetricField<Counter64> displayScanned( "queryExecutor.scanned", &scannedCounter );
- static ServerStatusMetricField<Counter64> displayScannedObjects( "queryExecutor.scannedObjects",
- &scannedObjectCounter );
-
- static Counter64 idhackCounter;
- static Counter64 scanAndOrderCounter;
- static Counter64 fastmodCounter;
- static Counter64 writeConflictsCounter;
-
- static ServerStatusMetricField<Counter64> displayIdhack( "operation.idhack", &idhackCounter );
- static ServerStatusMetricField<Counter64> displayScanAndOrder( "operation.scanAndOrder", &scanAndOrderCounter );
- static ServerStatusMetricField<Counter64> displayFastMod( "operation.fastmod", &fastmodCounter );
- static ServerStatusMetricField<Counter64> displayWriteConflicts( "operation.writeConflicts",
- &writeConflictsCounter );
-
- void OpDebug::recordStats() {
- if ( nreturned > 0 )
- returnedCounter.increment( nreturned );
- if ( ninserted > 0 )
- insertedCounter.increment( ninserted );
- if ( nMatched > 0 )
- updatedCounter.increment( nMatched );
- if ( ndeleted > 0 )
- deletedCounter.increment( ndeleted );
- if ( nscanned > 0 )
- scannedCounter.increment( nscanned );
- if ( nscannedObjects > 0 )
- scannedObjectCounter.increment( nscannedObjects );
-
- if ( idhack )
- idhackCounter.increment();
- if ( scanAndOrder )
- scanAndOrderCounter.increment();
- if ( fastmod )
- fastmodCounter.increment();
- if ( writeConflicts )
- writeConflictsCounter.increment( writeConflicts );
- }
-
void OpDebug::reset() {
extra.reset();
diff --git a/src/mongo/db/curop.h b/src/mongo/db/curop.h
index 2067f1d7af5..080739204f4 100644
--- a/src/mongo/db/curop.h
+++ b/src/mongo/db/curop.h
@@ -127,8 +127,6 @@ namespace mongo {
void reset();
- void recordStats();
-
std::string report(const CurOp& curop, const SingleThreadedLockStats& lockStats) const;
/**
diff --git a/src/mongo/db/curop_metrics.cpp b/src/mongo/db/curop_metrics.cpp
new file mode 100644
index 00000000000..d0cde25d225
--- /dev/null
+++ b/src/mongo/db/curop_metrics.cpp
@@ -0,0 +1,90 @@
+/**
+ * Copyright (C) 2015 MongoDB, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * 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
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * 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 GNU Affero General 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/base/counter.h"
+#include "mongo/db/curop.h"
+#include "mongo/db/operation_context.h"
+#include "mongo/db/commands/server_status_metric.h"
+
+namespace mongo {
+namespace {
+ Counter64 returnedCounter;
+ Counter64 insertedCounter;
+ Counter64 updatedCounter;
+ Counter64 deletedCounter;
+ Counter64 scannedCounter;
+ Counter64 scannedObjectCounter;
+
+ ServerStatusMetricField<Counter64> displayReturned("document.returned", &returnedCounter);
+ ServerStatusMetricField<Counter64> displayUpdated("document.updated", &updatedCounter);
+ ServerStatusMetricField<Counter64> displayInserted("document.inserted", &insertedCounter);
+ ServerStatusMetricField<Counter64> displayDeleted("document.deleted", &deletedCounter);
+ ServerStatusMetricField<Counter64> displayScanned("queryExecutor.scanned", &scannedCounter);
+ ServerStatusMetricField<Counter64> displayScannedObjects("queryExecutor.scannedObjects",
+ &scannedObjectCounter);
+
+ Counter64 idhackCounter;
+ Counter64 scanAndOrderCounter;
+ Counter64 fastmodCounter;
+ Counter64 writeConflictsCounter;
+
+ ServerStatusMetricField<Counter64> displayIdhack("operation.idhack", &idhackCounter);
+ ServerStatusMetricField<Counter64> displayScanAndOrder("operation.scanAndOrder",
+ &scanAndOrderCounter);
+ ServerStatusMetricField<Counter64> displayFastMod("operation.fastmod", &fastmodCounter);
+ ServerStatusMetricField<Counter64> displayWriteConflicts("operation.writeConflicts",
+ &writeConflictsCounter);
+
+} // namespace
+
+ void recordCurOpMetrics(OperationContext* opCtx) {
+ const OpDebug& debug = CurOp::get(opCtx)->debug();
+ if (debug.nreturned > 0)
+ returnedCounter.increment(debug.nreturned);
+ if (debug.ninserted > 0)
+ insertedCounter.increment(debug.ninserted);
+ if (debug.nMatched > 0)
+ updatedCounter.increment(debug.nMatched);
+ if (debug.ndeleted > 0)
+ deletedCounter.increment(debug.ndeleted);
+ if (debug.nscanned > 0)
+ scannedCounter.increment(debug.nscanned);
+ if (debug.nscannedObjects > 0)
+ scannedObjectCounter.increment(debug.nscannedObjects);
+
+ if (debug.idhack)
+ idhackCounter.increment();
+ if (debug.scanAndOrder)
+ scanAndOrderCounter.increment();
+ if (debug.fastmod)
+ fastmodCounter.increment();
+ if (debug.writeConflicts)
+ writeConflictsCounter.increment(debug.writeConflicts);
+ }
+
+} // namespace mongo
diff --git a/src/mongo/db/curop_metrics.h b/src/mongo/db/curop_metrics.h
new file mode 100644
index 00000000000..42429f981be
--- /dev/null
+++ b/src/mongo/db/curop_metrics.h
@@ -0,0 +1,37 @@
+/**
+ * Copyright (C) 2015 MongoDB, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * 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
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * 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 GNU Affero General 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
+
+namespace mongo {
+
+ class OperationContext;
+
+ void recordCurOpMetrics(OperationContext* opCtx);
+
+} // namespace mongo
diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp
index 1d14670a640..859bee227aa 100644
--- a/src/mongo/db/instance.cpp
+++ b/src/mongo/db/instance.cpp
@@ -52,6 +52,7 @@
#include "mongo/db/concurrency/d_concurrency.h"
#include "mongo/db/concurrency/lock_state.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
+#include "mongo/db/curop_metrics.h"
#include "mongo/db/db.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/dbdirectclient.h"
@@ -652,7 +653,7 @@ namespace {
}
}
- debug.recordStats();
+ recordCurOpMetrics(txn);
debug.reset();
}