Commit 18df41e0 authored by Edward Lemur's avatar Edward Lemur Committed by Commit Bot

metrics: Collect full timestamps.

Update metrics.README.md and add a metrics_version field.

Bug: None
Change-Id: I17d9032bd787af2a6fc49f80d59e05152d5223b7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1406256Reviewed-by: 's avatarAndy Perelson <ajp@chromium.org>
Reviewed-by: 's avatarEdward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
parent 74913996
......@@ -34,8 +34,8 @@ First, some words about what data we are **NOT** collecting:
The metrics we're collecting are:
- A timestamp, with a week resolution.
- The age of your depot\_tools checkout, with a week resolution.
- The time when the command was run.
- The age of your depot\_tools checkout.
- Your version of Python (in the format major.minor.micro).
- Your version of Git (in the format major.minor.micro).
- The OS of your machine (i.e. win, linux or mac).
......@@ -47,7 +47,7 @@ The metrics we're collecting are:
- The exit code.
- The project you're working on. We only record data about projects you can
fetch using depot\_tools' fetch command (e.g. Chromium, WebRTC, V8, etc)
- The age of your project checkout, with a week resolution.
- The age of your project checkout.
- What features are you using in your DEPS and .gclient files. For example:
- Are you setting `use_relative_paths=True`?
- Are you using `recursedeps`?
......
......@@ -198,6 +198,7 @@ class MetricsCollector(object):
return func(*args, **kwargs)
self._collecting_metrics = True
self.add('metrics_version', metrics_utils.CURRENT_VERSION)
self.add('command', command_name)
try:
start = time.time()
......@@ -213,7 +214,7 @@ class MetricsCollector(object):
self.add('exit_code', exit_code)
# Add metrics regarding environment information.
self.add('timestamp', metrics_utils.seconds_to_weeks(time.time()))
self.add('timestamp', time.time())
self.add('python_version', metrics_utils.get_python_version())
self.add('host_os', gclient_utils.GetMacWinOrLinux())
self.add('host_arch', detect_host_arch.HostArch())
......
......@@ -183,15 +183,6 @@ def return_code_from_exception(exception):
return 1
def seconds_to_weeks(duration):
"""Transform a |duration| from seconds to weeks approximately.
Drops the lowest 19 bits of the integer representation, which ammounts to
about 6 days.
"""
return int(duration) >> 19
def extract_known_subcommand_args(args):
"""Extract the known arguments from the passed list of args."""
known_args = []
......@@ -276,8 +267,7 @@ def get_repo_timestamp(path_to_repo):
if p.returncode != 0:
return None
# Get the age of the checkout in weeks.
return seconds_to_weeks(stdout.strip())
return stdout.strip()
def print_boxed_text(out, min_width, lines):
[EW, NS, SE, SW, NE, NW] = list('=|++++')
......
......@@ -68,11 +68,13 @@ class MetricsCollectorTest(unittest.TestCase):
mock.patch('metrics_utils.get_git_version',
lambda: '2.18.1').start()
self.maxDiff = None
self.default_metrics = {
"metrics_version": 0,
"python_version": "2.7.13",
"git_version": "2.18.1",
"execution_time": 1000,
"timestamp": 0,
"timestamp": 3000,
"exit_code": 0,
"command": "fun",
"depot_tools_age": 1234,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment