using (Activity activity = source.StartActivity("demo"))
{
Console.WriteLine(activity?.Id);
}
the output is something like 00-bbd8c75b04cda7f7fe9ee03b54b2d7ba-72dc8c0dc24fc406-01
and it always has two leading 0s and trailing 01, what does those two leading 0s and trailing 01 mean?
also the trace id is bbd8c75b04cda7f7fe9ee03b54b2d7ba, according to the w3c format, trace-id that is 16 bytes. but isn't that bbd8c75b04cda7f7fe9ee03b54b2d7ba 32 bytes since it has 32 characters?
It looks like you're using the W3C activity ID format. (See the
DefaultIdFormatproperty for details of that.The W3C format is documented here as traceparent. Importantly:
So basically the
00is the version, and01is the trace flag, meaning "sampled".The trace ID is 32 characters because it's hex-encoded binary data - it's only 16 bytes. (Just like the version number is a single byte, encoded as two hex digits.)