moontel Showcase · the header, in your hands Showcase GitHub
Showcase

A header you
can take apart.

Fifty-five characters, four fields, and a rule for each. Type one, break one, or send it on a hop — every answer on this page comes from the library, compiled to JavaScript and running in this tab.

Fields
four, separated by dashes
Ids
16 and 8 octets, lowercase hex
Answers
from parse, start, inject
The header

Edit it, or start from one of these:

What the library read

Reading…

02

What the next hop sends.

The same trace id, a new span id. One header is replaced, the other travels as it arrived.

Press “send it to the next hop”.

03

Three steps, in this order.

A hop reads, joins and writes. The page above calls the same three functions a server does; nothing in the browser reimplements them.

01

Read

parse accepts the header or refuses it with the offset and the shape it wanted. A hop that only wants to get on with the request calls extract, which starts a new trace instead of failing.

fn read(header : StringView) -> @trace.TraceContext raise {
  @propagate.parse(header)
}
02

Join

The new span takes the trace id and the vendor state from the parent. Its own span id is minted, and the sampler is asked once, with the parent in hand.

fn join(
  tracer : @trace.Tracer,
  parent : @trace.TraceContext,
  now : () -> Int64,
) -> @trace.Span raise {
  tracer.start(
    "GET /orders/42",
    parent=parent,
    kind=@trace.Server,
    at=now(),
  )
}
03

Write

inject replaces the two propagation headers on the outgoing request, so the sender's context cannot survive beside the one this hop decided on.

fn write(
  request_headers : Array[(String, String)],
  span : @trace.Span,
) -> Array[(String, String)] {
  @propagate.inject(request_headers, {
    context: Some(span.context()),
    baggage: @propagate.empty_baggage,
  })
}