README is markdown
Modified README
Cleaned up example
luajit-stapsdt
is a library lets you define SystemTap Statically Defined Tracing (stapsdt) probes in LuaJIT. This gives you the power of Linux's eBPF tracing infrastructure in LuaJIT. It does this by binding the libstapsdt
library, which can be acquired here.
luajit-stapsdt
has only been tested on x86_64 Linux, it may work on other arches as well eventually, but this depends on libstapsdt
. Currently, libstapsdt
seems to only claim support for x86_64 Linux.
libstapsdt
Lightweight tracing is very useful. Lightweight tracing with useful contextual information is even more useful. We can get this with Linux's eBPF subsystem, as long as we provide the probes it can hook into. This library lets you define such hooks in your LuaJIT programs.
-- Load the library
local trace = require "stapsdt"
-- Make a provider
local p = trace.provider "myprovider"
-- Add a probe to the provider
p:probe("myprobe", "u8")
-- load the provider, after this, you can start tracing with eBPF. bcc-tools is
-- recommended for this purpose.
p:load()
-- fire off a probe
p:fire("myprobe", 42)
-- Unload the provider (this is not normally necessary)
p:unload()
-- The underlying structures will be cleaned up automatically
p = nil
Read the source in stapsdt.lua
for more information. There is a more in-depth example at example_primes.lua
MIT
Brendan Gregg's book "BPF Performance Tools" is very good and recommended to learn more. His blog is great as well.