Suppress [Obsolete] warnings for TelemetrySource
This commit is contained in:
Родитель
e92d325be0
Коммит
9a12085ef9
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<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 contextFactory = _applicationServices.GetRequiredService<IHttpContextFactory>();
|
||||
var contextAccessor = _applicationServices.GetRequiredService<IHttpContextAccessor>();
|
||||
#pragma warning disable 0618
|
||||
var telemetrySource = _applicationServices.GetRequiredService<TelemetrySource>();
|
||||
#pragma warning restore 0618
|
||||
var server = ServerFactory.Start(_serverInstance,
|
||||
async features =>
|
||||
{
|
||||
|
@ -96,12 +98,12 @@ namespace Microsoft.AspNet.Hosting.Internal
|
|||
httpContext.ApplicationServices = _applicationServices;
|
||||
var requestIdentifier = GetRequestIdentifier(httpContext);
|
||||
contextAccessor.HttpContext = httpContext;
|
||||
|
||||
#pragma warning disable 0618
|
||||
if (telemetrySource.IsEnabled("Microsoft.AspNet.Hosting.BeginRequest"))
|
||||
{
|
||||
telemetrySource.WriteTelemetry("Microsoft.AspNet.Hosting.BeginRequest", new { httpContext = httpContext });
|
||||
}
|
||||
|
||||
#pragma warning restore 0618
|
||||
try
|
||||
{
|
||||
using (logger.IsEnabled(LogLevel.Critical)
|
||||
|
@ -113,18 +115,20 @@ namespace Microsoft.AspNet.Hosting.Internal
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
#pragma warning disable 0618
|
||||
if (telemetrySource.IsEnabled("Microsoft.AspNet.Hosting.UnhandledException"))
|
||||
{
|
||||
telemetrySource.WriteTelemetry("Microsoft.AspNet.Hosting.UnhandledException", new { httpContext = httpContext, exception = ex });
|
||||
}
|
||||
|
||||
#pragma warning restore 0618
|
||||
throw;
|
||||
}
|
||||
|
||||
#pragma warning disable 0618
|
||||
if (telemetrySource.IsEnabled("Microsoft.AspNet.Hosting.EndRequest"))
|
||||
{
|
||||
telemetrySource.WriteTelemetry("Microsoft.AspNet.Hosting.EndRequest", new { httpContext = httpContext });
|
||||
}
|
||||
#pragma warning restore 0618
|
||||
});
|
||||
|
||||
_applicationLifetime.NotifyStarted();
|
||||
|
|
|
@ -99,9 +99,11 @@ namespace Microsoft.AspNet.Hosting
|
|||
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||
services.AddLogging();
|
||||
|
||||
#pragma warning disable 0618
|
||||
var telemetrySource = new TelemetryListener("Microsoft.AspNet");
|
||||
services.AddInstance<TelemetrySource>(telemetrySource);
|
||||
services.AddInstance<TelemetryListener>(telemetrySource);
|
||||
#pragma warning restore 0618
|
||||
|
||||
// Conjure up a RequestServices
|
||||
services.AddTransient<IStartupFilter, AutoRequestServicesStartupFilter>();
|
||||
|
|
|
@ -437,6 +437,7 @@ namespace Microsoft.AspNet.TestHost
|
|||
Assert.Equal("FoundFoo:False", await result.Content.ReadAsStringAsync());
|
||||
}
|
||||
|
||||
#pragma warning disable 0618
|
||||
[Fact]
|
||||
public async Task BeginEndTelemetryAvailable()
|
||||
{
|
||||
|
@ -480,6 +481,7 @@ namespace Microsoft.AspNet.TestHost
|
|||
Assert.NotNull(listener.UnhandledException?.HttpContext);
|
||||
Assert.NotNull(listener.UnhandledException?.Exception);
|
||||
}
|
||||
#pragma warning restore 0618
|
||||
|
||||
public class TestTelemetryListener
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче