Skip to content

Commit d667a2a

Browse files
Phillip Kuznetsovcopybaranaut
authored andcommitted
Add stacktraces to pxviews
Summary: stacktraces() computes the stacktraces for the entire cluster. Test Plan: Rewrote all of the stacktraces.beta scripts to use this view and they all worked. Reviewers: michelle, vihang, jamesbartlett Reviewed By: vihang Signed-off-by: Phillip Kuznetsov <pkuznetsov@pixielabs.ai> Differential Revision: https://phab.corp.pixielabs.ai/D11959 GitOrigin-RevId: 41521e1
1 parent ce44943 commit d667a2a

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

src/carnot/planner/pxl_lib/pxviews.pxl

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,4 +431,52 @@ def inbound_http_latency_timeseries(start_time, end_time, window_ns):
431431

432432
return df[['time_', 'pod_id', 'latency_quantiles', 'num_requests', 'num_errors', 'latency_sum', 'req_bytes', 'resp_bytes']]
433433

434+
435+
def stacktraces(start_time, end_time):
436+
''' Compute the stacktraces for the entire cluster.
437+
438+
Returns the stacktraces for the cluster, labelled with pod, container, cmdline, and
439+
function stack names.
440+
441+
Args:
442+
@start_time Starting time of the data to examine.
443+
@end_time Ending time of the data to examine.
444+
'''
445+
df = px.DataFrame(table='stack_traces.beta', start_time=start_time, end_time=end_time)
446+
447+
df.namespace = df.ctx['namespace']
448+
df.pod = df.ctx['pod']
449+
df.container = df.ctx['container']
450+
df.cmdline = df.ctx['cmdline']
451+
df.service = df.ctx['service']
452+
453+
# Compute node using _exec_hostname() instead of `df.ctx['node']`
454+
# We do this so it works for non-k8s processes too.
455+
# This is important for determining total number of stack trace samples per node,
456+
# as we need to include the non-K8s processes in the computation.
457+
df.node = px.Node(px._exec_hostname())
458+
df.node_num_cpus = px._exec_host_num_cpus()
459+
460+
# Combine flamegraphs from different intervals into one larger framegraph.
461+
df = df.groupby(['node', 'namespace', 'service', 'pod', 'container', 'cmdline', 'stack_trace_id']).agg(
462+
stack_trace=('stack_trace', px.any),
463+
count=('count', px.sum),
464+
time_=('time_', px.max),
465+
node_num_cpus=('node_num_cpus', px.any),
466+
)
467+
468+
return df[[
469+
'namespace',
470+
'node',
471+
'service',
472+
'pod',
473+
'container',
474+
'cmdline',
475+
'stack_trace',
476+
'time_',
477+
'stack_trace_id',
478+
'count',
479+
'node_num_cpus',
480+
]]
481+
434482
)"

0 commit comments

Comments
 (0)