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'
  -compile({passage_default_tracer, "foo_tracer"}). % Specifies the default tracer (optional)
 
  -passage_trace([{tags, #{foo => "bar", size => "byte_size(Bin)"}}]).
  -spec foo(binary()) -> binary().
  foo(Bin) ->
    <<"foo", Bin/binary>>.

The above foo function will be transformed as follows:

  foo(Bin) ->
    passage_pd:start_span('example:foo/1', []),
    try
      passage_pd:set_tags(
          fun () ->
              #{
                  'location.pid' => self(),
                  'location.application' => example,
                  'location.module' => example,
                  'location.line' => 7
                  foo => bar,
                  size => byte_size(Bin)
               }
          end),
      <<"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, expr_string()} | {tags, #{passage:tag_name() => expr_string()}} | {child_of, expr_string()} | {follows_from, expr_string()} | {error_if, expr_string()} | {error_if_exception, boolean()}

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