Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nginx: how to generate X-B3-SpanId 16 random bytes for tracing

I'm trying to generate zipkin trace id from nginx in order to be able to trace from nginx to applications. To achieve this, I want to find out how to generate 16 random bytes to be used for X-B3-SpanId since $request_id generates 32 bytes (which can be used for X-B3-TraceId).

like image 382
Thomas Lee Avatar asked Nov 20 '25 02:11

Thomas Lee


1 Answers

FYI, this worked after generating dummy X-B3-SpanId; it works as long as X-B3-TraceId is unique.

e.g.

map $http_x_b3_traceid $_request_id {
    default   $http_x_b3_traceid;
    ""        $request_id;
}
map $http_x_b3_spanid $_span_id {
    default   $http_x_b3_spanid;
    ""        "1111111111111111";
}
like image 169
Thomas Lee Avatar answered Nov 21 '25 20:11

Thomas Lee



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!