summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2022-02-02 19:07:19 +0000
committerAndras Timar <andras.timar@collabora.com>2022-02-03 14:21:50 +0100
commitf49590f2963f3fc8ce60917dad96af729b22edea (patch)
treeb0084dff1ba86497568e553380afb25d52a3cf81
parentBump package version to 6.4.18-1 (diff)
downloadonline-f49590f2963f3fc8ce60917dad96af729b22edea.tar.gz
online-f49590f2963f3fc8ce60917dad96af729b22edea.zip
Count and report on various internal exceptions.
An initial set of seven of these, easy to add more as/when needed. Change-Id: I6c65e052d00f9eaa10adee3c9464043e4c594848 Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
-rw-r--r--Makefile.am3
-rw-r--r--test/Makefile.am1
-rw-r--r--wsd/AdminModel.cpp10
-rw-r--r--wsd/Exceptions.cpp25
-rw-r--r--wsd/Exceptions.hpp54
-rw-r--r--wsd/metrics.txt10
6 files changed, 66 insertions, 37 deletions
diff --git a/Makefile.am b/Makefile.am
index 927a06ac9e..da835869c4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -109,7 +109,8 @@ shared_sources = common/FileUtil.cpp \
net/HttpRequest.cpp \
net/HttpHelper.cpp \
net/NetUtil.cpp \
- net/Socket.cpp
+ net/Socket.cpp \
+ wsd/Exceptions.cpp
if ENABLE_SSL
shared_sources += net/Ssl.cpp
endif
diff --git a/test/Makefile.am b/test/Makefile.am
index 992116803a..c097d34dce 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -95,6 +95,7 @@ common_sources = \
../common/Util.cpp \
../common/StringVector.cpp \
../common/TraceEvent.cpp \
+ ../wsd/Exceptions.cpp \
../net/HttpRequest.cpp \
../net/Socket.cpp \
../net/NetUtil.cpp \
diff --git a/wsd/AdminModel.cpp b/wsd/AdminModel.cpp
index 326def0718..a9feef77a9 100644
--- a/wsd/AdminModel.cpp
+++ b/wsd/AdminModel.cpp
@@ -23,6 +23,7 @@
#include <Unit.hpp>
#include <Util.hpp>
#include <wsd/LOOLWSD.hpp>
+#include <wsd/Exceptions.hpp>
#include <fnmatch.h>
#include <dirent.h>
@@ -1142,6 +1143,15 @@ void AdminModel::getMetrics(std::ostringstream &oss)
PrintDocActExpMetrics(oss, "wopi_download_duration", "milliseconds", docStats._wopiDownloadDuration);
oss << std::endl;
PrintDocActExpMetrics(oss, "view_load_duration", "milliseconds", docStats._viewLoadDuration);
+
+ oss << std::endl;
+ oss << "error_storage_space_low " << StorageSpaceLowException::count << "\n";
+ oss << "error_storage_connection " << StorageConnectionException::count << "\n";
+ oss << "error_bad_request " << (BadRequestException::count - BadArgumentException::count) << "\n";
+ oss << "error_bad_argument " << BadArgumentException::count << "\n";
+ oss << "error_unauthorized_request " << UnauthorizedRequestException::count << "\n";
+ oss << "error_service_unavailable " << ServiceUnavailableException::count << "\n";
+ oss << "error_parse_error " << ParseError::count << "\n";
}
std::set<pid_t> AdminModel::getDocumentPids() const
diff --git a/wsd/Exceptions.cpp b/wsd/Exceptions.cpp
new file mode 100644
index 0000000000..1a4804e9e3
--- /dev/null
+++ b/wsd/Exceptions.cpp
@@ -0,0 +1,25 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "Exceptions.hpp"
+
+#undef EXCEPTION_DECL
+
+// not beautiful
+#define EXCEPTION_DECL(type,unused) \
+ std::atomic<size_t> type::count;
+
+EXCEPTION_DECL(StorageSpaceLowException,LoolException)
+EXCEPTION_DECL(StorageConnectionException,LoolException)
+EXCEPTION_DECL(BadRequestException,LoolException)
+EXCEPTION_DECL(BadArgumentException,BadRequestException)
+EXCEPTION_DECL(UnauthorizedRequestException,LoolException)
+EXCEPTION_DECL(ServiceUnavailableException,LoolException)
+EXCEPTION_DECL(ParseError,LoolException)
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/wsd/Exceptions.hpp b/wsd/Exceptions.hpp
index 664edeaecf..3c8910be73 100644
--- a/wsd/Exceptions.hpp
+++ b/wsd/Exceptions.hpp
@@ -10,9 +10,20 @@
#pragma once
+#include <atomic>
#include <exception>
#include <stdexcept>
+// not beautiful
+#define EXCEPTION_DECL(type,parent_cl) \
+ class type : public parent_cl \
+ { \
+ public: \
+ static std::atomic<size_t> count; \
+ type(const std::string &str) : parent_cl(str) \
+ { type::count++; } \
+ };
+
// Generic LOOL errors and base for others.
class LoolException : public std::runtime_error
{
@@ -21,62 +32,33 @@ public:
{
return what();
}
-
protected:
using std::runtime_error::runtime_error;
};
-class StorageSpaceLowException : public LoolException
-{
-public:
- using LoolException::LoolException;
-};
+EXCEPTION_DECL(StorageSpaceLowException,LoolException)
/// General exception thrown when we are not able to
/// connect to storage.
-class StorageConnectionException : public LoolException
-{
-public:
- using LoolException::LoolException;
-};
+EXCEPTION_DECL(StorageConnectionException,LoolException)
/// A bad-request exception that is meant to signify,
/// and translate into, an HTTP bad request.
-class BadRequestException : public LoolException
-{
-public:
- using LoolException::LoolException;
-};
+EXCEPTION_DECL(BadRequestException,LoolException)
/// A bad-argument exception that is meant to signify,
/// and translate into, an HTTP bad request.
-class BadArgumentException : public BadRequestException
-{
-public:
- using BadRequestException::BadRequestException;
-};
+EXCEPTION_DECL(BadArgumentException,BadRequestException)
/// An authorization exception that is meant to signify,
/// and translate into, an HTTP unauthorized error.
-class UnauthorizedRequestException : public LoolException
-{
-public:
- using LoolException::LoolException;
-};
+EXCEPTION_DECL(UnauthorizedRequestException,LoolException)
/// A service-unavailable exception that is meant to signify
/// an internal error.
-class ServiceUnavailableException : public LoolException
-{
-public:
- using LoolException::LoolException;
-};
+EXCEPTION_DECL(ServiceUnavailableException,LoolException)
/// Badly formed data we are parsing
-class ParseError : public LoolException
-{
-public:
- using LoolException::LoolException;
-};
+EXCEPTION_DECL(ParseError,LoolException)
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/wsd/metrics.txt b/wsd/metrics.txt
index 09c0a13ef5..2b03e1efa2 100644
--- a/wsd/metrics.txt
+++ b/wsd/metrics.txt
@@ -161,3 +161,13 @@ DOCUMENT VIEW LOAD DURATION
document_expired_view_load_duration_average_seconds - average between the load duration of all views (active or expired) of each expired document.
document_expired_view_load_duration_min_seconds - minimum from the load duration of all views (active or expired) of each expired document.
document_expired_view_load_duration_max_seconds - maximum from the load duration of all views (active or expired) of each expired document.
+
+SELECTED ERRORS - all integer counts
+
+ error_storage_space_low - local storage space too low to operate
+ error_storage_connection - unable to connect to storage
+ error_bad_request - we returned an HTTP bad request to a caller
+ error_bad_argument - we returned an HTTP bad argument to a caller
+ error_unauthorized_request - an authorization exception usually on CheckFileInfo
+ error_service_unavailable - internal error, service is unavailable
+ error_parse_error - badly formed data provided for us to parse.