-
Notifications
You must be signed in to change notification settings - Fork 0
/
capture_args.pxl
42 lines (36 loc) · 1.37 KB
/
capture_args.pxl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# -*- mode: python; -*-
# Copyright (c) Pixie Labs, Inc.
# Licensed under the Apache License, Version 2.0 (the "License")
import pxtrace
import px
# The UPID of the simple-gotracing-example server. You can
# get the value of this by running:
# px run px/upids -- --namespace px-demo-gotracing
# The relevant UPID will be in the fourth column.
upid = 'replace-me-with-upid'
# This is the basic trace function. Every function call of
# `main.computeE` is traced and the values are recorded into
# a table as specified by the return value.
#
# To probe struct functions, see the notes here:
# https://docs.px.dev/tutorials/custom-data/dynamic-go-logging/#formatting-the-pxtrace.probe-path
@pxtrace.probe("main.computeE")
def probe_func():
return [{
'iterations': pxtrace.ArgExpr("iterations"),
'latency': pxtrace.FunctionLatency(),
}]
# This is the function that actually installs the tracepoint.
# The arguments are:
# Tracepoint name.
# Output table name.
# Name of the probe function.
# The UPID.
# The TTL of the tracepoint. It is updated each time the script is run.
pxtrace.UpsertTracepoint('compute_e_data',
'compute_e_data',
probe_func,
px.uint128(upid),
"5m")
# This just writes the output into a table.
px.display(px.DataFrame(table='compute_e_data'))