Skip to content

Commit 17e696c

Browse files
committed
systemtap: add tapset for node user probes
This makes systemtap tracing prettier, you can do things like `stap -e 'probe node_http_server_request { println(probestr); }'`
1 parent 23509eb commit 17e696c

2 files changed

Lines changed: 180 additions & 0 deletions

File tree

src/node.stp

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
// Copyright Joyent, Inc. and other Node contributors.
2+
//
3+
// Permission is hereby granted, free of charge, to any person obtaining a
4+
// copy of this software and associated documentation files (the
5+
// "Software"), to deal in the Software without restriction, including
6+
// without limitation the rights to use, copy, modify, merge, publish,
7+
// distribute, sublicense, and/or sell copies of the Software, and to permit
8+
// persons to whom the Software is furnished to do so, subject to the
9+
// following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included
12+
// in all copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
21+
22+
23+
probe node_net_server_connection = process("node").mark("net__server__connection")
24+
{
25+
remote = user_string($arg2);
26+
port = $arg3;
27+
fd = $arg4;
28+
29+
probestr = sprintf("%s(remote=%s, port=%d, fd=%d)",
30+
$$name,
31+
remote,
32+
port,
33+
fd);
34+
}
35+
36+
probe node_net_stream_end = process("node").mark("net__stream__end")
37+
{
38+
remote = user_string($arg2);
39+
port = $arg3;
40+
fd = $arg4;
41+
42+
probestr = sprintf("%s(remote=%s, port=%d, fd=%d)",
43+
$$name,
44+
remote,
45+
port,
46+
fd);
47+
}
48+
49+
probe node_net_socket_write = process("node").mark("net__socket__write")
50+
{
51+
bytes = $arg2;
52+
remote = user_string($arg3);
53+
port = $arg4;
54+
fd = $arg5;
55+
56+
probestr = sprintf("%s(bytes=%d, remote=%s, port=%d, fd=%d)",
57+
$$name,
58+
bytes,
59+
remote,
60+
port,
61+
fd);
62+
}
63+
64+
probe node_net_socket_read = process("node").mark("net__socket__read")
65+
{
66+
bytes = $arg2;
67+
remote = user_string($arg3);
68+
port = $arg4;
69+
fd = $arg5;
70+
71+
probestr = sprintf("%s(bytes=%d, remote=%s, port=%d, fd=%d)",
72+
$$name,
73+
bytes,
74+
remote,
75+
port,
76+
fd);
77+
}
78+
79+
probe node_http_server_request = process("node").mark("http__server__request")
80+
{
81+
remote = user_string($arg3);
82+
port = $arg4;
83+
method = user_string($arg5);
84+
url = user_string($arg6);
85+
fd = $arg7;
86+
87+
probestr = sprintf("%s(remote=%s, port=%d, method=%s, url=%s, fd=%d)",
88+
$$name,
89+
remote,
90+
port,
91+
method,
92+
url,
93+
fd);
94+
}
95+
96+
probe node_http_server_response = process("node").mark("http__server__response")
97+
{
98+
remote = user_string($arg2);
99+
port = $arg3;
100+
fd = $arg4;
101+
102+
probestr = sprintf("%s(remote=%s, port=%d, fd=%d)",
103+
$$name,
104+
remote,
105+
port,
106+
fd);
107+
}
108+
109+
probe node_http_client_request = process("node").mark("http__client__request")
110+
{
111+
remote = user_string($arg3);
112+
port = $arg4;
113+
method = user_string($arg5);
114+
url = user_string($arg6);
115+
fd = $arg7;
116+
117+
probestr = sprintf("%s(remote=%s, port=%d, method=%s, url=%s, fd=%d)",
118+
$$name,
119+
remote,
120+
port,
121+
method,
122+
url,
123+
fd);
124+
}
125+
126+
probe node_http_client_response = process("node").mark("http__client__response")
127+
{
128+
remote = user_string($arg2);
129+
port = $arg3;
130+
fd = $arg4;
131+
132+
probestr = sprintf("%s(remote=%s, port=%d, fd=%d)",
133+
$$name,
134+
remote,
135+
port,
136+
fd);
137+
}
138+
139+
probe node_gc_start = process("node").mark("gc__start")
140+
{
141+
scavenge = 1 << 0;
142+
compact = 1 << 1;
143+
144+
if ($arg1 == scavenge)
145+
type = "kGCTypeScavenge";
146+
else if ($arg1 == compact)
147+
type = "kGCTypeMarkSweepCompact";
148+
else
149+
type = "kGCTypeAll";
150+
151+
flags = $arg2;
152+
153+
probestr = sprintf("%s(type=%s,flags=%d)",
154+
$$name,
155+
type,
156+
flags);
157+
}
158+
159+
probe node_gc_stop = process("node").mark("gc__stop")
160+
{
161+
scavenge = 1 << 0;
162+
compact = 1 << 1;
163+
164+
if ($arg1 == scavenge)
165+
type = "kGCTypeScavenge";
166+
else if ($arg1 == compact)
167+
type = "kGCTypeMarkSweepCompact";
168+
else
169+
type = "kGCTypeAll";
170+
171+
flags = $arg2;
172+
173+
probestr = sprintf("%s(type=%s,flags=%d)",
174+
$$name,
175+
type,
176+
flags);
177+
}

tools/install.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ def files(action):
126126
# with dtrace support now (oracle's "unbreakable" linux)
127127
action(['src/node.d'], 'lib/dtrace/')
128128

129+
# behave similarly for systemtap
130+
action(['src/node.stp'], 'share/systemtap/tapset/')
131+
129132
if 'freebsd' in sys.platform or 'openbsd' in sys.platform:
130133
action(['doc/node.1'], 'man/man1/')
131134
else:

0 commit comments

Comments
 (0)