diff --git a/metrics.README.md b/metrics.README.md index 5a0adb130d..bf162a7427 100644 --- a/metrics.README.md +++ b/metrics.README.md @@ -70,6 +70,8 @@ The metrics we're collecting are: - What argument names (but not values) were passed to the program. (e.g. --checkout but not the branch name). - What was the exit code? +- Information about the enablement status of experimental feature flags, when + such experiments are being run. The list of all known strings we collect can be found at https://source.chromium.org/chromium/infra/infra/+/HEAD:go/src/infra/appengine/depot_tools_metrics/metrics/constants.go diff --git a/metrics.py b/metrics.py index 0f0083d277..66b872155d 100644 --- a/metrics.py +++ b/metrics.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python3 # Copyright (c) 2018 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -16,6 +15,7 @@ import urllib.request import detect_host_arch import gclient_utils import metrics_utils +import newauth import subprocess2 import utils @@ -251,6 +251,18 @@ class MetricsCollector(object): if bot_metrics: self.add('bot_metrics', bot_metrics) + # TODO(b/347085702): Remove this variable when dogfood is over. + new_auth_enabled = 'DEFAULT' + if newauth.Enabled(): + new_auth_enabled = 'TRUE' + elif newauth.ExplicitlyDisabled(): + new_auth_enabled = 'FALSE' + if new_auth_enabled != 'DEFAULT': + self.add_repeated('env_vars', { + 'name': 'DOGFOOD_NEW_AUTH', + 'value': new_auth_enabled, + }) + self._upload_metrics_data() if exception: gclient_utils.reraise(exception[0], exception[1], exception[2]) diff --git a/metrics_utils.py b/metrics_utils.py index d1d2a5cde8..90344ac803 100644 --- a/metrics_utils.py +++ b/metrics_utils.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python3 # Copyright (c) 2018 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -13,7 +12,7 @@ import urllib.parse # Current version of metrics recording. # When we add new metrics, the version number will be increased, we display the # user what has changed, and ask the user to agree again. -CURRENT_VERSION = 2 +CURRENT_VERSION = 3 APP_URL = 'https://cit-cli-metrics.appspot.com' @@ -73,6 +72,13 @@ def get_change_notice(version): 'authenticated as bot service accounts.', ] + if version == 3: + return [ + 'We will start collecting metrics for experiment flags.', + 'These are boolean or enum values that show whether', + 'you have opted in to or out of experimental features', + ] + KNOWN_PROJECT_URLS = { 'https://chrome-internal.googlesource.com/chrome/ios_internal', diff --git a/tests/metrics_test.py b/tests/metrics_test.py old mode 100644 new mode 100755 index c011ebc6df..8b7f0e1862 --- a/tests/metrics_test.py +++ b/tests/metrics_test.py @@ -66,6 +66,9 @@ class MetricsCollectorTest(unittest.TestCase): mock.patch('metrics_utils.get_repo_timestamp', lambda _: 1234).start() mock.patch('metrics_utils.get_git_version', lambda: '2.18.1').start() + mock.patch('newauth.Enabled', lambda: False).start() + mock.patch('newauth.ExplicitlyDisabled', lambda: False).start() + self.maxDiff = None self.default_metrics = { "metrics_version": 0,