Suppress [Obsolete] warnings for TelemetrySource
This commit is contained in:
parent
e92d325be0
commit
9a12085ef9
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<packageSources>
|
<packageSources>
|
||||||
<add key="AspNetVNext" value="https://www.myget.org/F/aspnetcidev/api/v3/index.json" />
|
<add key="AspNetVNext" value="https://www.myget.org/F/aspnetcidev/api/v3/index.json" />
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,9 @@ namespace Microsoft.AspNet.Hosting.Internal
|
||||||
var logger = _applicationServices.GetRequiredService<ILogger<HostingEngine>>();
|
var logger = _applicationServices.GetRequiredService<ILogger<HostingEngine>>();
|
||||||
var contextFactory = _applicationServices.GetRequiredService<IHttpContextFactory>();
|
var contextFactory = _applicationServices.GetRequiredService<IHttpContextFactory>();
|
||||||
var contextAccessor = _applicationServices.GetRequiredService<IHttpContextAccessor>();
|
var contextAccessor = _applicationServices.GetRequiredService<IHttpContextAccessor>();
|
||||||
|
#pragma warning disable 0618
|
||||||
var telemetrySource = _applicationServices.GetRequiredService<TelemetrySource>();
|
var telemetrySource = _applicationServices.GetRequiredService<TelemetrySource>();
|
||||||
|
#pragma warning restore 0618
|
||||||
var server = ServerFactory.Start(_serverInstance,
|
var server = ServerFactory.Start(_serverInstance,
|
||||||
async features =>
|
async features =>
|
||||||
{
|
{
|
||||||
|
|
@ -96,12 +98,12 @@ namespace Microsoft.AspNet.Hosting.Internal
|
||||||
httpContext.ApplicationServices = _applicationServices;
|
httpContext.ApplicationServices = _applicationServices;
|
||||||
var requestIdentifier = GetRequestIdentifier(httpContext);
|
var requestIdentifier = GetRequestIdentifier(httpContext);
|
||||||
contextAccessor.HttpContext = httpContext;
|
contextAccessor.HttpContext = httpContext;
|
||||||
|
#pragma warning disable 0618
|
||||||
if (telemetrySource.IsEnabled("Microsoft.AspNet.Hosting.BeginRequest"))
|
if (telemetrySource.IsEnabled("Microsoft.AspNet.Hosting.BeginRequest"))
|
||||||
{
|
{
|
||||||
telemetrySource.WriteTelemetry("Microsoft.AspNet.Hosting.BeginRequest", new { httpContext = httpContext });
|
telemetrySource.WriteTelemetry("Microsoft.AspNet.Hosting.BeginRequest", new { httpContext = httpContext });
|
||||||
}
|
}
|
||||||
|
#pragma warning restore 0618
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (logger.IsEnabled(LogLevel.Critical)
|
using (logger.IsEnabled(LogLevel.Critical)
|
||||||
|
|
@ -113,18 +115,20 @@ namespace Microsoft.AspNet.Hosting.Internal
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
#pragma warning disable 0618
|
||||||
if (telemetrySource.IsEnabled("Microsoft.AspNet.Hosting.UnhandledException"))
|
if (telemetrySource.IsEnabled("Microsoft.AspNet.Hosting.UnhandledException"))
|
||||||
{
|
{
|
||||||
telemetrySource.WriteTelemetry("Microsoft.AspNet.Hosting.UnhandledException", new { httpContext = httpContext, exception = ex });
|
telemetrySource.WriteTelemetry("Microsoft.AspNet.Hosting.UnhandledException", new { httpContext = httpContext, exception = ex });
|
||||||
}
|
}
|
||||||
|
#pragma warning restore 0618
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
#pragma warning disable 0618
|
||||||
if (telemetrySource.IsEnabled("Microsoft.AspNet.Hosting.EndRequest"))
|
if (telemetrySource.IsEnabled("Microsoft.AspNet.Hosting.EndRequest"))
|
||||||
{
|
{
|
||||||
telemetrySource.WriteTelemetry("Microsoft.AspNet.Hosting.EndRequest", new { httpContext = httpContext });
|
telemetrySource.WriteTelemetry("Microsoft.AspNet.Hosting.EndRequest", new { httpContext = httpContext });
|
||||||
}
|
}
|
||||||
|
#pragma warning restore 0618
|
||||||
});
|
});
|
||||||
|
|
||||||
_applicationLifetime.NotifyStarted();
|
_applicationLifetime.NotifyStarted();
|
||||||
|
|
|
||||||
|
|
@ -99,9 +99,11 @@ namespace Microsoft.AspNet.Hosting
|
||||||
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||||
services.AddLogging();
|
services.AddLogging();
|
||||||
|
|
||||||
|
#pragma warning disable 0618
|
||||||
var telemetrySource = new TelemetryListener("Microsoft.AspNet");
|
var telemetrySource = new TelemetryListener("Microsoft.AspNet");
|
||||||
services.AddInstance<TelemetrySource>(telemetrySource);
|
services.AddInstance<TelemetrySource>(telemetrySource);
|
||||||
services.AddInstance<TelemetryListener>(telemetrySource);
|
services.AddInstance<TelemetryListener>(telemetrySource);
|
||||||
|
#pragma warning restore 0618
|
||||||
|
|
||||||
// Conjure up a RequestServices
|
// Conjure up a RequestServices
|
||||||
services.AddTransient<IStartupFilter, AutoRequestServicesStartupFilter>();
|
services.AddTransient<IStartupFilter, AutoRequestServicesStartupFilter>();
|
||||||
|
|
|
||||||
|
|
@ -437,6 +437,7 @@ namespace Microsoft.AspNet.TestHost
|
||||||
Assert.Equal("FoundFoo:False", await result.Content.ReadAsStringAsync());
|
Assert.Equal("FoundFoo:False", await result.Content.ReadAsStringAsync());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma warning disable 0618
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task BeginEndTelemetryAvailable()
|
public async Task BeginEndTelemetryAvailable()
|
||||||
{
|
{
|
||||||
|
|
@ -480,6 +481,7 @@ namespace Microsoft.AspNet.TestHost
|
||||||
Assert.NotNull(listener.UnhandledException?.HttpContext);
|
Assert.NotNull(listener.UnhandledException?.HttpContext);
|
||||||
Assert.NotNull(listener.UnhandledException?.Exception);
|
Assert.NotNull(listener.UnhandledException?.Exception);
|
||||||
}
|
}
|
||||||
|
#pragma warning restore 0618
|
||||||
|
|
||||||
public class TestTelemetryListener
|
public class TestTelemetryListener
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue