Use TelemetrySource

This commit is contained in:
Ryan Nowak 2015-09-06 20:23:05 -07:00
parent 2834b70987
commit 465b4ce0df
23 changed files with 258 additions and 148 deletions

View File

@ -1,7 +1,7 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14 # Visual Studio 14
VisualStudioVersion = 14.0.23017.0 VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{DAAE4C74-D06F-4874-A166-33305D2643CE}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{DAAE4C74-D06F-4874-A166-33305D2643CE}"
EndProject EndProject
@ -88,6 +88,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Locali
EndProject EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Localization.Test", "test\Microsoft.AspNet.Mvc.Localization.Test\Microsoft.AspNet.Mvc.Localization.Test.xproj", "{8FC726B5-E766-44E0-8B38-1313B6D8D9A7}" Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Localization.Test", "test\Microsoft.AspNet.Mvc.Localization.Test\Microsoft.AspNet.Mvc.Localization.Test.xproj", "{8FC726B5-E766-44E0-8B38-1313B6D8D9A7}"
EndProject EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.TestTelemetryListener.Sources", "test\Microsoft.AspNet.Mvc.TestTelemetryListener.Sources\Microsoft.AspNet.Mvc.TestTelemetryListener.Sources.xproj", "{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -518,6 +520,18 @@ Global
{8FC726B5-E766-44E0-8B38-1313B6D8D9A7}.Release|Mixed Platforms.Build.0 = Release|Any CPU {8FC726B5-E766-44E0-8B38-1313B6D8D9A7}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{8FC726B5-E766-44E0-8B38-1313B6D8D9A7}.Release|x86.ActiveCfg = Release|Any CPU {8FC726B5-E766-44E0-8B38-1313B6D8D9A7}.Release|x86.ActiveCfg = Release|Any CPU
{8FC726B5-E766-44E0-8B38-1313B6D8D9A7}.Release|x86.Build.0 = Release|Any CPU {8FC726B5-E766-44E0-8B38-1313B6D8D9A7}.Release|x86.Build.0 = Release|Any CPU
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Debug|x86.ActiveCfg = Debug|Any CPU
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Debug|x86.Build.0 = Debug|Any CPU
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Release|Any CPU.Build.0 = Release|Any CPU
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Release|x86.ActiveCfg = Release|Any CPU
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -560,5 +574,6 @@ Global
{827DBBCB-F3A9-4BAD-8262-4BD43E28EB3B} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1} {827DBBCB-F3A9-4BAD-8262-4BD43E28EB3B} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
{50893B10-5735-4F35-9995-F81DA3F0189E} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} {50893B10-5735-4F35-9995-F81DA3F0189E} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E}
{8FC726B5-E766-44E0-8B38-1313B6D8D9A7} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1} {8FC726B5-E766-44E0-8B38-1313B6D8D9A7} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

15
Mvc.sln
View File

@ -186,6 +186,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Locali
EndProject EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Localization.Test", "test\Microsoft.AspNet.Mvc.Localization.Test\Microsoft.AspNet.Mvc.Localization.Test.xproj", "{8FC726B5-E766-44E0-8B38-1313B6D8D9A7}" Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Localization.Test", "test\Microsoft.AspNet.Mvc.Localization.Test\Microsoft.AspNet.Mvc.Localization.Test.xproj", "{8FC726B5-E766-44E0-8B38-1313B6D8D9A7}"
EndProject EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.TestTelemetryListener.Sources", "test\Microsoft.AspNet.Mvc.TestTelemetryListener.Sources\Microsoft.AspNet.Mvc.TestTelemetryListener.Sources.xproj", "{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -1140,6 +1142,18 @@ Global
{8FC726B5-E766-44E0-8B38-1313B6D8D9A7}.Release|Mixed Platforms.Build.0 = Release|Any CPU {8FC726B5-E766-44E0-8B38-1313B6D8D9A7}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{8FC726B5-E766-44E0-8B38-1313B6D8D9A7}.Release|x86.ActiveCfg = Release|Any CPU {8FC726B5-E766-44E0-8B38-1313B6D8D9A7}.Release|x86.ActiveCfg = Release|Any CPU
{8FC726B5-E766-44E0-8B38-1313B6D8D9A7}.Release|x86.Build.0 = Release|Any CPU {8FC726B5-E766-44E0-8B38-1313B6D8D9A7}.Release|x86.Build.0 = Release|Any CPU
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Debug|x86.ActiveCfg = Debug|Any CPU
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Debug|x86.Build.0 = Debug|Any CPU
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Release|Any CPU.Build.0 = Release|Any CPU
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Release|x86.ActiveCfg = Release|Any CPU
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -1231,5 +1245,6 @@ Global
{60873DFA-97B9-419E-BAA3-940FC9B07085} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1} {60873DFA-97B9-419E-BAA3-940FC9B07085} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
{50893B10-5735-4F35-9995-F81DA3F0189E} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} {50893B10-5735-4F35-9995-F81DA3F0189E} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E}
{8FC726B5-E766-44E0-8B38-1313B6D8D9A7} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1} {8FC726B5-E766-44E0-8B38-1313B6D8D9A7} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View File

