Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

why Activity.Id has two leading 0s and trailing 01?

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

It looks like you’re using the W3C activity ID format. (See the DefaultIdFormat property for details of that.

The W3C format is documented here as traceparent. Importantly:

value           = version "-" version-format

Version (version) is 1 byte representing an 8-bit unsigned integer. Version ff is invalid. The current specification assumes the version is set to 00.

trace-flags An 8-bit field that controls tracing flags such as sampling, trace level, etc. […] The current version of this specification (00) only supports a single flag called sampled. When set, the least significant bit (right-most), denotes that the caller may have recorded trace data.

So basically the 00 is the version, and 01 is 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.)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading