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

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

Issue 1260293009: make version of ts_mon compatible with appengine (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: add noncululativedistribution metric to ts_mon imports 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
« no previous file with comments | « appengine_module/gae_ts_mon/monacq ('k') | appengine_module/gae_ts_mon/monitoring.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """Send system monitoring data to the timeseries monitoring API."""
7
8 import logging
9 import webapp2
10
11 from common.metrics import *
12 from common.http_metrics import (
13 access_count, durations, request_bytes, response_bytes, response_status)
14 import config
15 import interface
16
17 from google.appengine.api import app_identity
18 from google.appengine.api import modules
19
20 import os
21 import sys
22
23
24 MONACQ_ENDPOINT = 'pubsub://chrome-infra-mon-pubsub/monacq'
25
26
27 class InitializeMonitoringHandler(webapp2.RequestHandler):
28
29 def get(self):
30 service = app_identity.get_application_id()
31 version = modules.get_current_version_name()
32 instance_id = hash(modules.get_current_instance_id()) % 10
33 endpoint = MONACQ_ENDPOINT
34 config.initialize(job_name=version, instance=instance_id,
35 service_name=service, endpoint=endpoint)
36 self.response.set_status(200, 'Initialized instance of ts_mon.')
37
38
39 class MonitoringHandler(webapp2.RequestHandler):
40
41 ''' Called by cron jobs every 5 minutes to update metrics. '''
42 def get(self, key=None):
43 interface.flush()
44 logging.info('Metrics updated.')
45 return
46
47
48 app = webapp2.WSGIApplication([
49 ('/_ah/start', InitializeMonitoringHandler),
50 ('/monitoring', MonitoringHandler),
51 ('/monitoring/(.*)', MonitoringHandler)
52 ], debug=True)
OLDNEW
« no previous file with comments | « appengine_module/gae_ts_mon/monacq ('k') | appengine_module/gae_ts_mon/monitoring.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698