Skip to content

Parent Request Id is mislabeled as Correlation Id in log scope #5918

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ngbrown opened this issue Apr 16, 2018 · 16 comments
Closed

Parent Request Id is mislabeled as Correlation Id in log scope #5918

ngbrown opened this issue Apr 16, 2018 · 16 comments
Assignees
Labels
area-hosting Includes Hosting area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions Needs: Design This issue requires design work before implementating.

Comments

@ngbrown
Copy link

ngbrown commented Apr 16, 2018

For the upcoming for ASP.Net Core 2.1; pull #1138 added to the log scope a CorrelationId, but the contents are only the parent request identifier and does not appear to be set if there was no parent request (no Request-Id header in the incoming HTTP request).

There is documentation/specifications (mostly by @lmolkova) around these terms at:

Specifically in the Activity User Guide, it says:

When application calls external dependency to complete an operation, it may need to pass some of the context (e.g. correlation id) [emphasis added] along with dependency call to be able to correlate logs from multiple service.

I see that the expectation is that in the logs, there will be a "correlation id" of the context, or CorrelationId if you will, that can be used to link the logs entries across multiple services handling a single user request.

In the current preview code, the Log scope outputs a CorrelationId which is the value of an incoming header Request-Id, and only if that header is set. This is not useful for seeing the entire request across multiple services in the logs. What is needed is adding to the log scope the root request id to the log scope of all services involved in handling the request, including within the root service that generated the first request id.

@ngbrown ngbrown changed the title Parent Request Id is mislabeled as Context Id in log scope Parent Request Id is mislabeled as Correlation Id in log scope Apr 16, 2018
@lmolkova
Copy link

lmolkova commented Apr 16, 2018

@ngbrown
The spec implemented in .NET and ASP.NET is HierarchicalRequestId

i.e. 'correlationId' looks like |root-id-that-never-changes.some_unique.suffix.1.2.3.

You are right that 'parent request id' is the correct name for it.

Instead of adding parent Request-Id header value to logger scopes, we should use Activity.Current.Id that is generated for each request even if there were no Request-Id header.

I believe @davidfowl hit a snag there because no instrumentation (i.e. Activity creation) happens in absence of ApplicaitonInsights or other tracing systems that lights-up hosting diagnostics.

@ngbrown
Copy link
Author

ngbrown commented Apr 16, 2018

If CorrelationId in the log entries would most correctly be the Activity.Current.Id, then it could be conditionally added, depending on whether or not the Activity is created.

If that can't be achieved, then I don't think it should be set with the current name at all. i.e. change the log scope/enrichment name to ParentRequestId. There are also parameter names that should be updated.

@davidfowl
Copy link
Member

@lmolkova is right. Maybe we should just remove this from the logging scope altogether.

@ngbrown
Copy link
Author

ngbrown commented Apr 21, 2018

Another issue is that the log context RequestId in an hierarchical request id scenario does not include any part of the hierarchy.

The spec says:

"All operation logs may be queried by Request-Id prefix |Guid., logs for particular request may be queried by exact Request-Id match"

@muratg
Copy link
Contributor

muratg commented Jun 14, 2018

@davidfowl anything to do in 2.2?

@davidfowl
Copy link
Member

Yes, we should look at this in 2.2 and also look at disabling this by default because of the other security concerns raised here aspnet/Hosting#1385

@muratg
Copy link
Contributor

muratg commented Jun 21, 2018

@Tratcher thoughts?

@Tratcher
Copy link
Member

No specific thoughts, I wasn't involved in most of this work. @pakrym?

@muratg
Copy link
Contributor

muratg commented Oct 22, 2018

@davidfowl Moving this out to 3.0.0.

@aspnet-hello aspnet-hello transferred this issue from aspnet/Hosting Dec 18, 2018
@aspnet-hello aspnet-hello added this to the 3.0.0 milestone Dec 18, 2018
@muratg
Copy link
Contributor

muratg commented Jan 9, 2019

@pakrym thoughts on the scope of this one? You agree that removing it from logging scope is the right approach?

@pakrym
Copy link
Contributor

pakrym commented Jan 9, 2019

I, unfortunately, don't have enough context on this. Would need to discuss with @davidfowl as it seems he understands what's wrong here.

@lkts
Copy link

lkts commented Feb 27, 2019

I want to agree here that CorrelationId is confusing in current implementation because it is always null for application which serves "initial" requests. I would expect it to be Activity.Current.Id as mentioned here.

@analogrelay
Copy link
Contributor

Epic #8924

@analogrelay analogrelay added the Needs: Design This issue requires design work before implementating. label Apr 3, 2019
@analogrelay analogrelay modified the milestones: 3.0.0, 3.0.0-preview6 Apr 3, 2019
@analogrelay
Copy link
Contributor

Needs similar design to #5926

@davidfowl
Copy link
Member

This is done now

@davidfowl
Copy link
Member

See #9491

@ghost ghost locked as resolved and limited conversation to collaborators Dec 4, 2019
@amcasey amcasey added the area-hosting Includes Hosting label Jun 1, 2023
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Aug 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-hosting Includes Hosting area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions Needs: Design This issue requires design work before implementating.
Projects
None yet
Development

No branches or pull requests