Revert "autotest: Send metrics about the various host class' usage."
This reverts commit c2c6d54951e7581b047df233b9f4edfba7ced630.
Reason for revert: Said host classes deleted.
Original change's description:
> autotest: Send metrics about the various host class' usage.
>
> We have a lot of Host classes that we suspect are dead. Start spewing
> some metrics about what classes are actually in use so we can
> confidently start pouring gasoline over them all.
>
> BUG=chromium:834335
> TEST=moblab-generic-vm-pre-cq
>
> Change-Id: I8444906ee7c9cdf99f40da87b2c5658752065611
> Reviewed-on: https://chromium-review.googlesource.com/1022734
> Commit-Ready: ChromeOS CL Exonerator Bot <[email protected]>
> Tested-by: Prathmesh Prabhu <[email protected]>
> Reviewed-by: Prathmesh Prabhu <[email protected]>
Bug: chromium:834335
Change-Id: I2ddb6f649e4eab054ec551f501587648e4e4611d
Reviewed-on: https://chromium-review.googlesource.com/1237089
Commit-Ready: Prathmesh Prabhu <[email protected]>
Tested-by: Prathmesh Prabhu <[email protected]>
Reviewed-by: Aviv Keshet <[email protected]>
diff --git a/server/hosts/__init__.py b/server/hosts/__init__.py
index 1789e10..7d8b36f 100644
--- a/server/hosts/__init__.py
+++ b/server/hosts/__init__.py
@@ -22,7 +22,3 @@
# factory function
from factory import create_host
from factory import create_target_machine
-
-# Many host creation sites only import the package, so also provide useful
-# methods associated with host creation.
-from base_classes import send_creation_metric
diff --git a/server/hosts/base_classes.py b/server/hosts/base_classes.py
index 8d679f8..79d2dfa 100644
--- a/server/hosts/base_classes.py
+++ b/server/hosts/base_classes.py
@@ -17,13 +17,8 @@
[email protected] (Ryan Stutsman)
"""
-from autotest_lib.client.bin import utils
from autotest_lib.client.common_lib import hosts
-from autotest_lib.server import utils as server_utils
-try:
- from chromite.lib import metrics
-except ImportError:
- metrics = utils.metrics_mock
+from autotest_lib.server import utils
class Host(hosts.Host):
@@ -67,7 +62,7 @@
def _initialize(self, *args, **dargs):
super(Host, self)._initialize(*args, **dargs)
- self.serverdir = server_utils.get_server_dir()
+ self.serverdir = utils.get_server_dir()
self.env = {}
@@ -77,41 +72,3 @@
if self.job:
self.job.hosts.discard(self)
-
-
-_CREATION_METRIC_WHITELIST = {
- 'AbstractSSHHost',
- 'ADBHost',
- 'CastOSHost',
- 'ChameleonHost',
- 'CrosHost',
- 'EmulatedAdbHost',
- 'GceHost',
- 'JetstreamHost',
- 'MoblabHost',
- 'PlanktonHost',
- 'ServoHost',
- 'SonicHost',
- 'SSHHost',
- 'TestBed',
- 'TestStationHost',
-}
-_CREATION_METRIC = '/chrome/infra/chromeos/autotest/host/class_instantiated'
-
-
-def send_creation_metric(host, context=''):
- """Send a metric about which host class we ended up creating.
-
- Creating host classes is black magic. Once a host class has been created
- through the various channels, use this function to report what got created.
-
- @param host: An instace of one of the host classes to send a report about.
- @param context: Optional context for who created the host instance.
- """
- bases = {b.__name__ for b in host.__class__.__bases__}
- bases = bases & _CREATION_METRIC_WHITELIST
- for base in bases:
- metrics.Counter(_CREATION_METRIC).increment(fields={
- 'class': base,
- 'context': context,
- })
diff --git a/server/hosts/chameleon_host.py b/server/hosts/chameleon_host.py
index f1307b3..39b8e44 100644
--- a/server/hosts/chameleon_host.py
+++ b/server/hosts/chameleon_host.py
@@ -12,7 +12,6 @@
from autotest_lib.client.cros.chameleon import chameleon
from autotest_lib.server.cros import dnsname_mangler
from autotest_lib.server.cros.dynamic_suite import frontend_wrappers
-from autotest_lib.server.hosts import base_classes
from autotest_lib.server.hosts import ssh_host
@@ -180,9 +179,7 @@
'Chameleon %s is not accessible. Please file a bug'
' to test lab', chameleon_hostname)
return None
- host = ChameleonHost(chameleon_host=chameleon_hostname)
- base_classes.send_creation_metric(host)
- return host
+ return ChameleonHost(chameleon_host=chameleon_hostname)
if chameleon_args:
return ChameleonHost(**chameleon_args)
else:
@@ -191,12 +188,10 @@
afe = frontend_wrappers.RetryingAFE(timeout_min=5, delay_sec=10)
hosts = afe.get_hosts(hostname=dut)
if hosts and CHAMELEON_HOST_ATTR in hosts[0].attributes:
- host = ChameleonHost(
+ return ChameleonHost(
chameleon_host=hosts[0].attributes[CHAMELEON_HOST_ATTR],
chameleon_port=hosts[0].attributes.get(
CHAMELEON_PORT_ATTR, 9992)
)
- base_classes.send_creation_metric(host)
- return host
else:
return None
diff --git a/server/hosts/factory.py b/server/hosts/factory.py
index 6248238..31a2051 100644
--- a/server/hosts/factory.py
+++ b/server/hosts/factory.py
@@ -3,8 +3,6 @@
import logging
from contextlib import closing
-import common
-
from autotest_lib.client.bin import local_host
from autotest_lib.client.bin import utils
from autotest_lib.client.common_lib import deprecation
@@ -13,7 +11,6 @@
from autotest_lib.server import utils as server_utils
from autotest_lib.server.cros.dynamic_suite import constants
from autotest_lib.server.hosts import adb_host
-from autotest_lib.server.hosts import base_classes
from autotest_lib.server.hosts import cros_host
from autotest_lib.server.hosts import host_info
from autotest_lib.server.hosts import jetstream_host
@@ -234,7 +231,6 @@
host_instance.job_start()
_started_hostnames.add(hostname)
- base_classes.send_creation_metric(host_instance, context='factory')
return host_instance
diff --git a/server/hosts/plankton_host.py b/server/hosts/plankton_host.py
index e0f525d..ab7def1 100644
--- a/server/hosts/plankton_host.py
+++ b/server/hosts/plankton_host.py
@@ -8,7 +8,6 @@
"""This file provides core logic for servo verify/repair process."""
-from autotest_lib.server.hosts import base_classes
from autotest_lib.server.hosts import servo_host
@@ -71,6 +70,4 @@
# TODO Make this work in the lab chromium:564836
if plankton_args is None:
return None
- host = PlanktonHost(Required_by_test=True, is_in_lab=False, **plankton_args)
- base_classes.send_creation_metric(host)
- return host
+ return PlanktonHost(Required_by_test=True, is_in_lab=False, **plankton_args)
diff --git a/server/hosts/servo_host.py b/server/hosts/servo_host.py
index 7d55709..4510132 100644
--- a/server/hosts/servo_host.py
+++ b/server/hosts/servo_host.py
@@ -33,7 +33,6 @@
from autotest_lib.server.cros.dynamic_suite import control_file_getter
from autotest_lib.server.cros.dynamic_suite import frontend_wrappers
from autotest_lib.server.cros.servo import servo
-from autotest_lib.server.hosts import base_classes
from autotest_lib.server.hosts import servo_repair
from autotest_lib.server.hosts import ssh_host
from autotest_lib.site_utils.rpm_control_system import rpm_client
@@ -847,8 +846,6 @@
servo_args[SERVO_HOST_ATTR])),
**servo_args
)
- base_classes.send_creation_metric(newhost)
-
# Note that the logic of repair() includes everything done
# by verify(). It's sufficient to call one or the other;
# we don't need both.
diff --git a/server/hosts/teststation_host.py b/server/hosts/teststation_host.py
index bc17d83..e2fac55 100644
--- a/server/hosts/teststation_host.py
+++ b/server/hosts/teststation_host.py
@@ -34,9 +34,7 @@
else:
classes.append(ssh_host.SSHHost)
host_class = type('new_teststationhost', tuple(classes), {})
- host = host_class(hostname, **kwargs)
- base_classes.send_creation_metric(host)
- return host
+ return host_class(hostname, **kwargs)
class TestStationHost(base_classes.Host):