Created
September 23, 2025 18:36
-
-
Save snbeynon/750796ae67b76ac144cf13a560a45129 to your computer and use it in GitHub Desktop.
generate w3c traceparent header - tested on mac
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # set -eox | |
| # spec: https://www.w3.org/TR/trace-context | |
| # format = version "-" trace-id "-" parent-id "-" trace-flags | |
| # version = 00 ; always | |
| # trace-id = 32 hex ; 16 bytes array identifier. All zeroes forbidden | |
| # parent-id = 16 hex ; 8 bytes array identifier. All zeroes forbidden | |
| # trace-flags = 01 ; sampled | |
| VERSION="00" | |
| TRACE_ID="$(hexdump -vn "16" -e ' /1 "%02x"' /dev/urandom)" | |
| PARENT_ID="$(hexdump -vn "8" -e ' /1 "%02x"' /dev/urandom)" | |
| TRACE_FLAG="01" | |
| TRACE_PARENT="$VERSION-$TRACE_ID-$PARENT_ID-$TRACE_FLAG" | |
| echo "traceparent: $TRACE_PARENT" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment