diff --git a/Framework/Kernel/inc/MantidKernel/CrashService.h b/Framework/Kernel/inc/MantidKernel/CrashService.h index d8f89e20d97f84e1abc5eb97bbf1fff0341ef5ff..c216cc2c41db94a74831b6d325034c38139bb442 100644 --- a/Framework/Kernel/inc/MantidKernel/CrashService.h +++ b/Framework/Kernel/inc/MantidKernel/CrashService.h @@ -36,6 +36,7 @@ namespace Kernel { class MANTID_KERNEL_DLL CrashServiceImpl { public: CrashServiceImpl(std::string application); + CrashServiceImpl(std::string application, std::string startTime); void sendCrashReport(); protected: @@ -46,6 +47,7 @@ class MANTID_KERNEL_DLL CrashServiceImpl { private: int sendCrashAsyncImpl(const std::string &message); const std::string m_application; + const std::string m_startTime; /// Async method for sending startup notifications Poco::ActiveMethod<int, std::string, CrashServiceImpl> m_crashActiveMethod; }; diff --git a/Framework/Kernel/inc/MantidKernel/UsageService.h b/Framework/Kernel/inc/MantidKernel/UsageService.h index 936bbec93b0ca0d95d3ecf3acc9ea26aa3b0a1b5..3d06c159db5fd37d07117745d3d461a06f51fc3a 100644 --- a/Framework/Kernel/inc/MantidKernel/UsageService.h +++ b/Framework/Kernel/inc/MantidKernel/UsageService.h @@ -84,6 +84,8 @@ public: /// flushes any buffers and sends any outstanding usage reports void flush(); void shutdown(); + /// gets the uptime of this mantid instance + std::string getStartTime(); protected: /// Constructor @@ -131,6 +133,7 @@ private: bool m_isEnabled; mutable std::mutex m_mutex; std::string m_application; + std::string m_startTime; /// Async method for sending startup notifications Poco::ActiveMethod<int, std::string, UsageServiceImpl> m_startupActiveMethod; diff --git a/Framework/Kernel/src/CrashService.cpp b/Framework/Kernel/src/CrashService.cpp index 54023d148bb61ff499f9dbba9bf09d97f8d4c062..745a4383882c12c5235fda01725089dfb5cf3382 100644 --- a/Framework/Kernel/src/CrashService.cpp +++ b/Framework/Kernel/src/CrashService.cpp @@ -28,9 +28,10 @@ const std::string CRASH_URL("http://crashreports.mantidproject.org/api/crash"); //---------------------------------------------------------------------------------------------- // Constructor for CrashServiceImpl CrashServiceImpl::CrashServiceImpl(std::string application) - : m_application(application), m_crashActiveMethod(this, &CrashServiceImpl::sendCrashAsyncImpl) { - -} + : m_application(application), m_startTime(""), m_crashActiveMethod(this, &CrashServiceImpl::sendCrashAsyncImpl) {} + +CrashServiceImpl::CrashServiceImpl(std::string application, std::string startTime) + : m_application(application), m_startTime(startTime), m_crashActiveMethod(this, &CrashServiceImpl::sendCrashAsyncImpl) {} void CrashServiceImpl::sendCrashReport() { try { @@ -73,6 +74,8 @@ std::string CrashServiceImpl::generateCrashMessage() { message["dateTime"] = Types::Core::DateAndTime::getCurrentTime().toISO8601String(); + message["startTime"] = m_startTime; + message["application"] = m_application; message["facility"] = ConfigService::Instance().getFacility().name(); diff --git a/Framework/Kernel/src/UsageService.cpp b/Framework/Kernel/src/UsageService.cpp index ea4c8a7e27be0ae562c1882b22d0002d3ad2227a..f4cac93b6e7c9c7c3bd406c35bb17d4cc503da38 100644 --- a/Framework/Kernel/src/UsageService.cpp +++ b/Framework/Kernel/src/UsageService.cpp @@ -131,6 +131,10 @@ void UsageServiceImpl::flush() { } } +std::string UsageServiceImpl::getStartTime() { + return m_startTime; +} + void UsageServiceImpl::shutdown() { try { // stop the timer @@ -145,8 +149,8 @@ void UsageServiceImpl::shutdown() { void UsageServiceImpl::sendStartupReport() { try { + m_startTime = Types::Core::DateAndTime::getCurrentTime().toISO8601String(); std::string message = this->generateStartupMessage(); - // send the report Poco::ActiveResult<int> result = m_startupActiveMethod(message); } catch (std::exception &ex) { @@ -227,8 +231,7 @@ std::string UsageServiceImpl::generateStartupMessage() { message["mantidSha1"] = MantidVersion::revisionFull(); // mantid version and sha1 - message["dateTime"] = - Types::Core::DateAndTime::getCurrentTime().toISO8601String(); + message["dateTime"] = m_startTime; message["application"] = m_application; diff --git a/MantidPlot/src/Mantid/MantidApplication.cpp b/MantidPlot/src/Mantid/MantidApplication.cpp index 15c9aec430ff783b226e4dd2deda160ddf0ad4f2..4123caf6bed7137aba86e5901f428ddaa0674422 100644 --- a/MantidPlot/src/Mantid/MantidApplication.cpp +++ b/MantidPlot/src/Mantid/MantidApplication.cpp @@ -4,9 +4,10 @@ #include "MantidApplication.h" #include "MantidQtWidgets/Common/MantidDialog.h" +#include "MantidKernel/ConfigService.h" +#include "MantidKernel/CrashService.h" #include "MantidKernel/Logger.h" #include "MantidKernel/UsageService.h" -#include "MantidKernel/CrashService.h" #include <QMessageBox> #include <QPushButton> @@ -41,7 +42,7 @@ bool MantidApplication::notify(QObject *receiver, QEvent *event) { int reportingEnabled = 0; int retVal = Mantid::Kernel::ConfigService::Instance().getValue("usagereports.enabled", reportingEnabled); if (reportingEnabled && retVal == 1){ - Mantid::Kernel::CrashServiceImpl crashService("mantidplot"); + Mantid::Kernel::CrashServiceImpl crashService("mantidplot", Mantid::Kernel::UsageService::Instance().getStartTime()); crashService.sendCrashReport(); }