Module passage_transform

A parse_transform module for passage

Copyright © 2017 Takeru Ohta <phjgt308@gmail.com>

Description

A parse_transform module for passage

This module handles passage_trace attribute.

If the attribute is appeared, the next function will be traced automatically.

See following example:

  -module(example).
 
  -compile({parse_transform, passage_transform}). % Enables `passage_transform'
 
  -passage_trace([{tags, #{foo => bar}}, {eval_tags, #{size => "byte_size(Bin)"}}]).
  -spec foo(binary()) -> binary().
  foo(Bin) ->
    <<"foo", Bin/binary>>.

The above foo function will be transformed as follows:

  foo(Bin) ->
    try
      passage_pd:start_span(
        'example:foo/1',
        [{tags, #{application => example, module => example, line => 7, foo => bar}}]),
      passage_pd:set_tags(#{process => self(), size => byte_size(Bin)}),
      <<"foo", Bin/binary>>
    after
      passage_pd:finish_span()
    end.

References

Data Types

expr_string()

expr_string() = string()

The textual representation of an expression.

When used, it will be converted to an AST representation as follows:

  {ok, Tokens, _} = erl_scan:string(ExprString ++ "."),
  {ok, [Expr]} = erl_parse:parse_exprs(Tokens).

passage_trace_option()

passage_trace_option() = {tracer, passage:tracer_id()} | {tags, passage:tags()} | {eval_tags, #{passage:tag_name() => expr_string()}} | {child_of, expr_string()} | {follows_from, expr_string()} | {error_if, expr_string()} | error_if_exception

Function Index

parse_transform/2Performs transformations for passage

Function Details

parse_transform/2

parse_transform(AbstractForms, CompileOptions::list()) -> AbstractForms

Performs transformations for passage


Generated by EDoc, Oct 28 2017, 19:00:50.