No subject
Tue Apr 12 10:32:41 BST 2011
erlang$target:::function-entry
/self->traceIt/
{
//do something here
}
and so on.
You can run the gist like: sudo dtrace -s route.d -p `pgrep beam.smp`
The examples are really basic but I think they illustrate the point. With
that Erlang branch you could enable more granular probes than with the usua=
l
pid provider or dtruss.
BTW, this works on Mac and Solaris. AFAIK on Linux some Kernel modules are
required.
Cheers,
Alvaro
--20cf30563e3bcab9b904acfb56f4
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<a href=3D"https://twitter.com/hylomorphism/status/114000680875851776"></a>=
<a href=3D"https://twitter.com/hylomorphism/status/114000680875851776"></a>=
<a href=3D"https://twitter.com/hylomorphism/status/114000680875851776"></a>=
<a href=3D"https://twitter.com/hylomorphism/status/114000680875851776"></a>=
<a href=3D"https://twitter.com/hylomorphism/status/114000680875851776"></a>=
<div>
Hi,</div><div><br></div><div>I saw Matthew tweeting "Oh RabbitMQ, why =
are you taking over an hour to recover 100k queues? What /are/ you doing?!&=
quot;=A0<a href=3D"https://twitter.com/hylomorphism/status/1140006808758517=
76">https://twitter.com/hylomorphism/status/114000680875851776</a>=A0</div>
<div><br></div><div>I've been doing some stuff at work with DTrace and =
I think is pretty cool when it comes to find out what a process is actually=
doing.</div><div><br></div><div>At the same time there's an experiment=
al OTP fork on Github that adds Dtrace probes to Erlang:=A0<a href=3D"https=
://github.com/dustin/otp/wiki/DTrace">https://github.com/dustin/otp/wiki/DT=
race</a></div>
<div><br></div><div>See here for the available probes:=A0<a href=3D"https:/=
/github.com/dustin/otp/blob/dtrace/erts/emulator/beam/erlang_dtrace.d">http=
s://github.com/dustin/otp/blob/dtrace/erts/emulator/beam/erlang_dtrace.d</a=
></div>
<div><br></div><div>So for example running RabbitMQ based on that Erlang br=
anch you could do things like in this gist:=A0<a href=3D"https://gist.githu=
b.com/1219266">https://gist.github.com/1219266</a></div><div><br></div><div=
>
<span class=3D"Apple-style-span" style=3D"font-family: helvetica, arial, fr=
eesans, clean, sans-serif; font-size: 11px; line-height: 14px; "><pre style=
=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0p=
x; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left:=
0px; font: normal normal normal 12px/normal Monaco, 'Courier New',=
'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;=
line-height: 1.4em; font-family: 'Bitstream Vera Sans Mono', Couri=
er, monospace; ">
<div class=3D"line" id=3D"LC1" style=3D"margin-top: 0px; margin-right: 0px;=
margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px=
; padding-bottom: 0px; padding-left: 1em; line-height: 1.4em; "><span class=
=3D"n" style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; mar=
gin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; p=
adding-left: 0px; line-height: 1.4em; ">erlang</span><span class=3D"p" styl=
e=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0=
px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left=
: 0px; line-height: 1.4em; ">$</span><span class=3D"n" style=3D"margin-top:=
0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top:=
0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-heig=
ht: 1.4em; ">target</span><span class=3D"p" style=3D"margin-top: 0px; margi=
n-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; paddi=
ng-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.4em; =
">:::</span><span class=3D"k" style=3D"margin-top: 0px; margin-right: 0px; =
margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px;=
padding-bottom: 0px; padding-left: 0px; line-height: 1.4em; font-weight: b=
old; ">function</span><span class=3D"p" style=3D"margin-top: 0px; margin-ri=
ght: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-r=
ight: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.4em; ">-<=
/span><span class=3D"n" style=3D"margin-top: 0px; margin-right: 0px; margin=
-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; paddi=
ng-bottom: 0px; padding-left: 0px; line-height: 1.4em; ">entry</span></div>
<div class=3D"line" id=3D"LC2" style=3D"margin-top: 0px; margin-right: 0px;=
margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px=
; padding-bottom: 0px; padding-left: 1em; line-height: 1.4em; "><span class=
=3D"p" style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; mar=
gin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; p=
adding-left: 0px; line-height: 1.4em; ">/</span><span class=3D"n" style=3D"=
margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; p=
adding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px=
; line-height: 1.4em; ">copyinstr</span><span class=3D"p" style=3D"margin-t=
op: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-t=
op: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-h=
eight: 1.4em; ">(</span><span class=3D"n" style=3D"margin-top: 0px; margin-=
right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding=
-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.4em; ">=
arg1</span><span class=3D"p" style=3D"margin-top: 0px; margin-right: 0px; m=
argin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; =
padding-bottom: 0px; padding-left: 0px; line-height: 1.4em; ">)</span> <spa=
n class=3D"p" style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0=
px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom:=
0px; padding-left: 0px; line-height: 1.4em; ">=3D=3D</span> <span class=3D=
"s" style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin=
-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padd=
ing-left: 0px; line-height: 1.4em; color: rgb(221, 17, 68); ">"rabbit_=
exchange_type_direct:route/2"</span><span class=3D"p" style=3D"margin-=
top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-=
top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-=
height: 1.4em; ">/</span></div>
<div class=3D"line" id=3D"LC3" style=3D"margin-top: 0px; margin-right: 0px;=
margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px=
; padding-bottom: 0px; padding-left: 1em; line-height: 1.4em; "><span class=
=3D"p" style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; mar=
gin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; p=
adding-left: 0px; line-height: 1.4em; ">{</span></div>
<div class=3D"line" id=3D"LC4" style=3D"margin-top: 0px; margin-right: 0px;=
margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px=
; padding-bottom: 0px; padding-left: 1em; line-height: 1.4em; ">=A0=A0=A0=
=A0<span class=3D"n" style=3D"margin-top: 0px; margin-right: 0px; margin-bo=
ttom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-=
bottom: 0px; padding-left: 0px; line-height: 1.4em; ">printf</span><span cl=
ass=3D"p" style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px=
; padding-left: 0px; line-height: 1.4em; ">(</span><span class=3D"s" style=
=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0p=
x; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left:=
0px; line-height: 1.4em; color: rgb(221, 17, 68); ">"%s %s"</spa=
n><span class=3D"p" style=3D"margin-top: 0px; margin-right: 0px; margin-bot=
tom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-b=
ottom: 0px; padding-left: 0px; line-height: 1.4em; ">,</span> <span class=
=3D"n" style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; mar=
gin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; p=
adding-left: 0px; line-height: 1.4em; ">probemod</span><span class=3D"p" st=
yle=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left:=
0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-le=
ft: 0px; line-height: 1.4em; ">,</span> <span class=3D"n" style=3D"margin-t=
op: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-t=
op: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-h=
eight: 1.4em; ">probefunc</span><span class=3D"p" style=3D"margin-top: 0px;=
margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px;=
padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1=
.4em; ">);</span></div>
<div class=3D"line" id=3D"LC5" style=3D"margin-top: 0px; margin-right: 0px;=
margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px=
; padding-bottom: 0px; padding-left: 1em; line-height: 1.4em; ">=A0=A0=A0=
=A0<span class=3D"n" style=3D"margin-top: 0px; margin-right: 0px; margin-bo=
ttom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-=
bottom: 0px; padding-left: 0px; line-height: 1.4em; ">self</span><span clas=
s=3D"p" style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; ma=
rgin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; =
padding-left: 0px; line-height: 1.4em; ">-></span><span class=3D"n" styl=
e=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0=
px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left=
: 0px; line-height: 1.4em; ">traceIt</span> <span class=3D"p" style=3D"marg=
in-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; paddi=
ng-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; li=
ne-height: 1.4em; ">=3D</span> <span class=3D"mi" style=3D"margin-top: 0px;=
margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px;=
padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1=
.4em; color: rgb(0, 153, 153); ">1</span><span class=3D"p" style=3D"margin-=
top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-=
top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-=
height: 1.4em; ">;</span></div>
<div class=3D"line" id=3D"LC6" style=3D"margin-top: 0px; margin-right: 0px;=
margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px=
; padding-bottom: 0px; padding-left: 1em; line-height: 1.4em; "><span class=
=3D"p" style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; mar=
gin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; p=
adding-left: 0px; line-height: 1.4em; ">}</span></div>
</pre></span></div><div><br></div><div>There I enable the flag traceIt only=
when route/2 is called on the direct exchange.</div><div><br></div><div>Fr=
om there is just a matter of adding probes to different syscalls or io acce=
ss etc based using patterns on that flag like:</div>
<div><span class=3D"Apple-style-span" style=3D"font-family: 'Bitstream =
Vera Sans Mono', Courier, monospace; font-size: 12px; line-height: 16px=
; white-space: pre; "><span class=3D"n" style=3D"margin-top: 0px; margin-ri=
ght: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-r=
ight: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.4em; "><b=
r>
</span></span></div><div><span class=3D"Apple-style-span" style=3D"font-fam=
ily: 'Bitstream Vera Sans Mono', Courier, monospace; font-size: 12p=
x; line-height: 16px; white-space: pre; "><span class=3D"n" style=3D"margin=
-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding=
-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line=
-height: 1.4em; ">erlang</span><span class=3D"p" style=3D"margin-top: 0px; =
margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; =
padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.=
4em; ">$</span><span class=3D"n" style=3D"margin-top: 0px; margin-right: 0p=
x; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0=
px; padding-bottom: 0px; padding-left: 0px; line-height: 1.4em; ">target</s=
pan><span class=3D"p" style=3D"margin-top: 0px; margin-right: 0px; margin-b=
ottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding=
-bottom: 0px; padding-left: 0px; line-height: 1.4em; ">:::</span><span clas=
s=3D"k" style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; ma=
rgin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; =
padding-left: 0px; line-height: 1.4em; font-weight: bold; ">function</span>=
<span class=3D"p" style=3D"margin-top: 0px; margin-right: 0px; margin-botto=
m: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bot=
tom: 0px; padding-left: 0px; line-height: 1.4em; ">-</span><span class=3D"n=
" style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-l=
eft: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; paddin=
g-left: 0px; line-height: 1.4em; ">entry</span></span></div>
<div><span class=3D"Apple-style-span" style=3D"font-family: 'Bitstream =
Vera Sans Mono', Courier, monospace; font-size: 12px; line-height: 16px=
; white-space: pre; "><span class=3D"p" style=3D"margin-top: 0px; margin-ri=
ght: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-r=
ight: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.4em; ">/<=
/span><span class=3D"n" style=3D"margin-top: 0px; margin-right: 0px; margin=
-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; paddi=
ng-bottom: 0px; padding-left: 0px; line-height: 1.4em; ">self</span><span c=
lass=3D"p" style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px;=
margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0p=
x; padding-left: 0px; line-height: 1.4em; ">-></span><span class=3D"n" s=
tyle=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left=
: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-l=
eft: 0px; line-height: 1.4em; ">traceIt</span><span class=3D"p" style=3D"ma=
rgin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; pad=
ding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; =
line-height: 1.4em; ">/</span></span></div>
<div><span class=3D"Apple-style-span" style=3D"font-family: 'Bitstream =
Vera Sans Mono', Courier, monospace; font-size: 12px; line-height: 16px=
; white-space: pre; "><span class=3D"p" style=3D"margin-top: 0px; margin-ri=
ght: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-r=
ight: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.4em; ">{<=
/span></span></div>
<div><span class=3D"Apple-style-span" style=3D"font-family: 'Bitstream =
Vera Sans Mono', Courier, monospace; font-size: 12px; line-height: 16px=
; white-space: pre; "><span class=3D"p" style=3D"margin-top: 0px; margin-ri=
ght: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-r=
ight: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.4em; "> /=
/do something here</span></span></div>
<div><span class=3D"Apple-style-span" style=3D"font-family: 'Bitstream =
Vera Sans Mono', Courier, monospace; font-size: 12px; line-height: 16px=
; white-space: pre; "><span class=3D"p" style=3D"margin-top: 0px; margin-ri=
ght: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-r=
ight: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.4em; ">}<=
/span></span></div>
<div><br></div><div>and so on.=A0</div><div><br></div><div>You can run the =
gist like:=A0<span class=3D"Apple-style-span" style=3D"color: rgb(51, 51, 5=
1); font-family: helvetica, arial, freesans, clean, sans-serif; font-size: =
12px; line-height: 18px; ">sudo dtrace -s route.d -p `pgrep beam.smp`</span=
></div>
<div><br></div><div>The examples are really basic but I think they illustra=
te the point. With that Erlang branch you could enable more granular probes=
than with the usual pid provider or dtruss.</div><div><br></div><div>BTW, =
this works on Mac and Solaris. AFAIK on Linux some Kernel modules are requi=
red.</div>
<div><br></div><div>Cheers,</div><div><br></div><div>Alvaro</div>
--20cf30563e3bcab9b904acfb56f4--
More information about the rabbitmq-discuss
mailing list