Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Adding a feature to get the traceidentifier for a request #210

Merged
merged 1 commit into from
Mar 4, 2015
Merged

Adding a feature to get the traceidentifier for a request #210

merged 1 commit into from
Mar 4, 2015

Conversation

Praburaj
Copy link
Contributor

@Praburaj Praburaj commented Mar 3, 2015

Addresses : #117

Related changes in Helios & weblistener in separate PRs.

@Tratcher

@ghost
Copy link

ghost commented Mar 3, 2015

Hi @Praburaj, I'm your friendly neighborhood Microsoft Open Technologies, Inc. Pull Request Bot (You can call me MSOTBOT). Thanks for your contribution!


It looks like you're a Microsoft contributor (Praburaj Thiagarajan). If you're full-time, we DON'T require a Contribution License Agreement. If you are a vendor, please DO sign the electronic Contribution License Agreement. It will take 2 minutes and there's no faxing! https://cla2.msopentech.com.

TTYL, MSOTBOT;

@Praburaj
Copy link
Contributor Author

Praburaj commented Mar 3, 2015

/CC @GrabYourPitchforks

@GrabYourPitchforks
Copy link
Contributor

:shipit:
As an aside, do we need a feature along the lines of "tell me the exact time the request started"? These two capabilities usually come hand-in-hand.

@Praburaj
Copy link
Contributor Author

Praburaj commented Mar 3, 2015

Sure @GrabYourPitchforks. We can add a DateTime field to this interface having that information.

/// <summary>
/// Identifier to trace a request.
/// </summary>
Guid TraceIdentifier { get; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason this is specifically a Guid and not a string? (The OWIN spec doesn't specify a format.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW I'm not suggesting it should be a string, just asking.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Traditionally these have been GUIDs so that they can be flowed via the CorrelationManager.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that makes sense... but not really 😄 I'm not really opposed to it being a GUID, it just seems so arbitrary (even in CorrelationManager). I mean what's so special about GUIDs anyway - a correlation id is logically an opaque value. So honestly I'm fine either way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GUIDs actually solve the problem nicely because they have a definite ordering so can be indexed. You can't do that with strings without a lot of ceremony: making sure everything is length-prefixed in storage (nvarchar, but then you kill indexability), making sure everybody agrees on which comparer to use (good luck doing this in SQL), and so on.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That they have a fixed, unambiguous, universal representation is a huge plus over strings, even if ordering doesn't matter. I agree that academically the difference shouldn't matter, but practically it does. I guarantee you'll have a difficult time building a reliable, high-performance correlation engine if your key is an arbitrary structureless string.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the time these Ids are persisted as a string always so I'm not sure what you mean. Are you saying if we don't use the .NET Guid type that it won the performant?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The nearly 100% use case is that they're persisted in an ETW log or similar structure, so they're definitely not persisted as strings. Please reread my argument above - I'm not advocating GUIDs for the sake of having GUIDs, I'm advocating it because it's structured, unambiguous, and easy for correlation engines to reason about. If you have another structure in mind that meets these requirements then by all means suggest it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Eilon - Just as a side note. OWIN spec actually says owin.RequestId is a string.

3.2.1 Request Data
owin.RequestId An optional string that uniquely identifies a request. The value is opaque and SHOULD have some level of uniqueness. A Host MAY specify this value. If it is not specified, middleware MAY set it. Once set, it SHOULD NOT be modified.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep I read the OWIN spec 😄 Honestly I'm OK with forcing GUID because there's nothing really wrong with it in practice. It's just kind of annoying when practicality trumps so-called "correctness."

@davidfowl
Copy link
Member

Any reason it's a guid instead of a string?

var requestId = Prop<string>(OwinConstants.RequestId);
if (requestId != null)
{
return new Guid(requestId);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The OWIN spec say it's an opaque value, we can't assume it will parse as a GUID. TryParse?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure. I can fix that. Else return Guid.Empty?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm this makes me more worried actually. If we want to support OWIN, and OWIN uses strings, I don't see how we can force GUIDs... that's not to say that if we happen to get a GUID that we shouldn't use it...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OWIN on the top of any of IIS/Systemweb/WebListener will not be a problem. But this can affect any other servers. The alternate that I can think of is change all Guid to string and continue to produce GUID in our servers so that E2E tracing is possible (and just do a guid.ToString())?

@Praburaj
Copy link
Contributor Author

Praburaj commented Mar 4, 2015

@Tratcher Updated PR with feedback.

@Eilon
Copy link
Contributor

Eilon commented Mar 4, 2015

:shipit: (we discussed more in person)

Addresses : #117

Related changes in Helios & weblistener in separate PRs.
@Praburaj Praburaj merged commit ae23f7c into aspnet:dev Mar 4, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants