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

Side by Side Diff: appengine_module/gae_ts_mon/config.py

Issue 1260293009: make version of ts_mon compatible with appengine (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: take out deleted utils methods Created 5 years, 4 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
(Empty)
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
3 # found in the LICENSE file.
4
5 import json
6 import logging
7 import os
8 import socket
9 import sys
10 import urlparse
11 import re
12
13 import monitors
14 import interface
15 from common import standard_metrics
16 from common import targets
17
18
19 def initialize(endpoint=None, flush='manual', job_name=None,
20 service_name=None, instance=0):
21 """Initialize the global monitor.
22
23 Also initializes the default target if endpoint argument is supplied.
24 If they aren't, all created metrics will have to supply their own target.
25 This is generally a bad idea, as many libraries rely on the default target
26 being set up.
27
28 Args:
29 endpoint: url (in format pubsub://project/topic) to post ts_mon metrics to
30 flush: metric push behavior: all (send every metric individually),
31 or manual (only send when flush() is called)
32 job_name: name of the job instance of the task
33 instance: number of instance for this task
34 service_name: name of service being monitored
35
36 """
37 hostname = socket.getfqdn().split('.')[0]
38 try:
39 region = fqdn.split('.')[1]
40 except:
41 region = ''
42
43 if endpoint.startswith('pubsub://'):
Sergey Berezin 2015/08/18 00:40:37 nit: I feel this logic should belong in ts_mon its
jshu 2015/08/18 01:15:55 thanks for drawing attention this, going to take o
Sergey Berezin 2015/08/18 17:31:38 Filed http://crbug.com/522135 The danger of dupli
jshu 2015/08/20 00:23:34 Those two files are completely different.
44 url = urlparse.urlparse(endpoint)
45 project = url.netloc
46 topic = url.path.strip('/')
47 interface.state.global_monitor = monitors.PubSubMonitor(project, topic)
48 else:
49 logging.error('Error: endpoint should begin with pubsub://')
50 interface.state.global_monitor = monitors.NullMonitor()
51
52 # Reimplement ArgumentParser.error, since we don't have access to the parser
53 if not service_name:
54 logging.error('service_name variable is not set for task.')
55 if not job_name: # pragma: no cover
56 logging.error('job_name variable is not set for task.')
57 interface.state.default_target = targets.TaskTarget(
58 service_name, job_name, region, hostname, instance)
59
60 interface.state.flush_mode = flush
61
62 standard_metrics.init()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698