| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 base64 | 5 import base64 |
| 6 import json | 6 import json |
| 7 import logging | 7 import logging |
| 8 | 8 |
| 9 from common import constants | 9 from common import constants |
| 10 from common.base_handler import BaseHandler | 10 from common.base_handler import BaseHandler |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 ] | 52 ] |
| 53 } | 53 } |
| 54 | 54 |
| 55 crash_identifiers: { | 55 crash_identifiers: { |
| 56 'platform': 'mac', | 56 'platform': 'mac', |
| 57 'version': '52.0.2743.41', | 57 'version': '52.0.2743.41', |
| 58 'process_type': 'browser', | 58 'process_type': 'browser', |
| 59 'channel': 'beta', | 59 'channel': 'beta', |
| 60 'signature': '[ThreadWatcher UI hang] base::MessagePumpBase::Run' | 60 'signature': '[ThreadWatcher UI hang] base::MessagePumpBase::Run' |
| 61 } | 61 } |
| 62 |
| 63 customized_data, client_id and crash_identifiers vary from client to client. |
| 64 For example, for fracas, |
| 65 |
| 66 customized_data: { |
| 67 "trend_type": "d", # *see supported types below |
| 68 "channel": "beta", |
| 69 "historical_metadata": [ |
| 70 { |
| 71 "report_number": 0, |
| 72 "cpm": 0.0, |
| 73 "client_number": 0, |
| 74 "chrome_version": "51.0.2704.103" |
| 75 }, |
| 76 ... |
| 77 { |
| 78 "report_number": 10, |
| 79 "cpm": 2.1, |
| 80 "client_number": 8, |
| 81 "chrome_version": "53.0.2768.0" |
| 82 }, |
| 83 ] |
| 84 } |
| 85 |
| 86 crash_identifiers: { |
| 87 "platform": "mac", |
| 88 "version": "52.0.2743.41", |
| 89 "process_type": "browser", |
| 90 "channel": "beta", |
| 91 "signature": "[ThreadWatcher UI hang] base::MessagePumpCFRunLoopBase::Run" |
| 92 } |
| 62 """ | 93 """ |
| 63 try: | 94 try: |
| 64 received_message = json.loads(self.request.body) | 95 received_message = json.loads(self.request.body) |
| 65 pubsub_message = received_message['message'] | 96 pubsub_message = received_message['message'] |
| 66 crash_data = json.loads(base64.b64decode(pubsub_message['data'])) | 97 crash_data = json.loads(base64.b64decode(pubsub_message['data'])) |
| 67 | 98 |
| 68 logging.info('Processing message %s from subscription %s.', | 99 logging.info('Processing message %s from subscription %s.', |
| 69 pubsub_message['message_id'], | 100 pubsub_message['message_id'], |
| 70 received_message['subscription']) | 101 received_message['subscription']) |
| 71 | 102 |
| 72 logging.info('Crash data is %s', json.dumps(crash_data)) | 103 logging.info('Crash data is %s', json.dumps(crash_data)) |
| 73 | 104 |
| 74 crash_pipeline.ScheduleNewAnalysisForCrash( | 105 crash_pipeline.ScheduleNewAnalysisForCrash( |
| 75 crash_data['crash_identifiers'], | 106 crash_data['crash_identifiers'], |
| 76 crash_data['chrome_version'], | 107 crash_data['chrome_version'], |
| 77 crash_data['signature'], | 108 crash_data['signature'], |
| 78 crash_data['client_id'], | 109 crash_data['client_id'], |
| 79 crash_data['platform'], | 110 crash_data['platform'], |
| 80 crash_data['stack_trace'], | 111 crash_data['stack_trace'], |
| 81 crash_data['customized_data']['channel'], | 112 crash_data['customized_data'], |
| 82 crash_data['customized_data']['historical_metadata'], | 113 queue_name=constants.CRASH_ANALYSIS_QUEUE[crash_data['client_id']]) |
| 83 queue_name=constants.CRASH_ANALYSIS_FRACAS_QUEUE) | |
| 84 except (KeyError, ValueError): # pragma: no cover. | 114 except (KeyError, ValueError): # pragma: no cover. |
| 85 # TODO: save exception in datastore and create a page to show them. | 115 # TODO: save exception in datastore and create a page to show them. |
| 86 logging.exception('Failed to process crash message') | 116 logging.exception('Failed to process crash message') |
| 87 logging.info(self.request.body) | 117 logging.info(self.request.body) |
| OLD | NEW |