Tapper Plug v0.2.0 Tapper.Plug.Trace

Intercept B3 headers and join a sampled trace, or run a sampler to determine whether to start a new trace.

If starting a trace, a ‘server receive’ (sr) annotation will be added to the root span, as well as details about the request. A call-back is installed to finish the trace at the end of the request, adding additional http.status_code and a ‘server send’ (ss) annotations.

plug Tapper.Plug.Trace, sampler: Tapper.Plug.Sampler.Simple, percent: 25

or e.g.

plug Tapper.Plug.Trace, sampler: fn(conn, _config) -> String.starts_with?(conn.request_path, ["/foo", "/bar"]) end

Options

  • sampler - name of module with sample?/2, or a fun with arity 2, to call to determine whether to sample a request; see Tapper.Plug.Sampler.
  • debug - if set to true all requests, joined or started, will be sampled.
  • tapper - keyword list passed on to Tapper.start/1 or Tapper.join/6 (useful for testing/debugging, but use with caution since overrides options set by this module).

All options, including custom ones, will be passed to the sampler function (as a map), which means it can be configured here too.

Annotations

Tapper.Plug sets the following annotations:

  • sr - server receive on starting or joining a trace.
  • ca - client address, from conn.remote_ip.
  • http.host, http.method, http.path - from corresponding Plug.Conn fields.
  • ss - server send when finishing a trace.

Summary

Functions

Callback implementation for Plug.call/2

Callback implementation for Plug.init/1

join a trace, running the sampler if ‘sampled’ not expicitly sent

start a trace, running the sampler

Functions

call(conn, config)

Callback implementation for Plug.call/2.

init(opts)

Callback implementation for Plug.init/1.

join(conn, config, trace_id, span_id, parent_id, sample, debug)

join a trace, running the sampler if ‘sampled’ not expicitly sent

start(conn, config)

start a trace, running the sampler