Skip to content
Snippets Groups Projects
Commit 3541dc60 authored by Matthew Andrew's avatar Matthew Andrew
Browse files

Re #21709 Added starttime tracking

parent 94b9ecc8
No related branches found
No related tags found
No related merge requests found
...@@ -36,6 +36,7 @@ namespace Kernel { ...@@ -36,6 +36,7 @@ namespace Kernel {
class MANTID_KERNEL_DLL CrashServiceImpl { class MANTID_KERNEL_DLL CrashServiceImpl {
public: public:
CrashServiceImpl(std::string application); CrashServiceImpl(std::string application);
CrashServiceImpl(std::string application, std::string startTime);
void sendCrashReport(); void sendCrashReport();
protected: protected:
...@@ -46,6 +47,7 @@ class MANTID_KERNEL_DLL CrashServiceImpl { ...@@ -46,6 +47,7 @@ class MANTID_KERNEL_DLL CrashServiceImpl {
private: private:
int sendCrashAsyncImpl(const std::string &message); int sendCrashAsyncImpl(const std::string &message);
const std::string m_application; const std::string m_application;
const std::string m_startTime;
/// Async method for sending startup notifications /// Async method for sending startup notifications
Poco::ActiveMethod<int, std::string, CrashServiceImpl> m_crashActiveMethod; Poco::ActiveMethod<int, std::string, CrashServiceImpl> m_crashActiveMethod;
}; };
......
...@@ -84,6 +84,8 @@ public: ...@@ -84,6 +84,8 @@ public:
/// flushes any buffers and sends any outstanding usage reports /// flushes any buffers and sends any outstanding usage reports
void flush(); void flush();
void shutdown(); void shutdown();
/// gets the uptime of this mantid instance
std::string getStartTime();
protected: protected:
/// Constructor /// Constructor
...@@ -131,6 +133,7 @@ private: ...@@ -131,6 +133,7 @@ private:
bool m_isEnabled; bool m_isEnabled;
mutable std::mutex m_mutex; mutable std::mutex m_mutex;
std::string m_application; std::string m_application;
std::string m_startTime;
/// Async method for sending startup notifications /// Async method for sending startup notifications
Poco::ActiveMethod<int, std::string, UsageServiceImpl> m_startupActiveMethod; Poco::ActiveMethod<int, std::string, UsageServiceImpl> m_startupActiveMethod;
......
...@@ -28,9 +28,10 @@ const std::string CRASH_URL("http://crashreports.mantidproject.org/api/crash"); ...@@ -28,9 +28,10 @@ const std::string CRASH_URL("http://crashreports.mantidproject.org/api/crash");
//---------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------
// Constructor for CrashServiceImpl // Constructor for CrashServiceImpl
CrashServiceImpl::CrashServiceImpl(std::string application) 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() { void CrashServiceImpl::sendCrashReport() {
try { try {
...@@ -73,6 +74,8 @@ std::string CrashServiceImpl::generateCrashMessage() { ...@@ -73,6 +74,8 @@ std::string CrashServiceImpl::generateCrashMessage() {
message["dateTime"] = message["dateTime"] =
Types::Core::DateAndTime::getCurrentTime().toISO8601String(); Types::Core::DateAndTime::getCurrentTime().toISO8601String();
message["startTime"] = m_startTime;
message["application"] = m_application; message["application"] = m_application;
message["facility"] = ConfigService::Instance().getFacility().name(); message["facility"] = ConfigService::Instance().getFacility().name();
......
...@@ -131,6 +131,10 @@ void UsageServiceImpl::flush() { ...@@ -131,6 +131,10 @@ void UsageServiceImpl::flush() {
} }
} }
std::string UsageServiceImpl::getStartTime() {
return m_startTime;
}
void UsageServiceImpl::shutdown() { void UsageServiceImpl::shutdown() {
try { try {
// stop the timer // stop the timer
...@@ -145,8 +149,8 @@ void UsageServiceImpl::shutdown() { ...@@ -145,8 +149,8 @@ void UsageServiceImpl::shutdown() {
void UsageServiceImpl::sendStartupReport() { void UsageServiceImpl::sendStartupReport() {
try { try {
m_startTime = Types::Core::DateAndTime::getCurrentTime().toISO8601String();
std::string message = this->generateStartupMessage(); std::string message = this->generateStartupMessage();
// send the report // send the report
Poco::ActiveResult<int> result = m_startupActiveMethod(message); Poco::ActiveResult<int> result = m_startupActiveMethod(message);
} catch (std::exception &ex) { } catch (std::exception &ex) {
...@@ -227,8 +231,7 @@ std::string UsageServiceImpl::generateStartupMessage() { ...@@ -227,8 +231,7 @@ std::string UsageServiceImpl::generateStartupMessage() {
message["mantidSha1"] = MantidVersion::revisionFull(); message["mantidSha1"] = MantidVersion::revisionFull();
// mantid version and sha1 // mantid version and sha1
message["dateTime"] = message["dateTime"] = m_startTime;
Types::Core::DateAndTime::getCurrentTime().toISO8601String();
message["application"] = m_application; message["application"] = m_application;
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
#include "MantidApplication.h" #include "MantidApplication.h"
#include "MantidQtWidgets/Common/MantidDialog.h" #include "MantidQtWidgets/Common/MantidDialog.h"
#include "MantidKernel/ConfigService.h"
#include "MantidKernel/CrashService.h"
#include "MantidKernel/Logger.h" #include "MantidKernel/Logger.h"
#include "MantidKernel/UsageService.h" #include "MantidKernel/UsageService.h"
#include "MantidKernel/CrashService.h"
#include <QMessageBox> #include <QMessageBox>
#include <QPushButton> #include <QPushButton>
...@@ -41,7 +42,7 @@ bool MantidApplication::notify(QObject *receiver, QEvent *event) { ...@@ -41,7 +42,7 @@ bool MantidApplication::notify(QObject *receiver, QEvent *event) {
int reportingEnabled = 0; int reportingEnabled = 0;
int retVal = Mantid::Kernel::ConfigService::Instance().getValue("usagereports.enabled", reportingEnabled); int retVal = Mantid::Kernel::ConfigService::Instance().getValue("usagereports.enabled", reportingEnabled);
if (reportingEnabled && retVal == 1){ if (reportingEnabled && retVal == 1){
Mantid::Kernel::CrashServiceImpl crashService("mantidplot"); Mantid::Kernel::CrashServiceImpl crashService("mantidplot", Mantid::Kernel::UsageService::Instance().getStartTime());
crashService.sendCrashReport(); crashService.sendCrashReport();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment