Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(494)

Side by Side Diff: sql/connection.cc

Issue 14439007: Deeper histogram for SQLITE_IOERR. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebaseline Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "sql/connection.h" 5 #include "sql/connection.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 else 707 else
708 open_statements_.erase(i); 708 open_statements_.erase(i);
709 } 709 }
710 710
711 int Connection::OnSqliteError(int err, sql::Statement *stmt) { 711 int Connection::OnSqliteError(int err, sql::Statement *stmt) {
712 // Strip extended error codes. 712 // Strip extended error codes.
713 int base_err = err&0xff; 713 int base_err = err&0xff;
714 714
715 static size_t kSqliteErrorMax = 50; 715 static size_t kSqliteErrorMax = 50;
716 UMA_HISTOGRAM_ENUMERATION("Sqlite.Error", base_err, kSqliteErrorMax); 716 UMA_HISTOGRAM_ENUMERATION("Sqlite.Error", base_err, kSqliteErrorMax);
717 if (base_err == SQLITE_IOERR) {
718 // TODO(shess): Consider folding the IOERR range into the main
719 // histogram directly. Perhaps 30..49? The downside risk would
720 // be that SQLite core adds a bunch of codes and this becomes a
721 // complicated mapping.
722 static size_t kSqliteIOErrorMax = 20;
723 UMA_HISTOGRAM_ENUMERATION("Sqlite.Error.IOERR", err>>8, kSqliteIOErrorMax);
724 }
725
717 if (!error_histogram_name_.empty()) { 726 if (!error_histogram_name_.empty()) {
718 // TODO(shess): The histogram macros create a bit of static 727 // TODO(shess): The histogram macros create a bit of static
719 // storage for caching the histogram object. Since SQLite is 728 // storage for caching the histogram object. Since SQLite is
720 // being used for I/O, generally without error, this code 729 // being used for I/O, generally without error, this code
721 // shouldn't execute often enough for such caching to be crucial. 730 // shouldn't execute often enough for such caching to be crucial.
722 // If it becomes an issue, the object could be cached alongside 731 // If it becomes an issue, the object could be cached alongside
723 // error_histogram_name_. 732 // error_histogram_name_.
724 base::HistogramBase* histogram = 733 base::HistogramBase* histogram =
725 base::LinearHistogram::FactoryGet( 734 base::LinearHistogram::FactoryGet(
726 error_histogram_name_, 1, kSqliteErrorMax, kSqliteErrorMax + 1, 735 error_histogram_name_, 1, kSqliteErrorMax, kSqliteErrorMax + 1,
727 base::HistogramBase::kUmaTargetedHistogramFlag); 736 base::HistogramBase::kUmaTargetedHistogramFlag);
728 if (histogram) 737 if (histogram)
729 histogram->Add(base_err); 738 histogram->Add(base_err);
730 } 739 }
731 740
732 // Always log the error. 741 // Always log the error.
733 LOG(ERROR) << "sqlite error " << err 742 LOG(ERROR) << "sqlite error " << err
734 << ", errno " << GetLastErrno() 743 << ", errno " << GetLastErrno()
735 << ": " << GetErrorMessage(); 744 << ": " << GetErrorMessage();
736 745
737 if (error_delegate_.get()) 746 if (error_delegate_.get())
738 return error_delegate_->OnError(err, this, stmt); 747 return error_delegate_->OnError(err, this, stmt);
739 748
740 // The default handling is to assert on debug and to ignore on release. 749 // The default handling is to assert on debug and to ignore on release.
741 DLOG(FATAL) << GetErrorMessage(); 750 DLOG(FATAL) << GetErrorMessage();
742 return err; 751 return err;
743 } 752 }
744 753
745 } // namespace sql 754 } // namespace sql
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698