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

Side by Side Diff: components/metrics/metrics_service.cc

Issue 580093004: Reset some UMA stability stats on a version change. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 //------------------------------------------------------------------------------ 5 //------------------------------------------------------------------------------
6 // Description of the life cycle of a instance of MetricsService. 6 // Description of the life cycle of a instance of MetricsService.
7 // 7 //
8 // OVERVIEW 8 // OVERVIEW
9 // 9 //
10 // A MetricsService instance is typically created at application startup. It is 10 // A MetricsService instance is typically created at application startup. It is
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 551
552 //------------------------------------------------------------------------------ 552 //------------------------------------------------------------------------------
553 // private methods 553 // private methods
554 //------------------------------------------------------------------------------ 554 //------------------------------------------------------------------------------
555 555
556 556
557 //------------------------------------------------------------------------------ 557 //------------------------------------------------------------------------------
558 // Initialization methods 558 // Initialization methods
559 559
560 void MetricsService::InitializeMetricsState() { 560 void MetricsService::InitializeMetricsState() {
561 local_state_->SetString(metrics::prefs::kStabilityStatsVersion, 561 const int64 buildtime = MetricsLog::GetBuildTime();
562 client_->GetVersionString()); 562 const std::string version = client_->GetVersionString();
563 local_state_->SetInt64(metrics::prefs::kStabilityStatsBuildTime, 563 bool version_changed = false;
564 MetricsLog::GetBuildTime()); 564 if (local_state_->GetInt64(prefs::kStabilityStatsBuildTime) != buildtime ||
565 local_state_->GetString(prefs::kStabilityStatsVersion) != version) {
566 local_state_->SetString(metrics::prefs::kStabilityStatsVersion, version);
567 local_state_->SetInt64(metrics::prefs::kStabilityStatsBuildTime, buildtime);
568 version_changed = true;
569 }
565 570
566 log_manager_.LoadPersistedUnsentLogs(); 571 log_manager_.LoadPersistedUnsentLogs();
567 572
568 session_id_ = local_state_->GetInteger(metrics::prefs::kMetricsSessionID); 573 session_id_ = local_state_->GetInteger(metrics::prefs::kMetricsSessionID);
569 574
570 if (!clean_exit_beacon_.exited_cleanly()) { 575 if (!clean_exit_beacon_.exited_cleanly()) {
571 IncrementPrefValue(metrics::prefs::kStabilityCrashCount); 576 IncrementPrefValue(metrics::prefs::kStabilityCrashCount);
572 // Reset flag, and wait until we call LogNeedForCleanShutdown() before 577 // Reset flag, and wait until we call LogNeedForCleanShutdown() before
573 // monitoring. 578 // monitoring.
574 clean_exit_beacon_.WriteBeaconValue(true); 579 clean_exit_beacon_.WriteBeaconValue(true);
575 } 580 }
576 581
577 if (!clean_exit_beacon_.exited_cleanly() || ProvidersHaveStabilityMetrics()) { 582 if (!clean_exit_beacon_.exited_cleanly() || ProvidersHaveStabilityMetrics()) {
578 // TODO(rtenneti): On windows, consider saving/getting execution_phase from 583 // TODO(rtenneti): On windows, consider saving/getting execution_phase from
579 // the registry. 584 // the registry.
580 int execution_phase = 585 int execution_phase =
581 local_state_->GetInteger(metrics::prefs::kStabilityExecutionPhase); 586 local_state_->GetInteger(metrics::prefs::kStabilityExecutionPhase);
582 UMA_HISTOGRAM_SPARSE_SLOWLY("Chrome.Browser.CrashedExecutionPhase", 587 UMA_HISTOGRAM_SPARSE_SLOWLY("Chrome.Browser.CrashedExecutionPhase",
583 execution_phase); 588 execution_phase);
584 589
585 // If the previous session didn't exit cleanly, or if any provider 590 // If the previous session didn't exit cleanly, or if any provider
586 // explicitly requests it, prepare an initial stability log - 591 // explicitly requests it, prepare an initial stability log -
587 // provided UMA is enabled. 592 // provided UMA is enabled.
588 if (state_manager_->IsMetricsReportingEnabled()) 593 if (state_manager_->IsMetricsReportingEnabled())
589 PrepareInitialStabilityLog(); 594 PrepareInitialStabilityLog();
590 } 595 }
591 596
597 // If no initial stability log was generated and there was a version upgrade,
598 // reset stability stats from the previous version.
Ilya Sherman 2014/09/18 18:30:20 nit: I'd go into a bit more detail here on why thi
Alexei Svitkine (slow) 2014/09/18 20:21:14 Done.
599 if (!has_initial_stability_log_ && version_changed) {
600 for (size_t i = 0; i < metrics_providers_.size(); ++i)
601 metrics_providers_[i]->ClearSavedStabilityMetrics();
602
603 // Reset the prefs that are managed by MetricsService/MetricsLog directly.
604 local_state_->SetInteger(prefs::kStabilityCrashCount, 0);
605 local_state_->SetInteger(prefs::kStabilityExecutionPhase,
606 UNINITIALIZED_PHASE);
607 local_state_->SetInteger(prefs::kStabilityIncompleteSessionEndCount, 0);
608 local_state_->SetInteger(prefs::kStabilityLaunchCount, 0);
609 local_state_->SetBoolean(prefs::kStabilitySessionEndCompleted, true);
610 }
611
592 // Update session ID. 612 // Update session ID.
593 ++session_id_; 613 ++session_id_;
594 local_state_->SetInteger(metrics::prefs::kMetricsSessionID, session_id_); 614 local_state_->SetInteger(metrics::prefs::kMetricsSessionID, session_id_);
595 615
596 // Stability bookkeeping 616 // Stability bookkeeping
597 IncrementPrefValue(metrics::prefs::kStabilityLaunchCount); 617 IncrementPrefValue(metrics::prefs::kStabilityLaunchCount);
598 618
599 DCHECK_EQ(UNINITIALIZED_PHASE, execution_phase_); 619 DCHECK_EQ(UNINITIALIZED_PHASE, execution_phase_);
600 SetExecutionPhase(START_METRICS_RECORDING, local_state_); 620 SetExecutionPhase(START_METRICS_RECORDING, local_state_);
601 621
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 local_state_->SetBoolean(path, value); 1211 local_state_->SetBoolean(path, value);
1192 RecordCurrentState(local_state_); 1212 RecordCurrentState(local_state_);
1193 } 1213 }
1194 1214
1195 void MetricsService::RecordCurrentState(PrefService* pref) { 1215 void MetricsService::RecordCurrentState(PrefService* pref) {
1196 pref->SetInt64(metrics::prefs::kStabilityLastTimestampSec, 1216 pref->SetInt64(metrics::prefs::kStabilityLastTimestampSec,
1197 base::Time::Now().ToTimeT()); 1217 base::Time::Now().ToTimeT());
1198 } 1218 }
1199 1219
1200 } // namespace metrics 1220 } // namespace metrics
OLDNEW
« components/metrics/metrics_provider.h ('K') | « components/metrics/metrics_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698