Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Unified Diff: dbus/exported_object.cc

Issue 7824054: Add some histograms to the D-Bus library: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rate->ratio Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dbus/exported_object.h ('k') | dbus/object_proxy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dbus/exported_object.cc
diff --git a/dbus/exported_object.cc b/dbus/exported_object.cc
index 8d36d155df797f37b3c2fda87b203ec0286e9abd..c4ebd3bf236dc4a0bacbf73eeb94998ff3cc6c2d 100644
--- a/dbus/exported_object.cc
+++ b/dbus/exported_object.cc
@@ -8,6 +8,7 @@
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/message_loop.h"
+#include "base/metrics/histogram.h"
#include "base/threading/thread_restrictions.h"
#include "base/time.h"
#include "dbus/bus.h"
@@ -18,6 +19,9 @@ namespace dbus {
namespace {
+// Used for success ratio histograms. 1 for success, 0 for failure.
+const int kSuccessRatioHistogramMaxValue = 2;
+
// Gets the absolute method name by concatenating the interface name and
// the method name. Used for building keys for method_table_ in
// ExportedObject.
@@ -100,11 +104,13 @@ void ExportedObject::SendSignal(Signal* signal) {
DBusMessage* signal_message = signal->raw_message();
dbus_message_ref(signal_message);
+ const base::TimeTicks start_time = base::TimeTicks::Now();
// Bind() won't compile if we pass signal_message. See the comment at
// ObjectProxy::CallMethod() for details.
bus_->PostTaskToDBusThread(FROM_HERE,
base::Bind(&ExportedObject::SendSignalInternal,
this,
+ start_time,
static_cast<void*>(signal_message)));
}
@@ -146,12 +152,18 @@ void ExportedObject::OnExported(OnExportedCallback on_exported_callback,
on_exported_callback.Run(interface_name, method_name, success);
}
-void ExportedObject::SendSignalInternal(void* in_signal_message) {
+void ExportedObject::SendSignalInternal(base::TimeTicks start_time,
+ void* in_signal_message) {
DBusMessage* signal_message =
static_cast<DBusMessage*>(in_signal_message);
uint32 serial = 0;
bus_->Send(signal_message, &serial);
dbus_message_unref(signal_message);
+ // Record time spent to send the the signal. This is not accurate as the
+ // signal will actually be sent from the next run of the message loop,
+ // but we can at least tell the number of signals sent.
+ UMA_HISTOGRAM_TIMES("DBus.SignalSendTime",
+ base::TimeTicks::Now() - start_time);
}
bool ExportedObject::Register() {
@@ -195,6 +207,7 @@ DBusHandlerResult ExportedObject::HandleMessage(
if (interface.empty()) {
// We don't support method calls without interface.
+ LOG(WARNING) << "Interface is missing: " << method_call->ToString();
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
@@ -204,9 +217,11 @@ DBusHandlerResult ExportedObject::HandleMessage(
MethodTable::const_iterator iter = method_table_.find(absolute_method_name);
if (iter == method_table_.end()) {
// Don't know about the method.
+ LOG(WARNING) << "Unknown method: " << method_call->ToString();
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
+ const base::TimeTicks start_time = base::TimeTicks::Now();
Response* response = NULL;
if (bus_->HasDBusThread()) {
response_from_method_ = NULL;
@@ -237,6 +252,10 @@ DBusHandlerResult ExportedObject::HandleMessage(
// complete.
response = iter->second.Run(method_call.get());
}
+ // Record if the method call is successful, or not. 1 if successful.
+ UMA_HISTOGRAM_ENUMERATION("DBus.ExportedMethodHandleSuccess",
+ response ? 1 : 0,
+ kSuccessRatioHistogramMaxValue);
if (!response) {
// Something bad happened in the method call.
@@ -251,6 +270,9 @@ DBusHandlerResult ExportedObject::HandleMessage(
// The method call was successful.
dbus_connection_send(connection, response->raw_message(), NULL);
delete response;
+ // Record time spent to handle the the method call. Don't include failures.
+ UMA_HISTOGRAM_TIMES("DBus.ExportedMethodHandleTime",
+ base::TimeTicks::Now() - start_time);
return DBUS_HANDLER_RESULT_HANDLED;
}
« no previous file with comments | « dbus/exported_object.h ('k') | dbus/object_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698