Merge branch 'develop' into micmax/refactor-post-telemetry-script
This commit is contained in:
Коммит
241e198cd3
|
@ -3,6 +3,7 @@
|
|||
## VNext
|
||||
- [The `{OriginalFormat}` field in ILogger Scope will be emitted as `OriginalFormat` with the braces removed](https://github.com/microsoft/ApplicationInsights-dotnet/pull/2362)
|
||||
- [Enable SDK to create package for auto-instrumentation](https://github.com/microsoft/ApplicationInsights-dotnet/pull/2365)
|
||||
- [Suppress long running SignalR connections](https://github.com/microsoft/ApplicationInsights-dotnet/pull/2372)
|
||||
|
||||
## Version 2.18.0
|
||||
- [Change Self-Diagnostics to include datetimestamp in filename](https://github.com/microsoft/ApplicationInsights-dotnet/pull/2325)
|
||||
|
|
|
@ -754,6 +754,17 @@
|
|||
return;
|
||||
}
|
||||
|
||||
var activity = Activity.Current;
|
||||
|
||||
// Suppress long running SignalR requests
|
||||
// Ref: https://github.com/dotnet/aspnetcore/pull/32084
|
||||
var httpLongRunningRequest = activity?.Tags.FirstOrDefault(tag => tag.Key == "http.long_running").Value;
|
||||
|
||||
if (httpLongRunningRequest == "true")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
telemetry.Stop(timestamp);
|
||||
telemetry.ResponseCode = httpContext.Response.StatusCode.ToString(CultureInfo.InvariantCulture);
|
||||
|
||||
|
@ -781,7 +792,6 @@
|
|||
this.client.TrackRequest(telemetry);
|
||||
|
||||
// Stop what we started.
|
||||
var activity = Activity.Current;
|
||||
if (activity != null && activity.OperationName == ActivityCreatedByHostingDiagnosticListener)
|
||||
{
|
||||
activity.Stop();
|
||||
|
|
|
@ -1139,7 +1139,52 @@
|
|||
}
|
||||
}
|
||||
|
||||
private void HandleRequestBegin(
|
||||
[Theory]
|
||||
[InlineData(AspNetCoreMajorVersion.Two)]
|
||||
[InlineData(AspNetCoreMajorVersion.Three)]
|
||||
public void VerifyLongRunningRequestDoesNotGenerateTelemetry(AspNetCoreMajorVersion aspNetCoreMajorVersion)
|
||||
{
|
||||
HttpContext context = CreateContext(HttpRequestScheme, HttpRequestHost);
|
||||
TelemetryConfiguration config = TelemetryConfiguration.CreateDefault();
|
||||
|
||||
using (var hostingListener = CreateHostingListener(aspNetCoreMajorVersion, config))
|
||||
{
|
||||
HandleRequestBegin(hostingListener, context, 0, aspNetCoreMajorVersion);
|
||||
|
||||
var activity = Activity.Current;
|
||||
activity.AddTag("http.long_running", "true");
|
||||
Assert.NotNull(activity);
|
||||
|
||||
Assert.NotNull(context.Features.Get<RequestTelemetry>());
|
||||
|
||||
HandleRequestEnd(hostingListener, context, 0, aspNetCoreMajorVersion);
|
||||
|
||||
Assert.Empty(sentTelemetry);
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(AspNetCoreMajorVersion.Two)]
|
||||
[InlineData(AspNetCoreMajorVersion.Three)]
|
||||
public void NullActivityDoesGenerateTelemetry(AspNetCoreMajorVersion aspNetCoreMajorVersion)
|
||||
{
|
||||
HttpContext context = CreateContext(HttpRequestScheme, HttpRequestHost);
|
||||
TelemetryConfiguration config = TelemetryConfiguration.CreateDefault();
|
||||
|
||||
using (var hostingListener = CreateHostingListener(aspNetCoreMajorVersion, config))
|
||||
{
|
||||
HandleRequestBegin(hostingListener, context, 0, aspNetCoreMajorVersion);
|
||||
|
||||
Activity.Current = null;
|
||||
Assert.NotNull(context.Features.Get<RequestTelemetry>());
|
||||
|
||||
HandleRequestEnd(hostingListener, context, 0, aspNetCoreMajorVersion);
|
||||
|
||||
Assert.Single(sentTelemetry);
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleRequestBegin(
|
||||
HostingDiagnosticListener hostingListener,
|
||||
HttpContext context,
|
||||
long timestamp,
|
||||
|
|
Загрузка…
Ссылка в новой задаче