diff options
author | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-15 09:10:39 +0000 |
---|---|---|
committer | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-15 09:10:39 +0000 |
commit | 210ce0afe2a62a3d902b30bec98e31606e12132c (patch) | |
tree | 94d576b989e5ecd784ce19676bfca0aef3959399 /sql/connection.cc | |
parent | 0b0032accd7d6b8034bfb7380b4c524ab286c412 (diff) | |
download | chromium_src-210ce0afe2a62a3d902b30bec98e31606e12132c.zip chromium_src-210ce0afe2a62a3d902b30bec98e31606e12132c.tar.gz chromium_src-210ce0afe2a62a3d902b30bec98e31606e12132c.tar.bz2 |
Histogram versions and extended error codes for SQLite databases.
Track database versions across the fleet for purposes of making
decisions about whether old migration code can be removed.
As part of this, refactor histogram code to key off a
per-database tag rather than histogram name, and to log in a
form which can be fanned out via the field trial logic in
histograms.xml
[FYI michaeln from webkit/OWNERS, erikwright from {chrome,content}/net/OWNERS, sky for chrome/browser/history/OWNERS]
BUG=none
TBR=michaeln@chromium.org, erikwright@chromium.org, sky@chromium.org
Review URL: https://chromiumcodereview.appspot.com/14976003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200216 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sql/connection.cc')
-rw-r--r-- | sql/connection.cc | 49 |
1 files changed, 21 insertions, 28 deletions
diff --git a/sql/connection.cc b/sql/connection.cc index 29708e4..54aeb89 100644 --- a/sql/connection.cc +++ b/sql/connection.cc @@ -9,6 +9,7 @@ #include "base/files/file_path.h" #include "base/logging.h" #include "base/metrics/histogram.h" +#include "base/metrics/sparse_histogram.h" #include "base/string_util.h" #include "base/stringprintf.h" #include "base/utf_string_conversions.h" @@ -708,35 +709,27 @@ void Connection::StatementRefDeleted(StatementRef* ref) { open_statements_.erase(i); } +void Connection::AddTaggedHistogram(const std::string& name, + size_t sample) const { + if (histogram_tag_.empty()) + return; + + // TODO(shess): The histogram macros create a bit of static storage + // for caching the histogram object. This code shouldn't execute + // often enough for such caching to be crucial. If it becomes an + // issue, the object could be cached alongside histogram_prefix_. + std::string full_histogram_name = name + "." + histogram_tag_; + base::HistogramBase* histogram = + base::SparseHistogram::FactoryGet( + full_histogram_name, + base::HistogramBase::kUmaTargetedHistogramFlag); + if (histogram) + histogram->Add(sample); +} + int Connection::OnSqliteError(int err, sql::Statement *stmt) { - // Strip extended error codes. - int base_err = err&0xff; - - static size_t kSqliteErrorMax = 50; - UMA_HISTOGRAM_ENUMERATION("Sqlite.Error", base_err, kSqliteErrorMax); - if (base_err == SQLITE_IOERR) { - // TODO(shess): Consider folding the IOERR range into the main - // histogram directly. Perhaps 30..49? The downside risk would - // be that SQLite core adds a bunch of codes and this becomes a - // complicated mapping. - static size_t kSqliteIOErrorMax = 20; - UMA_HISTOGRAM_ENUMERATION("Sqlite.Error.IOERR", err>>8, kSqliteIOErrorMax); - } - - if (!error_histogram_name_.empty()) { - // TODO(shess): The histogram macros create a bit of static - // storage for caching the histogram object. Since SQLite is - // being used for I/O, generally without error, this code - // shouldn't execute often enough for such caching to be crucial. - // If it becomes an issue, the object could be cached alongside - // error_histogram_name_. - base::HistogramBase* histogram = - base::LinearHistogram::FactoryGet( - error_histogram_name_, 1, kSqliteErrorMax, kSqliteErrorMax + 1, - base::HistogramBase::kUmaTargetedHistogramFlag); - if (histogram) - histogram->Add(base_err); - } + UMA_HISTOGRAM_SPARSE_SLOWLY("Sqlite.Error", err); + AddTaggedHistogram("Sqlite.Error", err); // Always log the error. LOG(ERROR) << "sqlite error " << err |