Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

Change request trace ID format #1591

Closed
natemcmaster opened this issue Apr 1, 2017 · 3 comments
Closed

Change request trace ID format #1591

natemcmaster opened this issue Apr 1, 2017 · 3 comments
Assignees
Milestone

Comments

@natemcmaster
Copy link
Contributor

Follow up to #1578. In this PR, we Kestrel started generating request IDs instead of letting aspnet/Hosting do this. At the moment, request IDs use the same code to generate connection ID and request ID.

We want to enhance this change further by making the requestID to the following format:

//pseudocode
var count = ++_connection.RequestCount;
HttpContext.TraceIdentifier = $"{_connection.ConnectionId}:{count.ToString("X").PadLeft(5, '0')}";

Result:

Connection 1 Id = 001BCA
  Request 1: Id = 001BCA:00000
  Request 2: Id = 001BCA:00001
...
  Request 11: Id= 001BCA:0000B

Connection 2 Id = 001BCB
  Request 1: Id = 001BCB:00000
  Request 2: Id = 001BCB:00001

In the unlikely event there are more than 0xFFFFF (1,048,575) requests per connection, the counter must not truncate to 5 characters, but use as many characters required to express request count in hex.

@muratg
Copy link
Contributor

muratg commented Apr 10, 2017

Let's make it future-proof. (PadLeft(10, '0')) maybe?

@muratg muratg added this to the 2.0.0 milestone Apr 10, 2017
@muratg
Copy link
Contributor

muratg commented Apr 10, 2017

@shirhatti FYI. We should connect this with the ETW work you're planning in ANCM.

@natemcmaster
Copy link
Contributor Author

natemcmaster commented Apr 27, 2017

Decided to go with this:

//pseudocode
uint count = ++_connection.RequestCount;
HttpContext.TraceIdentifier = $"{_connection.ConnectionId}:{count.ToString("X8")}";

The X8 format represents the full range of info in uint.
FYI - uint.MaxValue is 4.2 billion.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants