Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Side by Side Diff: infra_libs/ts_mon/common/interface.py

Issue 1797103003: gae_ts_mon: instrument Cloud Endpoint methods (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Removed unnecessary 'no cover' Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 del state.metrics[metric.name] 126 del state.metrics[metric.name]
127 127
128 128
129 def close(): 129 def close():
130 """Stops any background threads and waits for them to exit.""" 130 """Stops any background threads and waits for them to exit."""
131 if state.flush_thread is not None: 131 if state.flush_thread is not None:
132 state.flush_thread.stop() 132 state.flush_thread.stop()
133 133
134 134
135 def reset_for_unittest(): 135 def reset_for_unittest():
136 global state
137 store = state.store
138 state = State()
139 state.store = store
136 state.store.reset_for_unittest() 140 state.store.reset_for_unittest()
137 141
138 142
139 class _FlushThread(threading.Thread): 143 class _FlushThread(threading.Thread):
140 """Background thread that flushes metrics on an interval.""" 144 """Background thread that flushes metrics on an interval."""
141 145
142 def __init__(self, interval_secs, stop_event=None): 146 def __init__(self, interval_secs, stop_event=None):
143 super(_FlushThread, self).__init__(name='ts_mon') 147 super(_FlushThread, self).__init__(name='ts_mon')
144 148
145 if stop_event is None: 149 if stop_event is None:
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 'Last monitoring flush took %f seconds (longer than ' 181 'Last monitoring flush took %f seconds (longer than '
178 '--ts-mon-flush-interval-secs = %f seconds)', 182 '--ts-mon-flush-interval-secs = %f seconds)',
179 flush_duration, self.interval_secs) 183 flush_duration, self.interval_secs)
180 next_timeout = 0 184 next_timeout = 0
181 185
182 def stop(self): 186 def stop(self):
183 """Stops the background thread and performs a final flush.""" 187 """Stops the background thread and performs a final flush."""
184 188
185 self.stop_event.set() 189 self.stop_event.set()
186 self.join() 190 self.join()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698