Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add long running activity tag for SignalR connections#32084

Merged
BrennanConroy merged 4 commits into
mainfrom
brecon/appin
Jun 7, 2021
Merged

Add long running activity tag for SignalR connections#32084
BrennanConroy merged 4 commits into
mainfrom
brecon/appin

Conversation

@BrennanConroy

Copy link
Copy Markdown
Member

Fixes #29699

@BrennanConroy BrennanConroy added the area-signalr Includes: SignalR clients and servers label Apr 23, 2021
@BrennanConroy BrennanConroy added this to the 6.0-preview5 milestone Apr 23, 2021
Comment thread src/SignalR/common/Http.Connections/test/LongPollingTests.cs Outdated
Comment thread src/SignalR/common/Http.Connections/test/ServerSentEventsTests.cs Outdated
Comment thread src/SignalR/common/Http.Connections/test/WebSocketsTests.cs Outdated
Comment thread src/SignalR/common/Http.Connections/src/Internal/Transports/CustomHeaderNames.cs Outdated
@davidfowl

davidfowl commented Apr 23, 2021

Copy link
Copy Markdown
Member

Should this be moved to the websocket middleware instead of signalr's websocket transport.

@shirhatti

Copy link
Copy Markdown
Contributor

I thought we we're doing to the header in addition to setting a tag on the activity?

@shirhatti

Copy link
Copy Markdown
Contributor

@cijothomas I assume this will be sufficient for AI to exclude long-running SigalR requests from regular request statistics?

@davidfowl

Copy link
Copy Markdown
Member

I thought we we're doing to the header in addition to setting a tag on the activity?

Why?

@rajkumar-rangaraj

rajkumar-rangaraj commented Apr 23, 2021

Copy link
Copy Markdown

@cijothomas I assume this will be sufficient for AI to exclude long-running SigalR requests from regular request statistics?

@shirhatti This will help in AI to exclude long-running requests of Signal-R.

@BrennanConroy

  • Application insights gets notified on new ASP.NET Core / SignalR request when it enters Microsoft.AspNetCore.Hosting.HostingApplicationDiagnostics.BeginRequest. At this point we create a request telemetry object to track the request.
  • When Microsoft.AspNetCore.Hosting.HostingApplicationDiagnostics.RequestEnd is invoked AI gets notified again at this point we update request telemetry with duration and send it to application insights service.

With the current change we have to create and hold the request telemetry in the heap till the RequestEnd is called and drop request telemetry object on the floor. Proposed change will help us suppress the long running requests but there is a perf issue in creating and holding the RequestTelemetry. Is it possible to add HttpContext request header in BeginRequest before start activity is called.

@shirhatti

Copy link
Copy Markdown
Contributor

Is it possible to add HttpContext request header in BeginRequest before start activity is called.

That's impossible. StartActivity is called way too early for that

@shirhatti

Copy link
Copy Markdown
Contributor

@davidfowl So that I don't have to use DiagnosticsListener, get the HttpContext and then read the response headers. If I'm an instrumentation library I just want to have all the info on the Activity

@shirhatti

Copy link
Copy Markdown
Contributor

Also @rajkumar-rangaraj ,we're adding a response header, not a request header 😄

@rajkumar-rangaraj

rajkumar-rangaraj commented Apr 23, 2021

Copy link
Copy Markdown

Also @rajkumar-rangaraj ,we're adding a response header, not a request header 😄

Yes. I reviewed it. As I wanted an update in BeginRequest asked for change in request header.

@davidfowl

Copy link
Copy Markdown
Member

Yes. I reviewed it. As I wanted an update in BeginRequest asked for change in request header.

This isn't possible.

@halter73

Copy link
Copy Markdown
Member

Should this be moved to the websocket middleware instead of signalr's websocket transport.

I thought you might want to make the WebSocket middleware a little more raw. Instrumentation should treat all WebSocket requests as long-running to begin with.

@BrennanConroy

Copy link
Copy Markdown
Member Author

Updated

@davidfowl

Copy link
Copy Markdown
Member

nit: Fix the PR title 😄

@BrennanConroy BrennanConroy changed the title Add Long-Running response header to SignalR connections Add long running activity tag for SignalR connections Jun 7, 2021

private async Task ExecuteAsync(HttpContext context, ConnectionDelegate connectionDelegate, HttpConnectionDispatcherOptions options, ConnectionLogScope logScope)
{
// set a tag to allow Application Performance Management tools to differentiate long running requests for reporting purposes

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I haven't seen APM written out like this before

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I didn't know what it stood for and in 1 year I definitely wont remember.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-signalr Includes: SignalR clients and servers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add information to indicate a SignalR request is long running

6 participants