Sibyl.Decorator (Sibyl v0.1.11)
View SourceModule encapsulating Sibyl's business logic for decorating functions for automated tracing.
Should be used only via use Sibyl
.
When used like this, provides the ability to decorate your function calls with:
@decorate trace()
to automatically trace a single function's execution, emitting telemetry events for:start
,:end
, and:exception
sub-events.@decorate_all trace()
which does the same as the above, but automatically for all functions in a module.
Automatically traced functions are available for reflection by via Sibyl.Events.reflect/1
.
Summary
Functions
Decorator which wraps a given function with a standard telemetry span.
Functions
@spec trace(function_body :: Sibyl.AST.ast(), ctx :: map()) :: Sibyl.AST.ast() | no_return()
Decorator which wraps a given function with a standard telemetry span.
The name of the captured event will be determined by however Sibyl
is configured
to generate event names.
Due to how anonymous functions are defined and executed in the BEAM, it ends up
being quite a bit more performant to build the span manually rather than using
:telemetry.span/3
.
See here for an example of how to emit the correct events.
See here for explanations w.r.t. anonymous function perf.