Tapper Plug v0.2.0 Tapper.Plug.HeaderPropagation
Decode/Encode B3 Headers to/from trace properties.
Summary
Types
Functions
Decode B3 headers from a list of {header_name, header_value}
tuples.
Returns either the atom :start
if (valid) B3 headers were not present (which is a suggestion,
rather than an instruction, since sampling is a separate concern), or the tuple
{:join, trace_id, span_id, parent_span_id, sampled, debug}
which passes on the decoded
values of the B3 headers. Note that if the parent_span_id is absent, implying the root
span, this function sets it to the atom :root
, rather than nil
.
Whether the trace should be sampled on a :join
result depends on the values of sampled
and debug
.
sampled
can be true
(the originator is sampling this trace, and expects us to do so too) or false
when the originator is not sampling this trace and doesn’t expect us to either, or the atom :absent
when the originator does not pass the X-B3-Sampled
header, implying that determining whether to trace
is up to us. The debug
flag, if true
implies we should always sample the trace regardless of the
sampled
status:
Result | sampled | debug | should sample? |
---|---|---|---|
:join | false | false | no |
:join | true | false | yes |
:join | false | true | yes |
:join | true | true | yes |
:join | :absent | true | yes |
:join | :absent | false | maybe |
Encode a Tapper id into a list of B3 propagation headers,
i.e. a list of 2-tuples like {"x-b3-traceid", "463ac35c9f6413ad48485a3953bb6124"}
.
Example
id = Tapper.start_span(id, name: "foo")
...
headers = Tapper.Plug.HeaderPropagation.encode(id)
response = HTTPoison.get("http://some.service.com/some/api", headers)