Skip to content
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

Use implicit logging scope for Activity #22376

Merged
merged 8 commits into from
Jun 22, 2020
Merged

Conversation

shirhatti
Copy link
Contributor

This reverts commit f7a2d3c.

Addresses #21020

@shirhatti shirhatti requested a review from Tratcher as a code owner May 29, 2020 22:32
@ghost ghost added the area-hosting label May 29, 2020
@shirhatti shirhatti marked this pull request as draft May 29, 2020 22:32
Copy link
Member

@Tratcher Tratcher left a comment

Choose a reason for hiding this comment

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

There are conflicts in the test that need resolving.

src/Hosting/Hosting/test/HostingApplicationTests.cs Outdated Show resolved Hide resolved
@shirhatti shirhatti force-pushed the shirhatti/loggingscopes branch 2 times, most recently from 694e14d to f809e23 Compare May 29, 2020 22:45
@shirhatti shirhatti requested review from davidfowl, tarekgh and abetaha and removed request for abetaha June 1, 2020 16:10
@shirhatti
Copy link
Contributor Author

Still waiting on #22387 before the new API from runtime is available

@davidfowl
Copy link
Member

I don’t think I should revert anything. Just make a new change.

@shirhatti
Copy link
Contributor Author

I don’t think I should revert anything. Just make a new change.

I'm going to squash before merging, so it won't look like a reverted commit when merged. I just found it easier to work this way.

@tarekgh
Copy link
Member

tarekgh commented Jun 1, 2020

dotnet/runtime#34305

@tarekgh
Copy link
Member

tarekgh commented Jun 1, 2020

just wondering do we have any tests covering this functionality in asp.net? I just wanted to ensure we are not introducing any regression there.

@shirhatti shirhatti changed the base branch from master to release/5.0-preview6 June 3, 2020 20:39
@shirhatti
Copy link
Contributor Author

just wondering do we have any tests covering this functionality in asp.net? I just wanted to ensure we are not introducing any regression there.

We did have some tests that I've removed in the PR. It isn't functionally the same behavior. In place of the 1 scope object that had both Activity and RequestId/RequestPath. Ideally I wouldn't like to test runtime functionality in this repo.

@shirhatti
Copy link
Contributor Author

@Pilchie Does this need tactics approval? Also, who needs to merge since I don't have access to this branch?

@tarekgh
Copy link
Member

tarekgh commented Jun 3, 2020

We did have some tests that I've removed in the PR. It isn't functionally the same behavior. In place of the 1 scope object that had both Activity and RequestId/RequestPath. Ideally I wouldn't like to test runtime functionality in this repo.

At least did you validate the behavior manually for asp.net?

@davidfowl
Copy link
Member

davidfowl commented Jun 3, 2020

Why would it need tactics approval?

@shirhatti
Copy link
Contributor Author

Why would it need tactics approval?

We already branched for preview6

@shirhatti shirhatti changed the base branch from release/5.0-preview6 to master June 3, 2020 23:16
@shirhatti
Copy link
Contributor Author

@tarekgh Manually verified with console logger. Is there any other logger provider you suggest I verify against given the fact that it's now two different scope objects?

New log message

info: PlaintextApp.Startup[0]
      => SpanId:|50b0a7b9-4f895b67e546d4e6., TraceId:50b0a7b9-4f895b67e546d4e6, ParentId: => ConnectionId:0HM08BPOU3LC2 => RequestPath:/ RequestId:0HM08BPOU3LC2:00000002
      Processing request

Old log message

info: PlaintextApp.Startup[0]
      => ConnectionId:0HM08BGDIJUGA => RequestPath:/ RequestId:0HM08BGDIJUGA:00000002, SpanId:|c5b2b78c-49b1f71be195b052., TraceId:c5b2b78c-49b1f71be195b052, ParentId:
      Processing request

@davidfowl
Copy link
Member

App insights. I wonder if this should instead go into the host builder’s create default builder

@shirhatti
Copy link
Contributor Author

I wonder if this should instead go into the host builder’s create default builder

In runtime?https://github.com/dotnet/runtime/blob/96a3bfed4acffbe88403d5f599cee358b880ac5d/src/libraries/Microsoft.Extensions.Hosting/src/Host.cs#L96

I just realized I also need to make the change in here (since we don't use WebHostBuilder in the default case) 🤦

internal static void ConfigureWebDefaults(IWebHostBuilder builder)

@shirhatti
Copy link
Contributor Author

@cijothomas Would this change impact AppInsights? Activity information is no longer present on the HostingLogScope object. It's present a separate scope object, however the fidelity of information is preserved.

@cijothomas
Copy link

@cijothomas Would this change impact AppInsights? Activity information is no longer present on the HostingLogScope object. It's present a separate scope object, however the fidelity of information is preserved.

Don't think so. ApplicationInsights does not directly rely on the activity information from logger. (To correlate with parent request, Activity.Current is used)

@davidfowl
Copy link
Member

The AppInsights logger should be using the scope provider so I should get this for free. It would be good to test it anyways

@shirhatti shirhatti requested a review from Tratcher June 9, 2020 21:33
@@ -215,6 +221,15 @@ internal static void ConfigureWebDefaults(IWebHostBuilder builder)
StaticWebAssetsLoader.UseStaticWebAssets(ctx.HostingEnvironment, ctx.Configuration);
}
});
builder.ConfigureLogging(loggingBuilder =>
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this should be here. This should go into the generic host.

Copy link
Member

@halter73 halter73 Jun 9, 2020

Choose a reason for hiding this comment

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

This gets called by the generic host. I verified that when doing #22528.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought we agreed to only to enable it for webapps?

Copy link
Member

Choose a reason for hiding this comment

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

I think we should turn it on by default for all generic hosted apps. That means workers get it for free as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So remove the ConfigureWebDefaults changes (make changes to generic host in the runtime repo) and keep the WebHostBuilder changes and get this merged?

Copy link
Member

Choose a reason for hiding this comment

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

I think we should turn it on by default for all generic hosted apps. That means workers get it for free as well.

Can we clarify the scope of this? I mean how common the apps are using default host against using none-defaulted hosts? I am asking because originally we decided to have the behavior as opt-in to be intentional paying the extra cost when only opting-in .

Copy link
Member

Choose a reason for hiding this comment

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

Worker service and ASP.NET Core core applications.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created a new PR in runtime for this dotnet/runtime#37892

Copy link
Member

Choose a reason for hiding this comment

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

do we still need to have this PR?

Copy link
Member

@Tratcher Tratcher Jun 15, 2020

Choose a reason for hiding this comment

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

In theory this PR prevents a regression for existing WebHost customers. Keep in mind we plan to obsolete WebHost in 5.0, but not remove it yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-hosting Includes Hosting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable ActivityTracking in CreateDefaultBuilder No need to explicitly hoist Activity inthe HostingLogScope
9 participants