Mantid
|
#include <UsageService.h>
Public Member Functions | |
void | clear () |
clear any buffers without sending any outstanding usage reports More... | |
void | flush () |
flushes any buffers and sends any outstanding usage reports More... | |
std::string | getApplicationName () const |
Returns the application name that has invoked Mantid. More... | |
Types::Core::DateAndTime | getStartTime () |
Gets the start time of this mantid instance. More... | |
Types::Core::time_duration | getUpTime () |
gets the uptime of this mantid instance More... | |
bool | isEnabled () const |
Returns true if usage reporting is enabled. More... | |
void | registerFeatureUsage (const FeatureType &type, const std::string &name, const bool internal) |
Version that takes a string if just registering usage of a class. More... | |
void | registerFeatureUsage (const FeatureType &type, const std::vector< std::string > &name, const bool internal) |
registerFeatureUsage registers the use of a feature in mantid. More... | |
void | registerFeatureUsage (const FeatureType &type, std::initializer_list< std::string > name, const bool internal) |
Version that accepts an initializer list. More... | |
void | registerStartup () |
Registers the Startup of Mantid. More... | |
void | setApplicationName (const std::string &name) |
Sets the application name that has invoked Mantid. More... | |
void | setEnabled (const bool enabled) |
Sets whether the UsageReporter is enabled. More... | |
void | setInterval (const uint32_t seconds=60) |
Sets the interval that the timer checks for tasks. More... | |
void | shutdown () |
Protected Member Functions | |
virtual std::string | generateFeatureUsageMessage () |
generates the message body for a feature usage message More... | |
virtual std::string | generateStartupMessage () |
generates the message body for a startup message More... | |
virtual Kernel::InternetHelper::HTTPStatus | sendReport (const std::string &message, const std::string &url) |
sends a report over the internet More... | |
UsageServiceImpl () | |
Constructor. More... | |
virtual | ~UsageServiceImpl ()=default |
Destructor. More... | |
Private Member Functions | |
::Json::Value | generateFeatureHeader () |
This puts together the system information for the json document. More... | |
UsageServiceImpl & | operator= (const UsageServiceImpl &) |
Private, unimplemented copy assignment operator. More... | |
InternetHelper::HTTPStatus | sendFeatureAsyncImpl (const std::string &message) |
Async method for sending feature messages. More... | |
void | sendFeatureUsageReport (const bool synchronous) |
Send featureUsageReport. More... | |
InternetHelper::HTTPStatus | sendStartupAsyncImpl (const std::string &message) |
Asynchronous execution. More... | |
void | sendStartupReport () |
Send startup Report. More... | |
void | timerCallback (Poco::Timer &) |
A method to handle the timerCallbacks. More... | |
UsageServiceImpl (const UsageServiceImpl &) | |
Private, unimplemented copy constructor. More... | |
Private Attributes | |
std::string | m_application |
Poco::ActiveMethod< InternetHelper::HTTPStatus, std::string, UsageServiceImpl > | m_featureActiveMethod |
Async method for sending feature notifications. More... | |
std::queue< FeatureUsage > | m_FeatureQueue |
size_t | m_FeatureQueueSizeThreshold |
bool | m_isEnabled |
std::mutex | m_mutex |
Types::Core::DateAndTime | m_startTime |
Poco::ActiveMethod< InternetHelper::HTTPStatus, std::string, UsageServiceImpl > | m_startupActiveMethod |
Async method for sending startup notifications. More... | |
Poco::Timer | m_timer |
a timer More... | |
uint32_t | m_timerTicks |
The number of timer ticks since the last reset. More... | |
uint32_t | m_timerTicksTarget |
The number of timer ticks at which to reset. More... | |
std::string | m_url |
Stores the base url of the usage system. More... | |
Friends | |
struct | Mantid::Kernel::CreateUsingNew< UsageServiceImpl > |
Definition at line 58 of file UsageService.h.
|
protected |
Constructor.
Constructor for UsageServiceImpl.
Definition at line 89 of file UsageService.cpp.
References Mantid::Kernel::Logger::debug(), Mantid::Kernel::DateAndTimeHelpers::g_log, Mantid::Kernel::SingletonHolder< T >::Instance(), m_url, and setInterval().
|
protectedvirtualdefault |
Destructor.
|
private |
Private, unimplemented copy constructor.
void Mantid::Kernel::UsageServiceImpl::clear | ( | ) |
clear any buffers without sending any outstanding usage reports
Definition at line 160 of file UsageService.cpp.
References m_FeatureQueue.
void Mantid::Kernel::UsageServiceImpl::flush | ( | ) |
flushes any buffers and sends any outstanding usage reports
Definition at line 165 of file UsageService.cpp.
References isEnabled(), and sendFeatureUsageReport().
Referenced by export_UsageService().
|
private |
This puts together the system information for the json document.
Definition at line 232 of file UsageService.cpp.
References Mantid::Kernel::MantidVersion::versionShort().
Referenced by generateFeatureUsageMessage().
|
protectedvirtual |
generates the message body for a feature usage message
Definition at line 273 of file UsageService.cpp.
References generateFeatureHeader(), m_FeatureQueue, and m_mutex.
Referenced by sendFeatureUsageReport().
|
protectedvirtual |
generates the message body for a startup message
This puts together the system information for the json document.
Definition at line 244 of file UsageService.cpp.
References Mantid::Kernel::SingletonHolder< T >::Instance(), m_application, m_startTime, Mantid::Kernel::ChecksumHelper::md5FromString(), Mantid::Kernel::MantidVersion::revisionFull(), and Mantid::Kernel::MantidVersion::version().
Referenced by sendStartupReport().
std::string Mantid::Kernel::UsageServiceImpl::getApplicationName | ( | ) | const |
Returns the application name that has invoked Mantid.
Definition at line 106 of file UsageService.cpp.
References m_application.
Referenced by export_UsageService(), and registerFeatureUsage().
|
inline |
Gets the start time of this mantid instance.
Definition at line 93 of file UsageService.h.
Referenced by export_UsageService().
Types::Core::time_duration Mantid::Kernel::UsageServiceImpl::getUpTime | ( | ) |
gets the uptime of this mantid instance
getUpTime returns the time for which the mantid instance has been running
Definition at line 174 of file UsageService.cpp.
References m_startTime.
Referenced by export_UsageService().
bool Mantid::Kernel::UsageServiceImpl::isEnabled | ( | ) | const |
Returns true if usage reporting is enabled.
Definition at line 147 of file UsageService.cpp.
References m_isEnabled.
Referenced by export_UsageService(), flush(), registerFeatureUsage(), and registerStartup().
|
private |
Private, unimplemented copy assignment operator.
void Mantid::Kernel::UsageServiceImpl::registerFeatureUsage | ( | const FeatureType & | type, |
const std::string & | name, | ||
const bool | internal | ||
) |
Version that takes a string if just registering usage of a class.
Definition at line 134 of file UsageService.cpp.
References getApplicationName(), isEnabled(), m_FeatureQueue, and m_mutex.
void Mantid::Kernel::UsageServiceImpl::registerFeatureUsage | ( | const FeatureType & | type, |
const std::vector< std::string > & | name, | ||
const bool | internal | ||
) |
registerFeatureUsage registers the use of a feature in mantid.
registerFeatureUsage
Provide three overloads: Version that takes vector of strings if want to register usage of a particular class/method combination
Definition at line 124 of file UsageService.cpp.
References getApplicationName(), isEnabled(), m_FeatureQueue, and m_mutex.
Referenced by registerFeatureUsage().
void Mantid::Kernel::UsageServiceImpl::registerFeatureUsage | ( | const FeatureType & | type, |
std::initializer_list< std::string > | name, | ||
const bool | internal | ||
) |
Version that accepts an initializer list.
This is required because {"abc","def"} is both a valid constructor for std::string and an initializer list so without this it's not clear which overload is being called
Definition at line 141 of file UsageService.cpp.
References registerFeatureUsage().
void Mantid::Kernel::UsageServiceImpl::registerStartup | ( | ) |
Registers the Startup of Mantid.
Definition at line 116 of file UsageService.cpp.
References isEnabled(), and sendStartupReport().
Referenced by export_UsageService().
|
private |
Async method for sending feature messages.
Definition at line 321 of file UsageService.cpp.
References m_url, and sendReport().
Referenced by sendFeatureUsageReport().
|
private |
Send featureUsageReport.
Definition at line 199 of file UsageService.cpp.
References Mantid::Kernel::Logger::debug(), Mantid::Kernel::DateAndTimeHelpers::g_log, generateFeatureUsageMessage(), m_featureActiveMethod, and sendFeatureAsyncImpl().
Referenced by flush(), shutdown(), and timerCallback().
|
protectedvirtual |
sends a report over the internet
Definition at line 325 of file UsageService.cpp.
References Mantid::Kernel::InternetHelper::BAD_REQUEST, Mantid::Kernel::Exception::InternetError::errorCode(), Mantid::Kernel::DateAndTimeHelpers::g_log, Mantid::Kernel::Logger::information(), Mantid::Kernel::InternetHelper::sendRequest(), Mantid::Kernel::InternetHelper::setBody(), Mantid::Kernel::InternetHelper::setTimeout(), and Mantid::Kernel::Exception::InternetError::what().
Referenced by sendFeatureAsyncImpl(), and sendStartupAsyncImpl().
|
private |
Asynchronous execution.
Async method for sending startup messages
Definition at line 315 of file UsageService.cpp.
References m_url, and sendReport().
|
private |
Send startup Report.
Definition at line 189 of file UsageService.cpp.
References Mantid::Kernel::Logger::debug(), Mantid::Kernel::DateAndTimeHelpers::g_log, generateStartupMessage(), and m_startupActiveMethod.
Referenced by registerStartup(), and timerCallback().
void Mantid::Kernel::UsageServiceImpl::setApplicationName | ( | const std::string & | name | ) |
Sets the application name that has invoked Mantid.
Definition at line 104 of file UsageService.cpp.
References m_application.
Referenced by export_UsageService().
void Mantid::Kernel::UsageServiceImpl::setEnabled | ( | const bool | enabled | ) |
Sets whether the UsageReporter is enabled.
Definition at line 149 of file UsageService.cpp.
References m_isEnabled, m_timer, and timerCallback().
Referenced by export_UsageService(), and shutdown().
void Mantid::Kernel::UsageServiceImpl::setInterval | ( | const uint32_t | seconds = 60 | ) |
Sets the interval that the timer checks for tasks.
Definition at line 108 of file UsageService.cpp.
References m_timer, and m_timerTicksTarget.
Referenced by UsageServiceImpl().
void Mantid::Kernel::UsageServiceImpl::shutdown | ( | ) |
Definition at line 178 of file UsageService.cpp.
References Mantid::Kernel::Logger::error(), Mantid::Kernel::DateAndTimeHelpers::g_log, sendFeatureUsageReport(), and setEnabled().
Referenced by export_UsageService().
|
private |
A method to handle the timerCallbacks.
Definition at line 215 of file UsageService.cpp.
References m_FeatureQueue, m_FeatureQueueSizeThreshold, m_timerTicks, m_timerTicksTarget, sendFeatureUsageReport(), and sendStartupReport().
Referenced by setEnabled().
|
friend |
Definition at line 105 of file UsageService.h.
|
private |
Definition at line 140 of file UsageService.h.
Referenced by generateStartupMessage(), getApplicationName(), and setApplicationName().
|
private |
Async method for sending feature notifications.
Definition at line 146 of file UsageService.h.
Referenced by sendFeatureUsageReport().
|
private |
Definition at line 136 of file UsageService.h.
Referenced by clear(), generateFeatureUsageMessage(), registerFeatureUsage(), and timerCallback().
|
private |
Definition at line 137 of file UsageService.h.
Referenced by timerCallback().
|
private |
Definition at line 138 of file UsageService.h.
Referenced by isEnabled(), and setEnabled().
|
mutableprivate |
Definition at line 139 of file UsageService.h.
Referenced by generateFeatureUsageMessage(), and registerFeatureUsage().
|
private |
Definition at line 141 of file UsageService.h.
Referenced by generateStartupMessage(), and getUpTime().
|
private |
Async method for sending startup notifications.
Definition at line 144 of file UsageService.h.
Referenced by sendStartupReport().
|
private |
a timer
Definition at line 129 of file UsageService.h.
Referenced by setEnabled(), and setInterval().
|
private |
The number of timer ticks since the last reset.
Definition at line 132 of file UsageService.h.
Referenced by timerCallback().
|
private |
The number of timer ticks at which to reset.
Definition at line 134 of file UsageService.h.
Referenced by setInterval(), and timerCallback().
|
private |
Stores the base url of the usage system.
Definition at line 149 of file UsageService.h.
Referenced by sendFeatureAsyncImpl(), sendStartupAsyncImpl(), and UsageServiceImpl().