summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Louie <nathan.louie@10gen.com>2018-06-28 11:48:18 -0400
committerNathan Louie <nathan.louie@10gen.com>2018-07-05 16:00:09 -0400
commit96c5d840db4f4279cd9fc8ffe4bdfdc60fcd3984 (patch)
tree174d2a83ed1c613ef5c57daafeb1c15b3973ee16
parent1447252f5f44e4a2df4b7e38d4bdef0d88e526c4 (diff)
downloadmongo-96c5d840db4f4279cd9fc8ffe4bdfdc60fcd3984.tar.gz
SERVER-35157 Add transactions latency tracking to OperationLatencyHistogram
-rw-r--r--src/mongo/db/commands.h4
-rw-r--r--src/mongo/db/stats/operation_latency_histogram.cpp4
-rw-r--r--src/mongo/db/stats/operation_latency_histogram.h7
-rw-r--r--src/mongo/db/stats/operation_latency_histogram_test.cpp2
4 files changed, 12 insertions, 5 deletions
diff --git a/src/mongo/db/commands.h b/src/mongo/db/commands.h
index a767c8f60c8..966a0d640c7 100644
--- a/src/mongo/db/commands.h
+++ b/src/mongo/db/commands.h
@@ -370,12 +370,12 @@ public:
}
/**
- * Returns whether this operation is a read, write, or command.
+ * Returns whether this operation is a read, write, command, or multi-document transaction.
*
* Commands which implement database read or write logic should override this to return kRead
* or kWrite as appropriate.
*/
- enum class ReadWriteType { kCommand, kRead, kWrite };
+ enum class ReadWriteType { kCommand, kRead, kWrite, kTransaction };
virtual ReadWriteType getReadWriteType() const {
return ReadWriteType::kCommand;
}
diff --git a/src/mongo/db/stats/operation_latency_histogram.cpp b/src/mongo/db/stats/operation_latency_histogram.cpp
index 74a1f462760..be406c860f4 100644
--- a/src/mongo/db/stats/operation_latency_histogram.cpp
+++ b/src/mongo/db/stats/operation_latency_histogram.cpp
@@ -118,6 +118,7 @@ void OperationLatencyHistogram::append(bool includeHistograms, BSONObjBuilder* b
_append(_reads, "reads", includeHistograms, builder);
_append(_writes, "writes", includeHistograms, builder);
_append(_commands, "commands", includeHistograms, builder);
+ _append(_transactions, "transactions", includeHistograms, builder);
}
// Computes the log base 2 of value, and checks for cases of split buckets.
@@ -165,6 +166,9 @@ void OperationLatencyHistogram::increment(uint64_t latency, Command::ReadWriteTy
case Command::ReadWriteType::kCommand:
_incrementData(latency, bucket, &_commands);
break;
+ case Command::ReadWriteType::kTransaction:
+ _incrementData(latency, bucket, &_transactions);
+ break;
default:
MONGO_UNREACHABLE;
}
diff --git a/src/mongo/db/stats/operation_latency_histogram.h b/src/mongo/db/stats/operation_latency_histogram.h
index 3d6e753ca49..e7652c7383f 100644
--- a/src/mongo/db/stats/operation_latency_histogram.h
+++ b/src/mongo/db/stats/operation_latency_histogram.h
@@ -36,7 +36,8 @@ namespace mongo {
class BSONObjBuilder;
/**
- * Stores statistics for latencies of read, write, and command operations.
+ * Stores statistics for latencies of read, write, command, and multi-document transaction
+ * operations.
*
* Note: This class is not thread-safe.
*/
@@ -53,7 +54,7 @@ public:
void increment(uint64_t latency, Command::ReadWriteType type);
/**
- * Appends the three histograms with latency totals and operation counts.
+ * Appends the four histograms with latency totals and operation counts.
*/
void append(bool includeHistograms, BSONObjBuilder* builder) const;
@@ -75,6 +76,6 @@ private:
void _incrementData(uint64_t latency, int bucket, HistogramData* data);
- HistogramData _reads, _writes, _commands;
+ HistogramData _reads, _writes, _commands, _transactions;
};
} // namespace mongo
diff --git a/src/mongo/db/stats/operation_latency_histogram_test.cpp b/src/mongo/db/stats/operation_latency_histogram_test.cpp
index 9a1e0b05328..03f4ffb2968 100644
--- a/src/mongo/db/stats/operation_latency_histogram_test.cpp
+++ b/src/mongo/db/stats/operation_latency_histogram_test.cpp
@@ -52,6 +52,7 @@ TEST(OperationLatencyHistogram, EnsureIncrementsStored) {
hist.increment(i, Command::ReadWriteType::kRead);
hist.increment(i, Command::ReadWriteType::kWrite);
hist.increment(i, Command::ReadWriteType::kCommand);
+ hist.increment(i, Command::ReadWriteType::kTransaction);
}
BSONObjBuilder outBuilder;
hist.append(false, &outBuilder);
@@ -59,6 +60,7 @@ TEST(OperationLatencyHistogram, EnsureIncrementsStored) {
ASSERT_EQUALS(out["reads"]["ops"].Long(), kMaxBuckets);
ASSERT_EQUALS(out["writes"]["ops"].Long(), kMaxBuckets);
ASSERT_EQUALS(out["commands"]["ops"].Long(), kMaxBuckets);
+ ASSERT_EQUALS(out["transactions"]["ops"].Long(), kMaxBuckets);
}
TEST(OperationLatencyHistogram, CheckBucketCountsAndTotalLatency) {