Instrumenting Erlang code

Edmond Begumisa ebegumisa@REDACTED
Wed Jan 29 11:30:34 CET 2020


Hi,

Years ago, Tim Watson wrote a neat AOP-style library which uses function  
attributes to do just that...

https://github.com/hyperthunk/annotations
	
I haven't used it in a while, but I see the README was more recently  
updated so I presume it still works.

- Edmond -

On Sun, 26 Jan 2020 22:58:04 +1000, Frank Muller  
<frank.muller.erl@REDACTED> wrote:

> Hi everyone
>
> I would like to implement a custom instrumentation module for my Erlang  
> code.
> Let assume this function:
>
> f1() ->
>   … code here …
>   ok.
>
> When instrumenting this function, I would like it to look like:
>
> f1() ->
>   instrument:start(),
>
>   … code here …
>
>   instrument:end(), <— just before retuning from f1  ok.
>
>> Other problem I can think of is when we have multiple return paths  
>> and/or recursive loop:
>
> f2() ->
>  instrument:start(),
>
>  receive ->
>    {msg1, M1} -> instrument:end(), M1;
>    {msg2, M2} -> instrument:end(), M2;
>    _ -> instrument:end(), f2()
>  end.
>
> Is that doable?
> If yes, can I apply like this logic to all modules running in my Erlang  
> node?
>
> @Kostis: does Concuerror (https://github.com/parapluu/Concuerror) use  
> this technique?
>
> Thanks for you help.
> /Frank
>
>



-- 
Using Opera's mail client: http://www.opera.com/mail/



More information about the erlang-questions mailing list