| OLD | NEW | 
|---|
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be | 
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. | 
| 4 | 4 | 
| 5 """Classes representing the monitoring interface for tasks or devices. | 5 """Classes representing the monitoring interface for tasks or devices. | 
| 6 | 6 | 
| 7 Usage: | 7 Usage: | 
| 8   import argparse | 8   import argparse | 
| 9   from infra_libs import ts_mon | 9   from infra_libs import ts_mon | 
| 10 | 10 | 
| (...skipping 21 matching lines...) Expand all  Loading... | 
| 32 """ | 32 """ | 
| 33 | 33 | 
| 34 import logging | 34 import logging | 
| 35 import os | 35 import os | 
| 36 import random | 36 import random | 
| 37 import threading | 37 import threading | 
| 38 import time | 38 import time | 
| 39 | 39 | 
| 40 from monacq.proto import metrics_pb2 | 40 from monacq.proto import metrics_pb2 | 
| 41 | 41 | 
| 42 from infra_libs.ts_mon import errors | 42 from infra_libs.ts_mon.common import errors | 
| 43 | 43 | 
| 44 # The maximum number of MetricsData messages to include in each HTTP request. | 44 # The maximum number of MetricsData messages to include in each HTTP request. | 
| 45 # MetricsCollections larger than this will be split into multiple requests. | 45 # MetricsCollections larger than this will be split into multiple requests. | 
| 46 METRICS_DATA_LENGTH_LIMIT = 5000 | 46 METRICS_DATA_LENGTH_LIMIT = 5000 | 
| 47 | 47 | 
| 48 | 48 | 
| 49 class State(object): | 49 class State(object): | 
| 50   """Package-level state is stored here so that it is easily accessible. | 50   """Package-level state is stored here so that it is easily accessible. | 
| 51 | 51 | 
| 52   Configuration is kept in this one object at the global level so that all | 52   Configuration is kept in this one object at the global level so that all | 
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 176             'Last monitoring flush took %f seconds (longer than ' | 176             'Last monitoring flush took %f seconds (longer than ' | 
| 177             '--ts-mon-flush-interval-secs = %f seconds)', | 177             '--ts-mon-flush-interval-secs = %f seconds)', | 
| 178             flush_duration, self.interval_secs) | 178             flush_duration, self.interval_secs) | 
| 179         next_timeout = 0 | 179         next_timeout = 0 | 
| 180 | 180 | 
| 181   def stop(self): | 181   def stop(self): | 
| 182     """Stops the background thread and performs a final flush.""" | 182     """Stops the background thread and performs a final flush.""" | 
| 183 | 183 | 
| 184     self.stop_event.set() | 184     self.stop_event.set() | 
| 185     self.join() | 185     self.join() | 
| OLD | NEW | 
|---|