bug 1237610 - make mach telemetry opt-out rather than opt-in. r?gps
This also changes the submission endpoint to a server that exists. The
previous dev server no longer exists. This is expected to be temporary
until the data platform team's generic ingestion service is available.
MozReview-Commit-ID: 1E92wlmuSqp
--- a/build/mach_bootstrap.py
+++ b/build/mach_bootstrap.py
@@ -110,16 +110,23 @@ CATEGORIES = {
'priority': 0,
}
}
# We submit data to telemetry approximately every this many mach invocations
TELEMETRY_SUBMISSION_FREQUENCY = 10
+def telemetry_disabled():
+ # Allow opt-out, and disable telemetry for automation as well.
+ for v in ('DISABLE_BUILD_SYSTEM_TELEMETRY', 'MOZ_AUTOMATION'):
+ if v in os.environ:
+ return True
+ return False
+
def search_path(mozilla_dir, packages_txt):
with open(os.path.join(mozilla_dir, packages_txt)) as f:
packages = [line.rstrip().split(':') for line in f]
for package in packages:
if package[0] == 'packages.txt':
assert len(package) == 2
@@ -156,18 +163,17 @@ def bootstrap(topsrcdir, mozilla_dir=Non
'build/virtualenv_packages.txt')]
import mach.main
from mozboot.util import get_state_dir
from mozbuild.util import patch_main
patch_main()
def telemetry_handler(context, data):
- # We have not opted-in to telemetry
- if 'BUILD_SYSTEM_TELEMETRY' not in os.environ:
+ if telemetry_disabled():
return
telemetry_dir = os.path.join(get_state_dir()[0], 'telemetry')
try:
os.mkdir(telemetry_dir)
except OSError as e:
if e.errno != errno.EEXIST:
raise
@@ -229,18 +235,17 @@ def bootstrap(topsrcdir, mozilla_dir=Non
if should_skip_dispatch(context, handler):
return
# We call mach environment in client.mk which would cause the
# data submission below to block the forward progress of make.
if handler.name in ('environment'):
return
- # We have not opted-in to telemetry
- if 'BUILD_SYSTEM_TELEMETRY' not in os.environ:
+ if telemetry_disabled():
return
# Every n-th operation
if random.randint(1, TELEMETRY_SUBMISSION_FREQUENCY) != 1:
return
with open(os.devnull, 'wb') as devnull:
subprocess.Popen([sys.executable,
--- a/build/submit_telemetry_data.py
+++ b/build/submit_telemetry_data.py
@@ -9,17 +9,17 @@ import sys
import time
HERE = os.path.abspath(os.path.dirname(__file__))
sys.path.append(os.path.join(HERE, '..', 'third_party', 'python', 'requests'))
import requests
# Server to which to submit telemetry data
-BUILD_TELEMETRY_SERVER = 'http://52.88.27.118/build-metrics-dev'
+BUILD_TELEMETRY_SERVER = 'http://54.149.253.188:80/build-metrics-dev'
def submit_telemetry_data(statedir):
# No data to work with anyway
outgoing = os.path.join(statedir, 'telemetry', 'outgoing')
if not os.path.isdir(outgoing):
return 0