From 57d5744f2c064ccb7bf8dd3dca2a24f6755297ac Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 28 Jul 2017 14:07:25 -0700 Subject: MAINT-7634: Move StatsAccumulator into llcommon, collect data sent and error codes from core. --- indra/llcorehttp/httpstats.cpp | 82 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 indra/llcorehttp/httpstats.cpp (limited to 'indra/llcorehttp/httpstats.cpp') diff --git a/indra/llcorehttp/httpstats.cpp b/indra/llcorehttp/httpstats.cpp new file mode 100644 index 0000000000..467d364885 --- /dev/null +++ b/indra/llcorehttp/httpstats.cpp @@ -0,0 +1,82 @@ +/** + * @file llviewerstats.cpp + * @brief LLViewerStats class implementation + * + * $LicenseInfo:firstyear=2002&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "httpstats.h" +#include "llerror.h" + +namespace LLCore +{ +HTTPStats::HTTPStats() +{ + resetStats(); +} + + +HTTPStats::~HTTPStats() +{ +} + +void HTTPStats::resetStats() +{ + mResutCodes.clear(); + mDataDown.reset(); + mDataUp.reset(); +} + + +void HTTPStats::recordResultCode(S32 code) +{ + std::map::iterator it; + + it = mResutCodes.find(code); + + if (it == mResutCodes.end()) + mResutCodes[code] = 1; + else + (*it).second = (*it).second + 1; + +} + +void HTTPStats::dumpStats() +{ + std::stringstream out; + + out << "HTTPCore Stats" << std::endl; + out << "Bytes Sent: " << mDataUp.getSum() << std::endl; + out << "Bytes Recv: " << mDataDown.getSum() << std::endl; + out << "Result Codes:" << std::endl << "--- -----" << std::endl; + + + for (std::map::iterator it = mResutCodes.begin(); it != mResutCodes.end(); ++it) + { + out << (*it).first << " " << (*it).second << std::endl; + } + + LL_WARNS("HTTP Core") << out.str() << LL_ENDL; +} + + +} -- cgit v1.2.3 From 1038633526330cf931ba097dbafdd270b5bb56e3 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 8 Aug 2017 09:04:32 -0700 Subject: MAINT-7634: Logging and instrumentation canges to narrow down viewer crashes. --- indra/llcorehttp/httpstats.cpp | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'indra/llcorehttp/httpstats.cpp') diff --git a/indra/llcorehttp/httpstats.cpp b/indra/llcorehttp/httpstats.cpp index 467d364885..b2de7f51ff 100644 --- a/indra/llcorehttp/httpstats.cpp +++ b/indra/llcorehttp/httpstats.cpp @@ -44,6 +44,7 @@ void HTTPStats::resetStats() mResutCodes.clear(); mDataDown.reset(); mDataUp.reset(); + mRequests = 0; } @@ -60,16 +61,41 @@ void HTTPStats::recordResultCode(S32 code) } +namespace +{ + std::string byte_count_converter(F32 bytes) + { + static const char unit_suffix[] = { 'B', 'K', 'M', 'G' }; + + F32 value = bytes; + int suffix = 0; + + while ((value > 1024.0) && (suffix < 3)) + { + value /= 1024.0; + ++suffix; + } + + std::stringstream out; + + out << std::setprecision(4) << value << unit_suffix[suffix]; + + return out.str(); + } +} + void HTTPStats::dumpStats() { std::stringstream out; - out << "HTTPCore Stats" << std::endl; - out << "Bytes Sent: " << mDataUp.getSum() << std::endl; - out << "Bytes Recv: " << mDataDown.getSum() << std::endl; + out << "HTTP DATA SUMMARY" << std::endl; + out << "HTTP Transfer counts:" << std::endl; + out << "Data Sent: " << byte_count_converter(mDataUp.getSum()) << " (" << mDataUp.getSum() << ")" << std::endl; + out << "Data Recv: " << byte_count_converter(mDataDown.getSum()) << " (" << mDataDown.getSum() << ")" << std::endl; + out << "Total requests: " << mRequests << "(request objects created)" << std::endl; + out << std::endl; out << "Result Codes:" << std::endl << "--- -----" << std::endl; - for (std::map::iterator it = mResutCodes.begin(); it != mResutCodes.end(); ++it) { out << (*it).first << " " << (*it).second << std::endl; -- cgit v1.2.3