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

Side by Side Diff: client/third_party/infra_libs/ts_mon/config.py

Issue 2465423002: Roll infra_libs to 564aaf7480f24c90687df79d9cef910cc342a54d (Closed)
Patch Set: update readmes Created 4 years, 1 month 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 import json 5 import json
6 import logging 6 import logging
7 import os 7 import os
8 import socket 8 import socket
9 import sys 9 import sys
10 import urlparse 10 import urlparse
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 parser.add_argument( 84 parser.add_argument(
85 '--ts-mon-endpoint', 85 '--ts-mon-endpoint',
86 help='url (including file://, pubsub://project/topic, https://) to post ' 86 help='url (including file://, pubsub://project/topic, https://) to post '
87 'monitoring metrics to. If set, overrides the value in ' 87 'monitoring metrics to. If set, overrides the value in '
88 '--ts-mon-config-file') 88 '--ts-mon-config-file')
89 parser.add_argument( 89 parser.add_argument(
90 '--ts-mon-credentials', 90 '--ts-mon-credentials',
91 help='path to a pkcs8 json credential file. If set, overrides the value ' 91 help='path to a pkcs8 json credential file. If set, overrides the value '
92 'in --ts-mon-config-file') 92 'in --ts-mon-config-file')
93 parser.add_argument( 93 parser.add_argument(
94 '--ts-mon-ca-certs',
95 help='path to file containing root CA certificates for SSL server '
96 'certificate validation. If not set, a CA cert file bundled with '
97 'httplib2 is used.')
98 parser.add_argument(
94 '--ts-mon-flush', 99 '--ts-mon-flush',
95 choices=('manual', 'auto'), default='auto', 100 choices=('manual', 'auto'), default='auto',
96 help=('metric push behavior: manual (only send when flush() is called), ' 101 help=('metric push behavior: manual (only send when flush() is called), '
97 'or auto (send automatically every --ts-mon-flush-interval-secs ' 102 'or auto (send automatically every --ts-mon-flush-interval-secs '
98 'seconds). (default: %(default)s)')) 103 'seconds). (default: %(default)s)'))
99 parser.add_argument( 104 parser.add_argument(
100 '--ts-mon-flush-interval-secs', 105 '--ts-mon-flush-interval-secs',
101 type=int, 106 type=int,
102 default=60, 107 default=60,
103 help=('automatically push metrics on this interval if ' 108 help=('automatically push metrics on this interval if '
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 parser.add_argument( 163 parser.add_argument(
159 '--ts-mon-task-number', type=int, default=0, 164 '--ts-mon-task-number', type=int, default=0,
160 help='number (e.g. for replication) of this instance of this task ' 165 help='number (e.g. for replication) of this instance of this task '
161 '(default: %(default)s)') 166 '(default: %(default)s)')
162 167
163 parser.add_argument( 168 parser.add_argument(
164 '--ts-mon-metric-name-prefix', 169 '--ts-mon-metric-name-prefix',
165 default='/chrome/infra/', 170 default='/chrome/infra/',
166 help='metric name prefix for all metrics (default: %(default)s)') 171 help='metric name prefix for all metrics (default: %(default)s)')
167 172
173 parser.add_argument(
174 '--ts-mon-use-new-proto',
175 default=False, action='store_true',
176 help='use the new proto schema (default: false)')
177
168 def process_argparse_options(args): 178 def process_argparse_options(args):
169 """Process command line arguments to initialize the global monitor. 179 """Process command line arguments to initialize the global monitor.
170 180
171 Also initializes the default target. 181 Also initializes the default target.
172 182
173 Starts a background thread to automatically flush monitoring metrics if not 183 Starts a background thread to automatically flush monitoring metrics if not
174 disabled by command line arguments. 184 disabled by command line arguments.
175 185
176 Args: 186 Args:
177 args (argparse.Namespace): the result of parsing the command line arguments 187 args (argparse.Namespace): the result of parsing the command line arguments
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 232
223 if endpoint.startswith('file://'): 233 if endpoint.startswith('file://'):
224 interface.state.global_monitor = monitors.DebugMonitor( 234 interface.state.global_monitor = monitors.DebugMonitor(
225 endpoint[len('file://'):]) 235 endpoint[len('file://'):])
226 elif endpoint.startswith('pubsub://'): 236 elif endpoint.startswith('pubsub://'):
227 if credentials: 237 if credentials:
228 url = urlparse.urlparse(endpoint) 238 url = urlparse.urlparse(endpoint)
229 project = url.netloc 239 project = url.netloc
230 topic = url.path.strip('/') 240 topic = url.path.strip('/')
231 interface.state.global_monitor = monitors.PubSubMonitor( 241 interface.state.global_monitor = monitors.PubSubMonitor(
232 credentials, project, topic, use_instrumented_http=True) 242 credentials, project, topic, use_instrumented_http=True,
243 ca_certs=args.ts_mon_ca_certs)
233 else: 244 else:
234 logging.error('ts_mon monitoring is disabled because credentials are not ' 245 logging.error('ts_mon monitoring is disabled because credentials are not '
235 'available') 246 'available')
236 elif endpoint.startswith('https://'): 247 elif endpoint.startswith('https://'):
237 interface.state.global_monitor = monitors.HttpsMonitor(endpoint, 248 interface.state.global_monitor = monitors.HttpsMonitor(
238 credentials) 249 endpoint, credentials)
239 elif endpoint.lower() == 'none': 250 elif endpoint.lower() == 'none':
240 logging.info('ts_mon monitoring has been explicitly disabled') 251 logging.info('ts_mon monitoring has been explicitly disabled')
241 else: 252 else:
242 logging.error('ts_mon monitoring is disabled because the endpoint provided' 253 logging.error('ts_mon monitoring is disabled because the endpoint provided'
243 ' is invalid or not supported: %s', endpoint) 254 ' is invalid or not supported: %s', endpoint)
244 255
245 interface.state.flush_mode = args.ts_mon_flush 256 interface.state.flush_mode = args.ts_mon_flush
257 interface.state.use_new_proto = args.ts_mon_use_new_proto
246 258
247 if args.ts_mon_flush == 'auto': 259 if args.ts_mon_flush == 'auto':
248 interface.state.flush_thread = interface._FlushThread( 260 interface.state.flush_thread = interface._FlushThread(
249 args.ts_mon_flush_interval_secs) 261 args.ts_mon_flush_interval_secs)
250 interface.state.flush_thread.start() 262 interface.state.flush_thread.start()
251 263
252 standard_metrics.init() 264 standard_metrics.init()
265
OLDNEW
« no previous file with comments | « client/third_party/infra_libs/ts_mon/common/targets.py ('k') | client/third_party/infra_libs/ts_mon/protos/REAME.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698