Question

I am currently observing traces of Erlang programs (using the Erlang:trace function), specifically the YAWS web server, although my problem may not be limited to this particular program.

Basically, when I attempt to trace some processes and output these traces, the following errors are displayed:

=ERROR REPORT==== 30-Mar-2014::15:48:25 === Failed to open trace "trace.<0.4084.0>.traffic": "I/O error"

=ERROR REPORT==== 30-Mar-2014::15:48:25 === Failed to open trace "trace.<0.4085.0>.traffic": "I/O error"

=ERROR REPORT==== 30-Mar-2014::15:48:26 === Failed to open trace "trace.<0.4086.0>.traffic": "I/O error"

I would appreciate any insight into why this error is occurring and how it can be solved.

Thanks!

EDIT: This is the code I am using:

looper()->
    receive
        P-> io:format(" trace msg: ~p ~n", [P])
    end,
    looper().

tracer2(Pid)->
    erlang:trace(Pid,true,[set_on_spawn, send, 'receive']),
    looper().

In the cmd, I first enter: ybed_sup:start_link() , then enter tracer2(PID) passing the PID of the process executing the function yaws_server:acceptor as a parameter.

At first, traces are printed correctly, but then this process dies and new processes with the functon yaws_server:acceptor are spawned, after which only the error messages show.

Was it helpful?

Solution

I think you might be confusing Erlang tracing and the tracing capabilities Yaws provides for HTTP requests. They are very different things.

The error you're seeing is caused by Yaws being unable to open the files mentioned in your error messages (for example, trace.<0.4084.0>.traffic), which by default are opened in the logdir specified in the yaws.conf file. You can read more about this near the top of the yaws.conf documentation or in the yaws.conf.5 man page that's part of your Yaws installation.

OTHER TIPS

After your EDIT:

I fully agree with Steve Vinoski answer.

Few notes:

  • with current logic you "freeze" you shell (cmd), you might want spawn a new process for loop/0 function
  • if you just would like to simply debug your system try using dbg module
  • if trace/2 function would fail you would get little different error message; something similar to

    ** exception error: bad argument in function erlang:trace/3 called as erlang:trace(a,b,c)

    so you can assume code you wrote works just fine

  • (as far as I understand you) you're tracing process that is spawning yaws acceptor; make sure that you turn on tracing before acceptor is spawned, or pass to your trace2/1 function pid returned from yaws_server:acceptor

And finally make sure that you configuration is ok. From what you are describing your log_dir might not exist (or you could forget to add flag allowing to create folder), or you might not have permission to write in this directory.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top