Giter Site home page Giter Site logo

tracer's Introduction

dbg:tracer/0 drop-in replacement

Tracing built into the Erlang VM is an enormously powerful mechanism, both for troubleshooting live systems as well as visualising components in development.

This is a tracer template which can be used as a drop-in replacement for dbg:tracer(). Why? Sometimes it's convenient to truncate/reformat/omit some parts of trace messages to get better clarity or more accurate traces.

Default dbg:dhandler/2 is nice, but when you want to use domain knowledge or discard some of the data (like too long arg lists or returned values) it might be convenient to write your own dbg handler function. However, this is error prone and since you can't trace your trace function (d'oh!) it's hard to debug.

The way to go is to setup a monitor on the trace handler process. When the trace function errors and kills the tracer process, you'll be notified. Still, if the monitor is setup by the shell, the 'DOWN' message might simply end up in the message queue of the shell and never be received - you won't know a crash happened.

So, it's best to setup a process which will monitor the trace handler and print any 'DOWN' messages it receives. This is done in my_tracer:start/0.

Usage

Instead of:

dbg:tracer().
dbg:p(all, [call, timestamp]).
dbg:tpl(mod_reauth, set_timer_for_new_session, x).

Do:

code:add_path("/Users/erszcz/work/erszcz/tracer").
my_tracer:start().
dbg:p(all, [call, timestamp]).
dbg:tpl(mod_reauth, set_timer_for_new_session, x).

The rest (i.e. filtering/formatting traces) is up to you. Open my_tracer.erl in your editor and hack away!

tracer's People

Contributors

erszcz avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.