@ -4,6 +4,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Diagnostics.Tracing;
using System.Reflection; using System.Reflection;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Mvc.ActionResults; using Microsoft.AspNet.Mvc.ActionResults;
@ -14,7 +15,6 @@ using Microsoft.AspNet.Mvc.ModelBinding;
using Microsoft.AspNet.Mvc.ModelBinding.Validation; using Microsoft.AspNet.Mvc.ModelBinding.Validation;
using Microsoft.Framework.Internal; using Microsoft.Framework.Internal;
using Microsoft.Framework.Logging; using Microsoft.Framework.Logging;
using Microsoft.Framework.Notification;
namespace Microsoft.AspNet.Mvc.Actions namespace Microsoft.AspNet.Mvc.Actions
{ {
@ -37,7 +37,7 @@ namespace Microsoft.AspNet.Mvc.Actions
[NotNull] IReadOnlyList<IValueProviderFactory> valueProviderFactories, [NotNull] IReadOnlyList<IValueProviderFactory> valueProviderFactories,
[NotNull] IActionBindingContextAccessor actionBindingContextAccessor, [NotNull] IActionBindingContextAccessor actionBindingContextAccessor,
[NotNull] ILogger logger, [NotNull] ILogger logger,
[NotNull] INotifier notifier, [NotNull] TelemetrySource telemetry,
int maxModelValidationErrors) int maxModelValidationErrors)
: base( : base(
actionContext, actionContext,
@ -49,7 +49,7 @@ namespace Microsoft.AspNet.Mvc.Actions
valueProviderFactories, valueProviderFactories,
actionBindingContextAccessor, actionBindingContextAccessor,
logger, logger,
notifier, telemetry,
maxModelValidationErrors) maxModelValidationErrors)
{ {
_descriptor = descriptor; _descriptor = descriptor;

View File

@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Tracing;
using System.Linq; using System.Linq;
using Microsoft.AspNet.Mvc.Filters; using Microsoft.AspNet.Mvc.Filters;
using Microsoft.AspNet.Mvc.Formatters; using Microsoft.AspNet.Mvc.Formatters;
@ -9,7 +10,6 @@ using Microsoft.AspNet.Mvc.ModelBinding;
using Microsoft.AspNet.Mvc.ModelBinding.Validation; using Microsoft.AspNet.Mvc.ModelBinding.Validation;
using Microsoft.Framework.Internal; using Microsoft.Framework.Internal;
using Microsoft.Framework.Logging; using Microsoft.Framework.Logging;
using Microsoft.Framework.Notification;
using Microsoft.Framework.OptionsModel; using Microsoft.Framework.OptionsModel;
namespace Microsoft.AspNet.Mvc.Actions namespace Microsoft.AspNet.Mvc.Actions
@ -27,7 +27,7 @@ namespace Microsoft.AspNet.Mvc.Actions
private readonly IActionBindingContextAccessor _actionBindingContextAccessor; private readonly IActionBindingContextAccessor _actionBindingContextAccessor;
private readonly int _maxModelValidationErrors; private readonly int _maxModelValidationErrors;
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly INotifier _notifier; private readonly TelemetrySource _telemetry;
public ControllerActionInvokerProvider( public ControllerActionInvokerProvider(
IControllerFactory controllerFactory, IControllerFactory controllerFactory,
@ -36,7 +36,7 @@ namespace Microsoft.AspNet.Mvc.Actions
IOptions<MvcOptions> optionsAccessor, IOptions<MvcOptions> optionsAccessor,
IActionBindingContextAccessor actionBindingContextAccessor, IActionBindingContextAccessor actionBindingContextAccessor,
ILoggerFactory loggerFactory, ILoggerFactory loggerFactory,
INotifier notifier) TelemetrySource telemetry)
{ {
_controllerFactory = controllerFactory; _controllerFactory = controllerFactory;
_filterProviders = filterProviders.OrderBy(item => item.Order).ToArray(); _filterProviders = filterProviders.OrderBy(item => item.Order).ToArray();
@ -49,7 +49,7 @@ namespace Microsoft.AspNet.Mvc.Actions
_actionBindingContextAccessor = actionBindingContextAccessor; _actionBindingContextAccessor = actionBindingContextAccessor;
_maxModelValidationErrors = optionsAccessor.Value.MaxModelValidationErrors; _maxModelValidationErrors = optionsAccessor.Value.MaxModelValidationErrors;
_logger = loggerFactory.CreateLogger<ControllerActionInvoker>(); _logger = loggerFactory.CreateLogger<ControllerActionInvoker>();
_notifier = notifier; _telemetry = telemetry;
} }
public int Order public int Order
@ -77,7 +77,7 @@ namespace Microsoft.AspNet.Mvc.Actions
_valueProviderFactories, _valueProviderFactories,
_actionBindingContextAccessor, _actionBindingContextAccessor,
_logger, _logger,
_notifier, _telemetry,
_maxModelValidationErrors); _maxModelValidationErrors);
} }
} }

View File

