-
-
Save chutten/65e146a68034ebdd8140a8b23a26facd to your computer and use it in GitHub Desktop.
Crashping Stacks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
# ### "crash" ping stacks | |
# We're now getting some stacks with crash pings on Nightly. How do they look? | |
# In[1]: | |
import ujson as json | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
import numpy as np | |
import plotly.plotly as py | |
from plotly.graph_objs import * | |
from moztelemetry import get_pings_properties, get_one_ping_per_client | |
from moztelemetry.dataset import Dataset | |
get_ipython().magic(u'matplotlib inline') | |
# In[2]: | |
import requests | |
# In[3]: | |
sc.defaultParallelism | |
# In[51]: | |
pings = Dataset.from_source("telemetry") .where(docType="crash") .where(appName="Firefox") .where(submissionDate=lambda d: d >= "20170106" and d <= "20170106") .where(appUpdateChannel="nightly") .records(sc, sample=1) | |
# In[52]: | |
pings.count() | |
# In[53]: | |
stacks = pings .filter(lambda p: p['payload'].get('stackTraces', None) is not None) .map(lambda p: p['payload']['stackTraces']) | |
# In[54]: | |
stacks.count() | |
# In[63]: | |
def symbolicate(s): | |
data = json.dumps({ | |
'stacks': [[[f['module_index'], int(f['ip'], 16) - int(s['modules'][f['module_index']]['base_addr'], 16)] for f in s['threads'][s['crash_info']['crashing_thread']]['frames']]], | |
'memoryMap': [[m['debug_file'], m['debug_id']] for m in s['modules']], 'version': 4}) | |
print 'Sending Request' | |
result = requests.post('http://symbolapi.mozilla.org/', data=data) | |
print 'Receiving Response' | |
result_json = result.json() | |
print 'Response Received' | |
return result_json['symbolicatedStacks'] | |
# In[55]: | |
some = stacks.take(10) | |
# In[57]: | |
s = some[0] | |
# In[58]: | |
s['threads'][s['crash_info']['crashing_thread']]['frames'] | |
# In[59]: | |
f = s['threads'][s['crash_info']['crashing_thread']]['frames'][0] | |
# In[60]: | |
f['ip'] | |
# In[61]: | |
s['modules'][f['module_index']] | |
# In[64]: | |
symbolicate(s) | |
# In[65]: | |
def safe_symbolicate(s): | |
try: | |
return symbolicate(s) | |
except Exception, e: | |
return None | |
symbolicated_stacks = stacks.map(safe_symbolicate) | |
# In[67]: | |
symbolicated_stacks.take(3) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment