Sibyl.Experimental (Sibyl v0.1.11)

View Source

This is an experimental module for Sibyl which aims to replace the use Sibyl macro with something that does not rely on the existing decorator library in Elixir.

This is due to limitations in the decorator library which prevent us from being able to trace functions which define multiple function clauses with default paramters due to the way its implemented.

This module implements the bare neccessities to get Sibyl working without the decorator library, and as such, does not intend to replace the decorator library in general (though it could definitely be possible in the future).

We do this by replacing Elixir's def macro when defining functions to a custom one which checks if you've opted into function tracing. If so, then we amend the AST of the function to include tracing code before passing it back to Elixir's def macro.

This is a very hacky way of doing things, but it seems to generally work.

There are two notable, core differences in using Sibyl.Experimental over Sibyl for the time being:

  1. In order to trace functions, you must annotate functions with @sibyl trace: true. In future, we may be able to capture extra metadata to attach to traces via additional keyword parameters.

  2. In order to trace all functions in a module, you must use Sibyl.Experimental, trace_all: true. Theoretically any metadata attached to individual functions should still be respected.

For reflection purposes, you can also use call __traces__/0 on any module that uses Sibyl.Experimental though for compatibility you may prefer to continue using Sibyl.Events.reflect/1 instead.

Summary

Functions

def(call, list)

(macro)