Salp is a library that enables Go programs to create and fire USDT probes at runtime. Such probes allow API-stable (i.e. not dependent on function names) tracing of executables written in Go - especially important since function tracing of Go code requires some unappealing (though not unimpressive) hacks. Salp uses the libstapsdt library to create and fire these probes.
Salp depends on
libstapsdt which in turn depends on
libstapsdt can be built from source or (for debian based distros) installed
via an Ubuntu PPA. Full instructions are available in the docs for
Build and Test
libstdapsdt is installed globally (e.g. from the PPA above or via
make install), you should be able to simply
go build or
go test. However if you
libstapsdt from source then you will need to tell the
how to find the headers and .so files for
libstapsdt using the
LD_LIBRARY_PATH environment variables.
export CGO_CFLAGS="-I/path/to/libstapsdt/src" export CGO_LDFLAGS="-L/path/to/libstapsdt/out" export LD_LIBRARY_PATH="/path/to/libstapsdt/out"
This repository contains a demo executable that will fire two different probes
every second. The demo can be observed using the
tplist tools from
the bcc project. Use two terminals to run the
demo - one to execute the tracable salpdemo go program and one to run the bcc
tools and see their output. In the first window run
go run internal/salpdemo.go
This program will print out how to monitor itself but then won't print out
anything after that. In the second window run the bcc trace program on the
salpdemo process, monitoring probes
sudo trace -p "$(pgrep salpdemo | head -n1)" \ 'u::p1 "arg1=%d arg2=%s", arg1, arg2' \ 'u::p2 "arg1=%d", arg1'
trace will output the values of
arg2 from probe
p1 and the
arg1 from probe