Tracing ruby applications with LTTng.
A simple API for sending tracepoints from Ruby programs to LTTng.
You need to have the lttng-ust library and headers installed on your system to build this.
The documentation for lttng will be useful for understanding how to make good use of this gem. http://lttng.org/docs/
$ lttng create $ lttng enable-channel channel0 -u $ lttng enable-event 'ruby_log:*' -u -c channel0 $ lttng start $ my-ruby-program.rb $ lttng stop $ lttng view | less $ lttng destroy
Note that logs aren’t deleted when you run lttng destroy, only the lttng session. The logs are stored by default in ~/lttng-traces.
require 'lttng-agent-ruby' require 'lttng-agent-ruby/logger' logger = LTTngLogger.new logger.info("Something informative")
Note that the standard 'formatter' attribute is present for compatibility with applications that expect it to be present, but has no effect when used.
require 'lttng-agent-ruby' require 'lttng-agent-ruby/logger' require 'tracer' tracer = TracePoint.new() {|tp| LTTng.debug(tp.inspect) } tracer.enable
Be careful about the span of your program covered by tracing at this level; this can use up disk space at alarming rates!
Until I can provide a more comprehensive tool, I’ve put together a couple libraries that can parse the output of the babeltrace tool.
Using these parsers requires that you have the 'parslet' gem installed, but as it’s not a hard requirement for using the core facilities of LTTng, it’s not a dependency.