Skip to content
This repository was archived by the owner on Jul 5, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## Version 2.7.0-beta1
- [Send UserActionable event about correlation issue with HTTP request with body when .NET 4.7.1 is not installed](https://github.com/Microsoft/ApplicationInsights-dotnet-server/pull/903)
- [Added support to collect Perf Counters for .NET Core Apps if running inside Azure WebApps](https://github.com/Microsoft/ApplicationInsights-dotnet-server/issues/889)
- [Opt-in legacy correlation headers (x-ms-request-id and x-ms-request-root-id) extraction and injection](https://github.com/Microsoft/ApplicationInsights-dotnet-server/issues/887)
- [Fix: Correlation is not working for POST requests](https://github.com/Microsoft/ApplicationInsights-dotnet-server/pull/898) when .NET 4.7.1 runtime is installed.
Expand Down
11 changes: 11 additions & 0 deletions Src/Web/Web.Shared.Net/Implementation/WebEventSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,17 @@ public void ActivityIsNull(string diagnosticsSourceEventName, string appDomainNa
this.WriteEvent(48, diagnosticsSourceEventName, this.ApplicationName);
}

[Event(49,
Keywords = Keywords.Diagnostics | Keywords.UserActionable,
Message = ".NET 4.7.1 is not installed, correlation for HTTP requests with body is not possible",
Level = EventLevel.Error)]
public void CorrelationIssueIsDetectedForRequestWithBody(string appDomainName = "Incorrect")
{
this.WriteEvent(
49,
this.ApplicationName);
}

[NonEvent]
private string GetApplicationName()
{
Expand Down
38 changes: 14 additions & 24 deletions Src/Web/Web.Shared.Net/RequestTrackingTelemetryModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@
public class RequestTrackingTelemetryModule : ITelemetryModule
{
private const string IntermediateRequestHttpContextKey = "IntermediateRequest";
private readonly IList<string> handlersToFilter = new List<string>();
// if HttpApplicaiton.OnRequestExecute is available, we don't attempt to detect any correlation issues
private static bool correlationIssuesDetectionComplete = typeof(HttpApplication).GetMethod("OnExecuteRequestStep") != null;

private TelemetryClient telemetryClient;
private TelemetryConfiguration telemetryConfiguration;
private bool initializationErrorReported;
private bool correlationHeadersEnabled = true;
private ChildRequestTrackingSuppressionModule childRequestTrackingSuppressionModule = null;

/// <summary>
/// Gets or sets a value indicating whether child request suppression is enabled or disabled.
/// True by default.
Expand All @@ -53,34 +54,17 @@ public class RequestTrackingTelemetryModule : ITelemetryModule
/// See also <see cref="ChildRequestTrackingSuppressionModule" />.
/// </remarks>
public int ChildRequestTrackingInternalDictionarySize { get; set; }

/// <summary>
/// Gets the list of handler types for which requests telemetry will not be collected
/// if request was successful.
/// </summary>
public IList<string> Handlers
{
get
{
return this.handlersToFilter;
}
}
public IList<string> Handlers { get; } = new List<string>();

/// <summary>
/// Gets or sets a value indicating whether the component correlation headers would be set on http responses.
/// </summary>
public bool SetComponentCorrelationHttpHeaders
{
get
{
return this.correlationHeadersEnabled;
}

set
{
this.correlationHeadersEnabled = value;
}
}
public bool SetComponentCorrelationHttpHeaders { get; set; } = true;

/// <summary>
/// Gets or sets the endpoint that is to be used to get the application insights resource's profile (appId etc.).
Expand Down Expand Up @@ -219,6 +203,12 @@ public void OnEndRequest(HttpContext context)
}

this.telemetryClient.TrackRequest(requestTelemetry);

if (!correlationIssuesDetectionComplete && context.Request.ContentLength > 0)
{
WebEventSource.Log.CorrelationIssueIsDetectedForRequestWithBody();
correlationIssuesDetectionComplete = true;
}
}
else
{
Expand Down Expand Up @@ -394,7 +384,7 @@ private bool IsHandlerToFilter(IHttpHandler handler)

return false;
}

/// <summary>
/// <see cref="System.Web.Handlers.TransferRequestHandler"/> can create a Child request to route extension-less requests to a controller.
/// (ex: site/home -> site/HomeController.cs)
Expand Down