@ -4,6 +4,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Diagnostics.Tracing;
using System.Linq; using System.Linq;
using System.Runtime.ExceptionServices; using System.Runtime.ExceptionServices;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -16,7 +17,6 @@ using Microsoft.AspNet.Mvc.ModelBinding;
using Microsoft.AspNet.Mvc.ModelBinding.Validation; using Microsoft.AspNet.Mvc.ModelBinding.Validation;
using Microsoft.Framework.Internal; using Microsoft.Framework.Internal;
using Microsoft.Framework.Logging; using Microsoft.Framework.Logging;
using Microsoft.Framework.Notification;
namespace Microsoft.AspNet.Mvc.Actions namespace Microsoft.AspNet.Mvc.Actions
{ {
@ -30,7 +30,7 @@ namespace Microsoft.AspNet.Mvc.Actions
private readonly IReadOnlyList<IValueProviderFactory> _valueProviderFactories; private readonly IReadOnlyList<IValueProviderFactory> _valueProviderFactories;
private readonly IActionBindingContextAccessor _actionBindingContextAccessor; private readonly IActionBindingContextAccessor _actionBindingContextAccessor;
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly INotifier _notifier; private readonly TelemetrySource _telemetry;
private readonly int _maxModelValidationErrors; private readonly int _maxModelValidationErrors;
private IFilterMetadata[] _filters; private IFilterMetadata[] _filters;
@ -70,7 +70,7 @@ namespace Microsoft.AspNet.Mvc.Actions
[NotNull] IReadOnlyList<IValueProviderFactory> valueProviderFactories, [NotNull] IReadOnlyList<IValueProviderFactory> valueProviderFactories,
[NotNull] IActionBindingContextAccessor actionBindingContextAccessor, [NotNull] IActionBindingContextAccessor actionBindingContextAccessor,
[NotNull] ILogger logger, [NotNull] ILogger logger,
[NotNull] INotifier notifier, [NotNull] TelemetrySource telemetry,
int maxModelValidationErrors) int maxModelValidationErrors)
{ {
ActionContext = actionContext; ActionContext = actionContext;
@ -83,7 +83,7 @@ namespace Microsoft.AspNet.Mvc.Actions
_valueProviderFactories = valueProviderFactories; _valueProviderFactories = valueProviderFactories;
_actionBindingContextAccessor = actionBindingContextAccessor; _actionBindingContextAccessor = actionBindingContextAccessor;
_logger = logger; _logger = logger;
_notifier = notifier; _telemetry = telemetry;
_maxModelValidationErrors = maxModelValidationErrors; _maxModelValidationErrors = maxModelValidationErrors;
} }
@ -571,9 +571,9 @@ namespace Microsoft.AspNet.Mvc.Actions
try try
{ {
if (_notifier.ShouldNotify("Microsoft.AspNet.Mvc.BeforeActionMethod")) if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.BeforeActionMethod"))
{ {
_notifier.Notify( _telemetry.WriteTelemetry(
"Microsoft.AspNet.Mvc.BeforeActionMethod", "Microsoft.AspNet.Mvc.BeforeActionMethod",
new { actionContext = ActionContext, arguments = _actionExecutingContext.ActionArguments }); new { actionContext = ActionContext, arguments = _actionExecutingContext.ActionArguments });
} }
@ -582,9 +582,9 @@ namespace Microsoft.AspNet.Mvc.Actions
} }
finally finally
{ {
if (_notifier.ShouldNotify("Microsoft.AspNet.Mvc.AfterActionMethod")) if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.AfterActionMethod"))
{ {
_notifier.Notify( _telemetry.WriteTelemetry(
"Microsoft.AspNet.Mvc.AfterActionMethod", "Microsoft.AspNet.Mvc.AfterActionMethod",
new { actionContext = ActionContext, result }); new { actionContext = ActionContext, result });
} }
@ -735,9 +735,9 @@ namespace Microsoft.AspNet.Mvc.Actions
private async Task InvokeResultAsync(IActionResult result) private async Task InvokeResultAsync(IActionResult result)
{ {
if (_notifier.ShouldNotify("Microsoft.AspNet.Mvc.BeforeActionResult")) if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.BeforeActionResult"))
{ {
_notifier.Notify( _telemetry.WriteTelemetry(
"Microsoft.AspNet.Mvc.BeforeActionResult", "Microsoft.AspNet.Mvc.BeforeActionResult",
new { actionContext = ActionContext, result }); new { actionContext = ActionContext, result });
} }
@ -748,9 +748,9 @@ namespace Microsoft.AspNet.Mvc.Actions
} }
finally finally
{ {
if (_notifier.ShouldNotify("Microsoft.AspNet.Mvc.AfterActionResult")) if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.AfterActionResult"))
{ {
_notifier.Notify( _telemetry.WriteTelemetry(
"Microsoft.AspNet.Mvc.AfterActionResult", "Microsoft.AspNet.Mvc.AfterActionResult",
new { actionContext = ActionContext, result }); new { actionContext = ActionContext, result });
} }

View File

@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
using System.Diagnostics.Tracing;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.AspNet.Mvc.Core; using Microsoft.AspNet.Mvc.Core;
@ -10,7 +11,6 @@ using Microsoft.AspNet.Routing;
using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.DependencyInjection;
using Microsoft.Framework.Internal; using Microsoft.Framework.Internal;
using Microsoft.Framework.Logging; using Microsoft.Framework.Logging;
using Microsoft.Framework.Notification;
namespace Microsoft.AspNet.Mvc.Actions namespace Microsoft.AspNet.Mvc.Actions
{ {
@ -20,7 +20,7 @@ namespace Microsoft.AspNet.Mvc.Actions
private IActionInvokerFactory _actionInvokerFactory; private IActionInvokerFactory _actionInvokerFactory;
private IActionSelector _actionSelector; private IActionSelector _actionSelector;
private ILogger _logger; private ILogger _logger;
private INotifier _notifier; private TelemetrySource _telemetry;
public VirtualPathData GetVirtualPath([NotNull] VirtualPathContext context) public VirtualPathData GetVirtualPath([NotNull] VirtualPathContext context)
{ {
@ -70,9 +70,9 @@ namespace Microsoft.AspNet.Mvc.Actions
{ {
context.RouteData = newRouteData; context.RouteData = newRouteData;
if (_notifier.ShouldNotify("Microsoft.AspNet.Mvc.BeforeAction")) if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.BeforeAction"))
{ {
_notifier.Notify( _telemetry.WriteTelemetry(
"Microsoft.AspNet.Mvc.BeforeAction", "Microsoft.AspNet.Mvc.BeforeAction",
new { actionDescriptor, httpContext = context.HttpContext, routeData = context.RouteData}); new { actionDescriptor, httpContext = context.HttpContext, routeData = context.RouteData});
} }
@ -87,9 +87,9 @@ namespace Microsoft.AspNet.Mvc.Actions
} }
finally finally
{ {
if (_notifier.ShouldNotify("Microsoft.AspNet.Mvc.AfterAction")) if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.AfterAction"))
{ {
_notifier.Notify( _telemetry.WriteTelemetry(
"Microsoft.AspNet.Mvc.AfterAction", "Microsoft.AspNet.Mvc.AfterAction",
new { actionDescriptor, httpContext = context.HttpContext }); new { actionDescriptor, httpContext = context.HttpContext });
} }
@ -140,9 +140,9 @@ namespace Microsoft.AspNet.Mvc.Actions
_logger = factory.CreateLogger<MvcRouteHandler>(); _logger = factory.CreateLogger<MvcRouteHandler>();
} }
if (_notifier == null) if (_telemetry == null)
{ {
_notifier = context.RequestServices.GetRequiredService<INotifier>(); _telemetry = context.RequestServices.GetRequiredService<TelemetrySource>();
} }
} }
} }

View File

@ -2,6 +2,8 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
using System.Diagnostics.Tracing;
using System.Linq;
using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Mvc.ActionConstraints; using Microsoft.AspNet.Mvc.ActionConstraints;
using Microsoft.AspNet.Mvc.Actions; using Microsoft.AspNet.Mvc.Actions;
@ -64,7 +66,7 @@ namespace Microsoft.Framework.DependencyInjection
services.TryAddEnumerable( services.TryAddEnumerable(
ServiceDescriptor.Transient<IActionDescriptorProvider, ControllerActionDescriptorProvider>()); ServiceDescriptor.Transient<IActionDescriptorProvider, ControllerActionDescriptorProvider>());
services.TryAddSingleton<IActionDescriptorsCollectionProvider, DefaultActionDescriptorsCollectionProvider>(); services.TryAddSingleton<IActionDescriptorsCollectionProvider, DefaultActionDescriptorsCollectionProvider>();
// //
// Action Selection // Action Selection
// //
@ -132,7 +134,18 @@ namespace Microsoft.Framework.DependencyInjection
{ {
services.AddOptions(); services.AddOptions();
services.AddRouting(); services.AddRouting();
services.AddNotifier();
// Registered as a Source for us, and as a Listener for consumers.
if (!services.Any(s => s.ServiceType == typeof(TelemetrySource)))
{
var source = new TelemetryListener("Microsoft.AspNet");
services.AddInstance<TelemetrySource>(source);
if (!services.Any(s => s.ServiceType == typeof(TelemetryListener)))
{
services.AddInstance<TelemetryListener>(source);
}
}
} }
} }
} }

