mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 17:03:58 +02:00
Fix bytes downloaded stat tracking
This commit is contained in:
parent
3500705d0c
commit
014a7bc9b0
10 changed files with 37 additions and 21 deletions
|
@ -1628,12 +1628,14 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
properties["throttled"] = _displayPlugin ? _displayPlugin->isThrottled() : false;
|
||||
|
||||
QJsonObject bytesDownloaded;
|
||||
bytesDownloaded["atp"] = statTracker->getStat(STAT_ATP_RESOURCE_TOTAL_BYTES).toInt();
|
||||
bytesDownloaded["http"] = statTracker->getStat(STAT_HTTP_RESOURCE_TOTAL_BYTES).toInt();
|
||||
bytesDownloaded["file"] = statTracker->getStat(STAT_FILE_RESOURCE_TOTAL_BYTES).toInt();
|
||||
bytesDownloaded["total"] = bytesDownloaded["atp"].toInt() + bytesDownloaded["http"].toInt()
|
||||
+ bytesDownloaded["file"].toInt();
|
||||
properties["bytesDownloaded"] = bytesDownloaded;
|
||||
auto atpBytes = statTracker->getStat(STAT_ATP_RESOURCE_TOTAL_BYTES).toLongLong();
|
||||
auto httpBytes = statTracker->getStat(STAT_HTTP_RESOURCE_TOTAL_BYTES).toLongLong();
|
||||
auto fileBytes = statTracker->getStat(STAT_FILE_RESOURCE_TOTAL_BYTES).toLongLong();
|
||||
bytesDownloaded["atp"] = atpBytes;
|
||||
bytesDownloaded["http"] = httpBytes;
|
||||
bytesDownloaded["file"] = fileBytes;
|
||||
bytesDownloaded["total"] = atpBytes + httpBytes + fileBytes;
|
||||
properties["bytes_downloaded"] = bytesDownloaded;
|
||||
|
||||
auto myAvatar = getMyAvatar();
|
||||
glm::vec3 avatarPosition = myAvatar->getPosition();
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <NetworkLogging.h>
|
||||
#include <NodeList.h>
|
||||
#include <OffscreenUi.h>
|
||||
#include <UserActivityLogger.h>
|
||||
|
||||
static const int AUTO_REFRESH_INTERVAL = 1000;
|
||||
|
||||
|
|
|
@ -155,6 +155,7 @@ void AssetResourceRequest::requestHash(const AssetHash& hash) {
|
|||
case AssetRequest::Error::NoError:
|
||||
_data = req->getData();
|
||||
_result = Success;
|
||||
recordBytesDownloadedInStats(STAT_ATP_RESOURCE_TOTAL_BYTES, _data.size());
|
||||
break;
|
||||
case AssetRequest::InvalidHash:
|
||||
_result = InvalidURL;
|
||||
|
@ -202,9 +203,8 @@ void AssetResourceRequest::onDownloadProgress(qint64 bytesReceived, qint64 bytes
|
|||
emit progress(bytesReceived, bytesTotal);
|
||||
|
||||
auto now = p_high_resolution_clock::now();
|
||||
|
||||
// Recording ATP bytes downloaded in stats
|
||||
DependencyManager::get<StatTracker>()->updateStat(STAT_ATP_RESOURCE_TOTAL_BYTES, bytesReceived);
|
||||
|
||||
recordBytesDownloadedInStats(STAT_ATP_RESOURCE_TOTAL_BYTES, bytesReceived);
|
||||
|
||||
// if we haven't received the full asset check if it is time to output progress to log
|
||||
// we do so every X seconds to assist with ATP download tracking
|
||||
|
|
|
@ -41,6 +41,8 @@ private:
|
|||
AssetRequest* _assetRequest { nullptr };
|
||||
|
||||
p_high_resolution_clock::time_point _lastProgressDebug;
|
||||
|
||||
int64_t _lastRecordedBytesDownloaded { 0 };
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -69,8 +69,7 @@ void FileResourceRequest::doSend() {
|
|||
|
||||
if (_result == ResourceRequest::Success) {
|
||||
statTracker->incrementStat(STAT_FILE_REQUEST_SUCCESS);
|
||||
// Recording FILE bytes downloaded in stats
|
||||
statTracker->updateStat(STAT_FILE_RESOURCE_TOTAL_BYTES,fileSize);
|
||||
statTracker->updateStat(STAT_FILE_RESOURCE_TOTAL_BYTES, fileSize);
|
||||
} else {
|
||||
statTracker->incrementStat(STAT_FILE_REQUEST_FAILED);
|
||||
}
|
||||
|
|
|
@ -141,6 +141,8 @@ void HTTPResourceRequest::onRequestFinished() {
|
|||
}
|
||||
}
|
||||
|
||||
recordBytesDownloadedInStats(STAT_HTTP_RESOURCE_TOTAL_BYTES, _data.size());
|
||||
|
||||
break;
|
||||
|
||||
case QNetworkReply::TimeoutError:
|
||||
|
@ -201,11 +203,8 @@ void HTTPResourceRequest::onDownloadProgress(qint64 bytesReceived, qint64 bytesT
|
|||
_sendTimer->start();
|
||||
|
||||
emit progress(bytesReceived, bytesTotal);
|
||||
|
||||
// Recording HTTP bytes downloaded in stats
|
||||
DependencyManager::get<StatTracker>()->updateStat(STAT_HTTP_RESOURCE_TOTAL_BYTES, bytesReceived);
|
||||
|
||||
|
||||
|
||||
recordBytesDownloadedInStats(STAT_HTTP_RESOURCE_TOTAL_BYTES, bytesReceived);
|
||||
}
|
||||
|
||||
void HTTPResourceRequest::onTimeout() {
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
|
||||
#include "ResourceRequest.h"
|
||||
|
||||
#include <DependencyManager.h>
|
||||
#include <StatTracker.h>
|
||||
|
||||
#include <QtCore/QThread>
|
||||
|
||||
ResourceRequest::ResourceRequest(const QUrl& url) : _url(url) { }
|
||||
|
@ -40,3 +43,11 @@ QString ResourceRequest::getResultString() const {
|
|||
default: return "Unspecified Error";
|
||||
}
|
||||
}
|
||||
|
||||
void ResourceRequest::recordBytesDownloadedInStats(const QString& statName, int64_t bytesReceived) {
|
||||
auto dBytes = bytesReceived - _lastRecordedBytesDownloaded;
|
||||
if (dBytes > 0) {
|
||||
_lastRecordedBytesDownloaded = bytesReceived;
|
||||
DependencyManager::get<StatTracker>()->updateStat(statName, dBytes);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,6 +85,7 @@ signals:
|
|||
|
||||
protected:
|
||||
virtual void doSend() = 0;
|
||||
void recordBytesDownloadedInStats(const QString& statName, int64_t bytesReceived);
|
||||
|
||||
QUrl _url;
|
||||
QUrl _relativePathURL;
|
||||
|
@ -97,6 +98,7 @@ protected:
|
|||
ByteRange _byteRange;
|
||||
bool _rangeRequestSuccessful { false };
|
||||
uint64_t _totalSizeOfResource { 0 };
|
||||
int64_t _lastRecordedBytesDownloaded { 0 };
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -17,12 +17,12 @@ QVariant StatTracker::getStat(const QString& name) {
|
|||
return _stats[name];
|
||||
}
|
||||
|
||||
void StatTracker::setStat(const QString& name, int value) {
|
||||
void StatTracker::setStat(const QString& name, int64_t value) {
|
||||
Lock lock(_statsLock);
|
||||
_stats[name] = value;
|
||||
}
|
||||
|
||||
void StatTracker::updateStat(const QString& name, int value) {
|
||||
void StatTracker::updateStat(const QString& name, int64_t value) {
|
||||
Lock lock(_statsLock);
|
||||
auto itr = _stats.find(name);
|
||||
if (_stats.end() == itr) {
|
||||
|
|
|
@ -24,15 +24,15 @@ class StatTracker : public Dependency {
|
|||
public:
|
||||
StatTracker();
|
||||
QVariant getStat(const QString& name);
|
||||
void setStat(const QString& name, int value);
|
||||
void updateStat(const QString& name, int mod);
|
||||
void setStat(const QString& name, int64_t value);
|
||||
void updateStat(const QString& name, int64_t mod);
|
||||
void incrementStat(const QString& name);
|
||||
void decrementStat(const QString& name);
|
||||
private:
|
||||
using Mutex = std::mutex;
|
||||
using Lock = std::lock_guard<Mutex>;
|
||||
Mutex _statsLock;
|
||||
QHash<QString, int> _stats;
|
||||
QHash<QString, int64_t> _stats;
|
||||
};
|
||||
|
||||
class CounterStat {
|
||||
|
|
Loading…
Reference in a new issue