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
|
#!/bin/sh
set -o errexit
libraft_path="${LIBRAFT_SO_PATH:-/usr/local/lib/libraft.so.2}"
exec bpftrace -I resources -I include $@ - <<EOF
#include <raft.h>
struct request
{
void *data;
int type;
raft_index index;
queue queue;
};
uprobe:$libraft_path:lifecycleRequestStart
{
\$req = (struct request *)arg1;
@start_request[\$req->data, \$req->type, \$req->index] = nsecs;
}
uprobe:$libraft_path:lifecycleRequestEnd
{
\$req = (struct request *)arg1;
\$start = @start_request[\$req->data, \$req->type, \$req->index];
\$end = nsecs;
@full[\$req->data, \$req->type, \$req->index] = (\$start, \$end);
\$elapsed_msecs = (\$end - \$start) / 1000;
@hist = lhist(\$elapsed_msecs, 100, 1000, 10);
delete(@start_request[\$req->data, \$req->type, \$req->index]);
}
EOF
|