SignalR in MVC Distortion

We just started using SignalR in an MVC application, and now we get a bunch of warnings due to the high average response time. I suspect this is misleading since the application does not experience any performance degradation. SignalR seems to be using this URL to connect. This url is not the controller / action of the project and only the built-in signal code in the js file. The jquery.signalR-2.2.1.js file is a file. I suspect that he is simply leaving the connection to the website while he is on this page, and he is distorting our numbers. That's for sure? If so, is there a way to filter it from the application view?

Here is the counter. Is this the expected behavior?

enter image description here

Here is the jquery signalR code where it builds its url:

// BUG #2953: The url needs to be same otherwise it will cause a memory leak
    getUrl: function (connection, transport, reconnecting, poll, ajaxPost) {
        /// <summary>Gets the url for making a GET based connect request</summary>
        var baseUrl = transport === "webSockets" ? "" : connection.baseUrl,
            url = baseUrl + connection.appRelativeUrl,
            qs = "transport=" + transport;

        if (!ajaxPost && connection.groupsToken) {
            qs += "&groupsToken=" + window.encodeURIComponent(connection.groupsToken);
        }

        if (!reconnecting) {
            url += "/connect";
        } else {
            if (poll) {
                // longPolling transport specific
                url += "/poll";
            } else {
                url += "/reconnect";
            }

            if (!ajaxPost && connection.messageId) {
                qs += "&messageId=" + window.encodeURIComponent(connection.messageId);
            }
        }
        url += "?" + qs;
        url = transportLogic.prepareQueryString(connection, url);

        if (!ajaxPost) {
            url += "&tid=" + Math.floor(Math.random() * 11);
        }

        return url;
    },
+4
2

, https://docs.microsoft.com/en-us/azure/application-insights/app-insights-api-filtering-sampling:

  • ApplicationInsights Nuget 2.0.0 .
  • , ITelemetryProcessor:
    public class UnwantedTelemetryFilter : ITelemetryProcessor
    {
        private ITelemetryProcessor Next { get; set; }

        public UnwantedTelemetryFilter(ITelemetryProcessor next)
        {
            this.Next = next;
        }

        public void Process(ITelemetry item)
        {
            var request = item as RequestTelemetry;

            if (request != null && request.Name != null)
                if (request.Name.Contains("signalr"))
                    return;

            // Send everything else:
            this.Next.Process(item);
        }
    }
  1. Application_Start() Global.asax.cs:
    var builder = TelemetryConfiguration.Active.TelemetryProcessorChainBuilder;
    builder.Use((next) => new UnwantedTelemetryFilter(next));
    builder.Build();
+2

# , - : https://docs.microsoft.com/en-us/azure/application-insights/app-insights-api-filtering-sampling

public void Process(ITelemetry item)
{
    var request = item as RequestTelemetry;

    if (request != null && request.[some field here].Equals("[some signalr specific check here]", StringComparison.OrdinalIgnoreCase))
    {
        // To filter out an item, just terminate the chain:
        return;
    }
    // Send everything else:
    this.Next.Process(item);
}

, signalr

JS, , false .

+1

Source: https://habr.com/ru/post/1665758/


All Articles