View File

@ -1,30 +1,48 @@
{ {
"description": "The core runtime components of ASP.NET MVC.", "description": "The core runtime components of ASP.NET MVC.",
"version": "6.0.0-*", "version": "6.0.0-*",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git://github.com/aspnet/mvc" "url": "git://github.com/aspnet/mvc"
},
"compilationOptions": {
"warningsAsErrors": true
},
"dependencies": {
"Microsoft.AspNet.Authorization": "1.0.0-*",
"Microsoft.AspNet.FileProviders.Abstractions": "1.0.0-*",
"Microsoft.AspNet.Hosting.Abstractions": "1.0.0-*",
"Microsoft.AspNet.Mvc.Abstractions": "6.0.0-*",
"Microsoft.Dnx.Runtime.Abstractions": "1.0.0-*",
"Microsoft.Framework.ClosedGenericMatcher.Sources": {
"version": "1.0.0-*",
"type": "build"
}, },
"compilationOptions": { "Microsoft.Framework.Logging.Abstractions": "1.0.0-*",
"warningsAsErrors": true "Microsoft.Framework.NotNullAttribute.Sources": {
"version": "1.0.0-*",
"type": "build"
}, },
"dependencies": { "Microsoft.Framework.PropertyActivator.Sources": {
"Microsoft.AspNet.Authorization": "1.0.0-*", "version": "1.0.0-*",
"Microsoft.AspNet.FileProviders.Abstractions": "1.0.0-*", "type": "build"
"Microsoft.AspNet.Hosting.Abstractions": "1.0.0-*",
"Microsoft.AspNet.Mvc.Abstractions": "6.0.0-*",
"Microsoft.Dnx.Runtime.Abstractions": "1.0.0-*",
"Microsoft.Framework.ClosedGenericMatcher.Sources": { "version": "1.0.0-*", "type": "build" },
"Microsoft.Framework.Logging.Abstractions": "1.0.0-*",
"Microsoft.Framework.Notification": "1.0.0-*",
"Microsoft.Framework.NotNullAttribute.Sources": { "version": "1.0.0-*", "type": "build" },
"Microsoft.Framework.PropertyActivator.Sources": { "version": "1.0.0-*", "type": "build" },
"Microsoft.Framework.PropertyHelper.Sources": { "version": "1.0.0-*", "type": "build" },
"Microsoft.Framework.SecurityHelper.Sources": { "version": "1.0.0-*", "type": "build" }
}, },
"frameworks": { "Microsoft.Framework.PropertyHelper.Sources": {
"dnx451": { }, "version": "1.0.0-*",
"dnxcore50": { } "type": "build"
} },
"Microsoft.Framework.SecurityHelper.Sources": {
"version": "1.0.0-*",
"type": "build"
},
"System.Diagnostics.Tracing.Telemetry": "4.0.0-beta-*"
},
"frameworks": {
"dnx451": {
"frameworkAssemblies": {
"System.Runtime": ""
}
},
"dnxcore50": { }
}
} }

View File

