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

Unified Diff: appengine/findit/handlers/crash/fracas_crash.py

Issue 1852383002: [Findit] Integrate with Fracas through Pub/Sub. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 4 years, 8 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
Index: appengine/findit/handlers/crash/fracas_crash.py
diff --git a/appengine/findit/handlers/crash/fracas_crash.py b/appengine/findit/handlers/crash/fracas_crash.py
new file mode 100644
index 0000000000000000000000000000000000000000..412feac0264afb238d0ccabef2d188eab88f0f14
--- /dev/null
+++ b/appengine/findit/handlers/crash/fracas_crash.py
@@ -0,0 +1,41 @@
+# Copyright 2016 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.
+
+import base64
+import json
+import logging
+
+from base_handler import BaseHandler
+from base_handler import Permission
+from common import constants
+from crash import fracas_crash_pipeline
+from model.crash.crash_config import CrashConfig
+
+
+FRACAS_ANALYSIS_QUEUE = 'fracas-crash-queue'
+
+
+class FracasCrash(BaseHandler):
+ PERMISSION_LEVEL = Permission.ANYONE
+
+ def HandlePost(self):
+ """Handles push delivery from Pub/Sub for crash data."""
+ token = self.request.get('token', '').strip()
+ crash_config = CrashConfig.Get()
+ if token != crash_config.fracas.get('crash_data_push_token'):
+ logging.warning('Unauthorized access.')
+ return self.CreateError(
+ 'Unauthorized access: invalid token "%s"' % token, 403)
+
+ received_message = json.loads(self.request.body)
+ pubsub_message = received_message['message']
+ crash_data = json.loads(base64.b64decode(pubsub_message['data']))
+
+ logging.info('Processing message %s from subscription %s.',
+ pubsub_message['message_id'], received_message['subscription'])
+
+ fracas_crash_pipeline.ScheduleNewAnalysisForCrash(
+ crash_data['channel'], crash_data['platform'], crash_data['signature'],
mimee 2016/04/07 23:43:09 I prefer passing the object and unpacking it in th
stgao 2016/04/08 01:14:08 I'd unpack the json here to prevent malformed data
+ crash_data['stack_trace'], crash_data['chrome_version'],
+ crash_data['cpm'], queue_name=constants.CRASH_ANALYSIS_FRACAS_QUEUE)

Powered by Google App Engine
This is Rietveld 408576698