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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine_module/gae_ts_mon/monitoring.py
diff --git a/appengine_module/gae_ts_mon/monitoring.py b/appengine_module/gae_ts_mon/monitoring.py
new file mode 100644
index 0000000000000000000000000000000000000000..efda54752c448a41ac925339e468f1d3c957cb1a
--- /dev/null
+++ b/appengine_module/gae_ts_mon/monitoring.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+# Copyright (c) 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Send system monitoring data to the timeseries monitoring API."""
+
+import logging
+import webapp2
+
+from common.metrics import *
+from common.http_metrics import (
+ access_count, durations, request_bytes, response_bytes, response_status)
+import config
+import interface
+
+from google.appengine.api import app_identity
+from google.appengine.api import modules
+
+import os
+import sys
+
+
+MONACQ_ENDPOINT = 'pubsub://chrome-infra-mon-pubsub/monacq'
+
+
+class InitializeMonitoringHandler(webapp2.RequestHandler):
+
+ def get(self):
+ service = app_identity.get_application_id()
+ version = modules.get_current_version_name()
+ instance_id = hash(modules.get_current_instance_id()) % 10
+ endpoint = MONACQ_ENDPOINT
+ config.initialize(job_name=version, instance=instance_id,
+ service_name=service, endpoint=endpoint)
+ self.response.set_status(200, 'Initialized instance of ts_mon.')
+
+
+class MonitoringHandler(webapp2.RequestHandler):
+
+ ''' Called by cron jobs every 5 minutes to update metrics. '''
+ def get(self, key=None):
+ interface.flush()
+ logging.info('Metrics updated.')
+ return
+
+
+app = webapp2.WSGIApplication([
+ ('/_ah/start', InitializeMonitoringHandler),
+ ('/monitoring', MonitoringHandler),
+ ('/monitoring/(.*)', MonitoringHandler)
+], debug=True)
« 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