@ -9,8 +9,7 @@ using Microsoft.Framework.Internal;
using Microsoft.Framework.Logging; using Microsoft.Framework.Logging;
using Microsoft.Net.Http.Headers; using Microsoft.Net.Http.Headers;
using Microsoft.Framework.OptionsModel; using Microsoft.Framework.OptionsModel;
using Microsoft.Framework.Notification; using System.Diagnostics.Tracing;
using Microsoft.AspNet.Mvc.Actions;
namespace Microsoft.AspNet.Mvc.ActionResults namespace Microsoft.AspNet.Mvc.ActionResults
{ {
@ -28,7 +27,7 @@ namespace Microsoft.AspNet.Mvc.ActionResults
/// Gets or sets the name of the view to render. /// Gets or sets the name of the view to render.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// When <c>null</c>, defaults to <see cref="ActionDescriptor.Name"/>. /// When <c>null</c>, defaults to <see cref="Actions.ActionDescriptor.Name"/>.
/// </remarks> /// </remarks>
public string ViewName { get; set; } public string ViewName { get; set; }
@ -61,7 +60,7 @@ namespace Microsoft.AspNet.Mvc.ActionResults
var viewEngine = ViewEngine ?? services.GetRequiredService<ICompositeViewEngine>(); var viewEngine = ViewEngine ?? services.GetRequiredService<ICompositeViewEngine>();
var logger = services.GetRequiredService<ILogger<ViewResult>>(); var logger = services.GetRequiredService<ILogger<ViewResult>>();
var notifier = services.GetRequiredService<INotifier>(); var telemetry = services.GetRequiredService<TelemetrySource>();
var options = services.GetRequiredService<IOptions<MvcViewOptions>>(); var options = services.GetRequiredService<IOptions<MvcViewOptions>>();
@ -69,9 +68,9 @@ namespace Microsoft.AspNet.Mvc.ActionResults
var viewEngineResult = viewEngine.FindView(context, viewName); var viewEngineResult = viewEngine.FindView(context, viewName);
if(!viewEngineResult.Success) if(!viewEngineResult.Success)
{ {
if (notifier.ShouldNotify("Microsoft.AspNet.Mvc.ViewResultViewNotFound")) if (telemetry.IsEnabled("Microsoft.AspNet.Mvc.ViewResultViewNotFound"))
{ {
notifier.Notify( telemetry.WriteTelemetry(
"Microsoft.AspNet.Mvc.ViewResultViewNotFound", "Microsoft.AspNet.Mvc.ViewResultViewNotFound",
new new
{ {
@ -89,9 +88,9 @@ namespace Microsoft.AspNet.Mvc.ActionResults
} }
var view = viewEngineResult.EnsureSuccessful().View; var view = viewEngineResult.EnsureSuccessful().View;
if (notifier.ShouldNotify("Microsoft.AspNet.Mvc.ViewResultViewFound")) if (telemetry.IsEnabled("Microsoft.AspNet.Mvc.ViewResultViewFound"))
{ {
notifier.Notify( telemetry.WriteTelemetry(
"Microsoft.AspNet.Mvc.ViewResultViewFound", "Microsoft.AspNet.Mvc.ViewResultViewFound",
new { actionContext = context, result = this, viewName, view = view }); new { actionContext = context, result = this, viewName, view = view });
} }

View File

@ -3,6 +3,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Tracing;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
@ -20,7 +21,6 @@ using Microsoft.AspNet.Testing;
using Microsoft.Framework.Internal; using Microsoft.Framework.Internal;
using Microsoft.Framework.Logging; using Microsoft.Framework.Logging;
using Microsoft.Framework.Logging.Testing; using Microsoft.Framework.Logging.Testing;
using Microsoft.Framework.Notification;
using Microsoft.Framework.OptionsModel; using Microsoft.Framework.OptionsModel;
using Microsoft.Net.Http.Headers; using Microsoft.Net.Http.Headers;
using Moq; using Moq;
@ -2046,7 +2046,7 @@ namespace Microsoft.AspNet.Mvc.Actions
new IValueProviderFactory[0], new IValueProviderFactory[0],
new ActionBindingContextAccessor(), new ActionBindingContextAccessor(),
new NullLoggerFactory().CreateLogger<ControllerActionInvoker>(), new NullLoggerFactory().CreateLogger<ControllerActionInvoker>(),
new Notifier(new ProxyNotifierMethodAdapter()), new TelemetryListener("Microsoft.AspNet"),
maxAllowedErrorsInModelState); maxAllowedErrorsInModelState);
return invoker; return invoker;
@ -2107,7 +2107,7 @@ namespace Microsoft.AspNet.Mvc.Actions
new IValueProviderFactory[0], new IValueProviderFactory[0],
new ActionBindingContextAccessor(), new ActionBindingContextAccessor(),
new NullLoggerFactory().CreateLogger<ControllerActionInvoker>(), new NullLoggerFactory().CreateLogger<ControllerActionInvoker>(),
new Notifier(new ProxyNotifierMethodAdapter()), new TelemetryListener("Microsoft.AspNet"),
200); 200);
// Act // Act
@ -2208,7 +2208,7 @@ namespace Microsoft.AspNet.Mvc.Actions
IReadOnlyList<IValueProviderFactory> valueProviderFactories, IReadOnlyList<IValueProviderFactory> valueProviderFactories,
IActionBindingContextAccessor actionBindingContext, IActionBindingContextAccessor actionBindingContext,
ILogger logger, ILogger logger,
INotifier notifier, TelemetrySource telemetry,
int maxAllowedErrorsInModelState) int maxAllowedErrorsInModelState)
: base( : base(
actionContext, actionContext,
@ -2223,7 +2223,7 @@ namespace Microsoft.AspNet.Mvc.Actions
valueProviderFactories, valueProviderFactories,
actionBindingContext, actionBindingContext,
logger, logger,
notifier, telemetry,
maxAllowedErrorsInModelState) maxAllowedErrorsInModelState)
{ {
ControllerFactory = controllerFactory; ControllerFactory = controllerFactory;

View File

@ -2,14 +2,13 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
using System.Diagnostics.Tracing;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.AspNet.Mvc.Internal; using Microsoft.AspNet.Mvc.Internal;
using Microsoft.AspNet.Mvc.TestCommon.Notification;
using Microsoft.AspNet.Routing; using Microsoft.AspNet.Routing;
using Microsoft.Framework.Logging; using Microsoft.Framework.Logging;
using Microsoft.Framework.Logging.Testing; using Microsoft.Framework.Logging.Testing;
using Microsoft.Framework.Notification;
using Microsoft.Framework.OptionsModel; using Microsoft.Framework.OptionsModel;
using Moq; using Moq;
using Xunit; using Xunit;
@ -158,9 +157,9 @@ namespace Microsoft.AspNet.Mvc.Actions
public async Task RouteAsync_Notifies_ActionSelected() public async Task RouteAsync_Notifies_ActionSelected()
{ {
// Arrange // Arrange
var listener = new TestNotificationListener(); var listener = new TestTelemetryListener();
var context = CreateRouteContext(notificationListener: listener); var context = CreateRouteContext(telemetryListener: listener);
context.RouteData.Values.Add("tag", "value"); context.RouteData.Values.Add("tag", "value");
var handler = new MvcRouteHandler(); var handler = new MvcRouteHandler();
@ -183,9 +182,9 @@ namespace Microsoft.AspNet.Mvc.Actions
public async Task RouteAsync_Notifies_ActionInvoked() public async Task RouteAsync_Notifies_ActionInvoked()
{ {
// Arrange // Arrange
var listener = new TestNotificationListener(); var listener = new TestTelemetryListener();
var context = CreateRouteContext(notificationListener: listener); var context = CreateRouteContext(telemetryListener: listener);
var handler = new MvcRouteHandler(); var handler = new MvcRouteHandler();
@ -203,7 +202,7 @@ namespace Microsoft.AspNet.Mvc.Actions
IActionInvokerFactory invokerFactory = null, IActionInvokerFactory invokerFactory = null,
ILoggerFactory loggerFactory = null, ILoggerFactory loggerFactory = null,
IOptions<MvcOptions> optionsAccessor = null, IOptions<MvcOptions> optionsAccessor = null,
object notificationListener = null) object telemetryListener = null)
{ {
if (actionDescriptor == null) if (actionDescriptor == null)
{ {
@ -243,10 +242,10 @@ namespace Microsoft.AspNet.Mvc.Actions
optionsAccessor = new TestOptionsManager<MvcOptions>(); optionsAccessor = new TestOptionsManager<MvcOptions>();
} }
var notifier = new Notifier(new ProxyNotifierMethodAdapter()); var telemetry = new TelemetryListener("Microsoft.AspNet");
if (notificationListener != null) if (telemetryListener != null)
{ {
notifier.EnlistTarget(notificationListener); telemetry.SubscribeWithAdapter(telemetryListener);
} }
var httpContext = new Mock<HttpContext>(); var httpContext = new Mock<HttpContext>();
@ -262,8 +261,8 @@ namespace Microsoft.AspNet.Mvc.Actions
.Returns(new MvcMarkerService()); .Returns(new MvcMarkerService());
httpContext.Setup(h => h.RequestServices.GetService(typeof(IOptions<MvcOptions>))) httpContext.Setup(h => h.RequestServices.GetService(typeof(IOptions<MvcOptions>)))
.Returns(optionsAccessor); .Returns(optionsAccessor);
httpContext.Setup(h => h.RequestServices.GetService(typeof(INotifier))) httpContext.Setup(h => h.RequestServices.GetService(typeof(TelemetrySource)))
.Returns(notifier); .Returns(telemetry);
return new RouteContext(httpContext.Object); return new RouteContext(httpContext.Object);
} }

View File

@ -1,28 +1,33 @@
{ {
"compilationOptions": { "compilationOptions": {
"warningsAsErrors": true "warningsAsErrors": true
},
"dependencies": {
"Microsoft.AspNet.Http": "1.0.0-*",
"Microsoft.AspNet.Mvc": "6.0.0-*",
"Microsoft.AspNet.Mvc.TestCommon": {
"version": "6.0.0-*",
"type": "build"
}, },
"dependencies": { "Microsoft.AspNet.Mvc.Formatters.Xml": "6.0.0-*",
"Microsoft.AspNet.Http": "1.0.0-*", "Microsoft.AspNet.Mvc.TestTelemetryListener.Sources": {
"Microsoft.AspNet.Mvc": "6.0.0-*", "version": "6.0.0-*",
"Microsoft.AspNet.Mvc.TestCommon": { "type": "build"
"version": "6.0.0-*",
"type": "build"
},
"Microsoft.AspNet.Mvc.Formatters.Xml": "6.0.0-*",
"Microsoft.AspNet.Testing": "1.0.0-*",
"Microsoft.Framework.DependencyInjection": "1.0.0-*",
"Microsoft.Framework.Logging.Testing": "1.0.0-*",
"Microsoft.Framework.WebEncoders.Testing": "1.0.0-*",
"Moq": "4.2.1312.1622",
"xunit.runner.aspnet": "2.0.0-aspnet-*"
}, },
"commands": { "Microsoft.AspNet.Testing": "1.0.0-*",
"test": "xunit.runner.aspnet" "Microsoft.Framework.DependencyInjection": "1.0.0-*",
}, "Microsoft.Framework.Logging.Testing": "1.0.0-*",
"frameworks": { "Microsoft.Framework.TelemetryAdapter": "1.0.0-*",
"dnx451": { "Microsoft.Framework.WebEncoders.Testing": "1.0.0-*",
"compilationOptions": { "define": ["MOCK_SUPPORT"] } "Moq": "4.2.1312.1622",
} "xunit.runner.aspnet": "2.0.0-aspnet-*"
},
"commands": {
"test": "xunit.runner.aspnet"
},
"frameworks": {
"dnx451": {
"compilationOptions": { "define": [ "MOCK_SUPPORT" ] }
} }
}
} }

View File

@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.AspNet.Mvc.TestCommon.Notification namespace Microsoft.AspNet.Mvc
{ {
public interface IProxyActionContext public interface IProxyActionContext
{ {

View File

@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.AspNet.Mvc.TestCommon.Notification namespace Microsoft.AspNet.Mvc
{ {
public interface IProxyActionDescriptor public interface IProxyActionDescriptor
{ {

View File

@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.AspNet.Mvc.TestCommon.Notification namespace Microsoft.AspNet.Mvc
{ {
public interface IProxyActionResult public interface IProxyActionResult
{ {

View File

@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.AspNet.Mvc.TestCommon.Notification namespace Microsoft.AspNet.Mvc
{ {
public interface IProxyHttpContext public interface IProxyHttpContext
{ {

View File

@ -3,7 +3,7 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace Microsoft.AspNet.Mvc.TestCommon.Notification namespace Microsoft.AspNet.Mvc
{ {
public interface IProxyRouteData public interface IProxyRouteData
{ {

View File

@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.AspNet.Mvc.TestCommon.Notification namespace Microsoft.AspNet.Mvc
{ {
public interface IProxyView public interface IProxyView
{ {

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>9879b5d5-2325-4a81-b4df-f279fe8feeb4</ProjectGuid>
<RootNamespace>Microsoft.AspNet.Mvc.TestTelemetryListener.Sources</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

View File

@ -2,11 +2,11 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.Framework.Notification; using Microsoft.Framework.TelemetryAdapter;
namespace Microsoft.AspNet.Mvc.TestCommon.Notification namespace Microsoft.AspNet.Mvc
{ {
public class TestNotificationListener public class TestTelemetryListener
{ {
public class OnBeforeActionEventData public class OnBeforeActionEventData
{ {
@ -17,7 +17,7 @@ namespace Microsoft.AspNet.Mvc.TestCommon.Notification
public OnBeforeActionEventData BeforeAction { get; set; } public OnBeforeActionEventData BeforeAction { get; set; }
[NotificationName("Microsoft.AspNet.Mvc.BeforeAction")] [TelemetryName("Microsoft.AspNet.Mvc.BeforeAction")]
public virtual void OnBeforeAction( public virtual void OnBeforeAction(
IProxyHttpContext httpContext, IProxyHttpContext httpContext,
IProxyRouteData routeData, IProxyRouteData routeData,
@ -39,7 +39,7 @@ namespace Microsoft.AspNet.Mvc.TestCommon.Notification
public OnAfterActionEventData AfterAction { get; set; } public OnAfterActionEventData AfterAction { get; set; }
[NotificationName("Microsoft.AspNet.Mvc.AfterAction")] [TelemetryName("Microsoft.AspNet.Mvc.AfterAction")]
public virtual void OnAfterAction( public virtual void OnAfterAction(
IProxyHttpContext httpContext, IProxyHttpContext httpContext,
IProxyActionDescriptor actionDescriptor) IProxyActionDescriptor actionDescriptor)
@ -61,7 +61,7 @@ namespace Microsoft.AspNet.Mvc.TestCommon.Notification
public OnViewResultViewFoundEventData ViewResultViewFound { get; set; } public OnViewResultViewFoundEventData ViewResultViewFound { get; set; }
[NotificationName("Microsoft.AspNet.Mvc.ViewResultViewFound")] [TelemetryName("Microsoft.AspNet.Mvc.ViewResultViewFound")]
public virtual void OnViewResultViewFound( public virtual void OnViewResultViewFound(
IProxyActionContext actionContext, IProxyActionContext actionContext,
IProxyActionResult result, IProxyActionResult result,
@ -87,7 +87,7 @@ namespace Microsoft.AspNet.Mvc.TestCommon.Notification
public OnViewResultViewNotFoundEventData ViewResultViewNotFound { get; set; } public OnViewResultViewNotFoundEventData ViewResultViewNotFound { get; set; }
[NotificationName("Microsoft.AspNet.Mvc.ViewResultViewNotFound")] [TelemetryName("Microsoft.AspNet.Mvc.ViewResultViewNotFound")]
public virtual void OnViewResultViewNotFound( public virtual void OnViewResultViewNotFound(
IProxyActionContext actionContext, IProxyActionContext actionContext,
IProxyActionResult result, IProxyActionResult result,

View File

@ -0,0 +1,12 @@
{
"version": "6.0.0-*",
"shared": "**/*.cs",
"frameworks": {
"dnx451": { },
"dnxcore50": {
"dependencies": {
"System.Runtime": "4.0.21-beta-*"
}
}
}
}

View File

@ -2,17 +2,16 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
using System.Diagnostics.Tracing;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.AspNet.Http.Internal; using Microsoft.AspNet.Http.Internal;
using Microsoft.AspNet.Mvc.Actions; using Microsoft.AspNet.Mvc.Actions;
using Microsoft.AspNet.Mvc.Rendering; using Microsoft.AspNet.Mvc.Rendering;
using Microsoft.AspNet.Mvc.TestCommon.Notification;
using Microsoft.AspNet.Routing; using Microsoft.AspNet.Routing;
using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.DependencyInjection;
using Microsoft.Framework.Logging; using Microsoft.Framework.Logging;
using Microsoft.Framework.Notification;
using Microsoft.Framework.OptionsModel; using Microsoft.Framework.OptionsModel;
using Microsoft.Net.Http.Headers; using Microsoft.Net.Http.Headers;
using Moq; using Moq;
@ -207,8 +206,14 @@ namespace Microsoft.AspNet.Mvc.ActionResults
.Verifiable(); .Verifiable();
var serviceProvider = new Mock<IServiceProvider>(); var serviceProvider = new Mock<IServiceProvider>();
serviceProvider.Setup(s => s.GetService(typeof(INotifier)))
.Returns(new Notifier(new ProxyNotifierMethodAdapter())); var telemetry = new TelemetryListener("Microsoft.AspNet");
serviceProvider
.Setup(s => s.GetService(typeof(TelemetrySource)))
.Returns(telemetry);
serviceProvider
.Setup(s => s.GetService(typeof(TelemetryListener)))
.Returns(telemetry);
serviceProvider.Setup(p => p.GetService(typeof(ICompositeViewEngine))) serviceProvider.Setup(p => p.GetService(typeof(ICompositeViewEngine)))
.Returns(viewEngine.Object); .Returns(viewEngine.Object);
serviceProvider.Setup(p => p.GetService(typeof(ILogger<ViewResult>))) serviceProvider.Setup(p => p.GetService(typeof(ILogger<ViewResult>)))
@ -242,8 +247,8 @@ namespace Microsoft.AspNet.Mvc.ActionResults
var httpContext = GetHttpContext(); var httpContext = GetHttpContext();
var context = new ActionContext(httpContext, new RouteData(), new ActionDescriptor()); var context = new ActionContext(httpContext, new RouteData(), new ActionDescriptor());
var listener = new TestNotificationListener(); var listener = new TestTelemetryListener();
httpContext.RequestServices.GetRequiredService<INotifier>().EnlistTarget(listener); httpContext.RequestServices.GetRequiredService<TelemetryListener>().SubscribeWithAdapter(listener);
var viewEngine = new Mock<IViewEngine>(); var viewEngine = new Mock<IViewEngine>();
var view = Mock.Of<IView>(); var view = Mock.Of<IView>();
@ -276,8 +281,8 @@ namespace Microsoft.AspNet.Mvc.ActionResults
var httpContext = GetHttpContext(); var httpContext = GetHttpContext();
var context = new ActionContext(httpContext, new RouteData(), new ActionDescriptor()); var context = new ActionContext(httpContext, new RouteData(), new ActionDescriptor());
var listener = new TestNotificationListener(); var listener = new TestTelemetryListener();
httpContext.RequestServices.GetRequiredService<INotifier>().EnlistTarget(listener); httpContext.RequestServices.GetRequiredService<TelemetryListener>().SubscribeWithAdapter(listener);
var viewEngine = new Mock<IViewEngine>(); var viewEngine = new Mock<IViewEngine>();
var view = Mock.Of<IView>(); var view = Mock.Of<IView>();
@ -316,9 +321,11 @@ namespace Microsoft.AspNet.Mvc.ActionResults
serviceProvider.Setup(s => s.GetService(typeof(IOptions<MvcViewOptions>))) serviceProvider.Setup(s => s.GetService(typeof(IOptions<MvcViewOptions>)))
.Returns(optionsAccessor.Object); .Returns(optionsAccessor.Object);
serviceProvider.Setup(s => s.GetService(typeof(INotifier))) var telemetry = new TelemetryListener("Microsoft.AspNet");
.Returns(new Notifier(new ProxyNotifierMethodAdapter())); serviceProvider.Setup(s => s.GetService(typeof(TelemetryListener)))
.Returns(telemetry);
serviceProvider.Setup(s => s.GetService(typeof(TelemetrySource)))
.Returns(telemetry);
var httpContext = new DefaultHttpContext(); var httpContext = new DefaultHttpContext();
httpContext.RequestServices = serviceProvider.Object; httpContext.RequestServices = serviceProvider.Object;

View File

@ -1,25 +1,33 @@
{ {
"compilationOptions": { "compilationOptions": {
"warningsAsErrors": true "warningsAsErrors": true
},
"dependencies": {
"Microsoft.AspNet.Http": "1.0.0-*",
"Microsoft.AspNet.Mvc": "6.0.0-*",
"Microsoft.AspNet.Mvc.Formatters.Xml": "6.0.0-*",
"Microsoft.AspNet.Mvc.TestCommon": {
"version": "6.0.0-*",
"type": "build"
}, },
"dependencies": { "Microsoft.AspNet.Mvc.TestTelemetryListener.Sources": {
"Microsoft.AspNet.Http": "1.0.0-*", "version": "6.0.0-*",
"Microsoft.AspNet.Mvc": "6.0.0-*", "type": "build"
"Microsoft.AspNet.Mvc.Formatters.Xml": "6.0.0-*",
"Microsoft.AspNet.Mvc.TestCommon": { "version": "6.0.0-*", "type": "build" },
"Microsoft.AspNet.Testing": "1.0.0-*",
"Microsoft.Framework.DependencyInjection": "1.0.0-*",
"Microsoft.Framework.Logging.Testing": "1.0.0-*",
"Microsoft.Framework.WebEncoders.Testing": "1.0.0-*",
"Moq": "4.2.1312.1622",
"xunit.runner.aspnet": "2.0.0-aspnet-*"
}, },
"commands": { "Microsoft.AspNet.Testing": "1.0.0-*",
"test": "xunit.runner.aspnet" "Microsoft.Framework.DependencyInjection": "1.0.0-*",
}, "Microsoft.Framework.Logging.Testing": "1.0.0-*",
"frameworks": { "Microsoft.Framework.TelemetryAdapter": "1.0.0-*",
"dnx451": { "Microsoft.Framework.WebEncoders.Testing": "1.0.0-*",
"compilationOptions": { "define": ["MOCK_SUPPORT"] } "Moq": "4.2.1312.1622",
} "xunit.runner.aspnet": "2.0.0-aspnet-*"
},
"commands": {
"test": "xunit.runner.aspnet"
},
"frameworks": {
"dnx451": {
"compilationOptions": { "define": [ "MOCK_SUPPORT" ] }
} }
}
} }