bug 1461992 - add a voluptuous schema for build system telemetry. r=gps
authorTed Mielczarek <ted@mielczarek.org>
Fri, 03 Aug 2018 15:41:20 -0400
changeset 486891 0f9bae9652bb295ef942c25ffed68846d6bdc849
parent 486890 a077bf122c05f9643ad66280d6b395b1751eff36
child 486892 0f4b8b37bf95445e6feb5d9473c2ea61e20190f7
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1461992
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 1461992 - add a voluptuous schema for build system telemetry. r=gps This change adds a voluptuous schema for build system telemetry, replacing the existing json schema file. Using voluptuous will make it easier to work with the schema from Python code in the build system. A future commit will use a Python module to provide a mach command to convert the voluptuous schema to json schema format for consumption by other systems. Differential Revision: https://phabricator.services.mozilla.com/D2840
build/telemetry-schema.json
python/mozbuild/mozbuild/telemetry.py
deleted file mode 100644
--- a/build/telemetry-schema.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
-  "$schema": "http://json-schema.org/draft-04/schema#",
-  "type": "object",
-  "properties": {
-    "argv": {"type": "array"},
-    "system": {
-      "type": "object",
-      "properties": {
-        "architecture": {"type": "array"},
-        "linux_distribution": {"type": "array"},
-        "mac_ver": {"type": "array"},
-        "machine": {"type": "string"},
-        "python_version": {"type": "string"},
-        "release": {"type": "string"},
-        "system": {"type": "string"},
-        "version": {"type": "string"},
-        "win_ver": {"type": "array"}
-      },
-      "required": ["architecture", "machine", "python_version",
-                   "release", "system", "version"]
-    }
-  },
-  "required": ["argv", "system"]
-}
new file mode 100644
--- /dev/null
+++ b/python/mozbuild/mozbuild/telemetry.py
@@ -0,0 +1,62 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from __future__ import absolute_import, print_function, unicode_literals
+
+'''
+This file contains a voluptuous schema definition for build system telemetry.
+'''
+
+from mozbuild.configure.constants import CompilerType
+from voluptuous import (
+    Any,
+    Optional,
+    Required,
+    Schema,
+)
+from voluptuous.validators import Datetime
+
+schema = Schema({
+    Required('client_id', description='A UUID to uniquely identify a client'): basestring,
+    Required('time', description='Time at which this event happened'): Datetime(),
+    Required('command', description='The mach command that was invoked'): basestring,
+    Required('argv', description=(
+        'Full mach commandline. ' +
+        'If the commandline contains absolute paths they will be sanitized.')): [basestring],
+    Required('success', description='true if the command succeeded'): bool,
+    Optional('exception', description=(
+        'If a Python exception was encountered during the execution of the command, ' +
+        'this value contains the result of calling `repr` on the exception object.')): basestring,
+    Optional('file_types_changed', description=(
+        'This array contains a list of objects with {ext, count} properties giving the count ' +
+        'of files changed since the last invocation grouped by file type')): [
+            {
+                Required('ext', description='File extension'): basestring,
+                Required('count', description='Count of changed files with this extension'): int,
+            }
+        ],
+    Required('duration_ms', description='Command duration in milliseconds'): int,
+    Required('build_opts', description='Selected build options'): {
+        Optional('compiler', description='The compiler type in use (CC_TYPE)'):
+            Any(*CompilerType.POSSIBLE_VALUES),
+        Optional('artifact', description='true if --enable-artifact-builds'): bool,
+        Optional('debug', description='true if build is debug (--enable-debug)'): bool,
+        Optional('opt', description='true if build is optimized (--enable-optimize)'): bool,
+        Optional('ccache', description='true if ccache is in use (--with-ccache)'): bool,
+        Optional('sccache', description='true if ccache in use is sccache'): bool,
+        Optional('icecream', description='true if icecream in use'): bool,
+    },
+    Required('system'): {
+        # We don't need perfect granularity here.
+        Required('os', description='Operating system'): Any('windows', 'macos', 'linux', 'other'),
+        Optional('cpu_brand', description='CPU brand string from CPUID'): basestring,
+        Optional('logical_cores', description='Number of logical CPU cores present'): int,
+        Optional('physical_cores', description='Number of physical CPU cores present'): int,
+        Optional('memory_gb', description='System memory in GB'): int,
+        Optional('drive_is_ssd',
+                 description='true if the source directory is on a solid-state disk'): bool,
+        Optional('virtual_machine',
+                 description='true if the OS appears to be running in a virtual machine'): bool,
+    },
+})