microsoft / applicationinsights-aspnetcore Goto Github PK
View Code? Open in Web Editor NEWASP.NET Core web applications monitoring
ASP.NET Core web applications monitoring
... because it requires adding non-trivial code to a WebAPI project, which, out of the box looks like this:
public class Startup
{
public Startup(IHostingEnvironment env) {
}
public void ConfigureServices(IServiceCollection services) {
services.AddMvc();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env) {
app.UseStaticFiles();
app.UseMvc();
}
}
I'm trying to test out sending custom events through an MVC 6 application, but am not seeing any of them coming up. I am seeing other events (response times, page loads, etc.).
The sample code is available here: https://github.com/avodovnik/MonitoringApplications. You can find the TrackEvent
being called in HomeController
's Contact
and GenerateEvents
.
I tried sending events with a properties dictionary, then reverted to simple events, still to no awail. Am not getting any info in the output view inside Visual Studio except for requests.
Am I missing something?
I'm following pretty closely to the leading edge of aspnet development, and because of the API changes between beta4 and beta5 it would be a major pain (for a very temporary benefit) to use the published nupkg. The usual answer to this problem is to just get the source and build it myself, which I tried to do. I guessed that the beta5 branch is my best bet and tried to build it, but it failed. A couple of things obtain:
NuGet.config
in the solution directory doesn't work outside of Microsoft. I had to remove it to do a successful restore.dnu build
fails because of a bunch of what appear to be namespacing problems. For example:C:\Users\Benjamin\src\ApplicationInsights-aspnet5\src\Microsoft.ApplicationInsights.AspNet\Extensions\ApplicationInsightsExtensions.cs(26,87): error CS0433: The type 'IApplicationBuilder' exists in both 'Microsoft.AspNet.Http.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' and 'Microsoft.AspNet.Http.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
and
C:\Users\Benjamin\src\ApplicationInsights-aspnet5\src\Microsoft.ApplicationInsights.AspNet\TelemetryInitializers\ClientIpHeaderTelemetryInitializer.cs(12,33):
error CS0234: The type or namespace name 'Features' does not exist in the namespace 'Microsoft.AspNet.Http' (are you missing an assembly reference?)
Is there a build script somewhere that you're using internally?
i'm try run mvc app with ApplicationInsights over microsoft/aspnet 1.0.0-beta4 docker image.
'dnx kestrel' return exception:
Autofac.Core.DependencyResolutionException: An exception was thrown while invoking the constructor 'Void .ctor(
TelemetryConfiguration)' on type 'TelemetryClient'. ---> An exception was thrown by the type initializer for Mi
crosoft.ApplicationInsights.Extensibility.Implementation.Tracing.CoreEventSource (See inner exception for detai
ls.) ---> System.TypeInitializationException: An exception was thrown by the type initializer for Microsoft.App
licationInsights.Extensibility.Implementation.Tracing.CoreEventSource ---> System.InvalidProgramException: Inva
lid IL code in Microsoft.Diagnostics.Tracing.EventSource:Initialize (System.Guid,string,string[]): IL_00cc: stl
oc.1
at Microsoft.Diagnostics.Tracing.EventSource..ctor (EventSourceSettings settings, System.String[] traits) [0x
00000] in :0
at Microsoft.Diagnostics.Tracing.EventSource..ctor (EventSourceSettings settings) [0x00000] in :0
at Microsoft.Diagnostics.Tracing.EventSource..ctor () [0x00000] in :0
at Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.CoreEventSource..ctor () [0x00000] in <
filename unknown>:0
at Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.CoreEventSource..cctor () [0x00000] in
:0
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.InnerInvoke () [0x00000] in :0
at System.Threading.Tasks.Task.Execute () [0x00000] in :0
--- End of inner exception stack trace ---
at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate () [0x00000] in :0
at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance (IComponentContext context, IEnume
rable1 parameters) [0x00000] in <filename unknown>:0 at Autofac.Core.Resolving.InstanceLookup.Activate (IEnumerable
1 parameters) [0x00000] in :
0
at Autofac.Core.Resolving.InstanceLookup.b__0 () [0x00000] in :0
at Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare (Guid id, System.Func1 creator) [0x00000] in <fil ename unknown>:0 at Autofac.Core.Resolving.InstanceLookup.Execute () [0x00000] in <filename unknown>:0 at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance (ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable
1 parameters) [0x00000] in :0
at Autofac.Core.Resolving.ResolveOperation.ResolveComponent (IComponentRegistration registration, IEnumerable
1 parameters) [0x00000] in <filename unknown>:0 at Autofac.Core.Resolving.ResolveOperation.Execute (IComponentRegistration registration, IEnumerable
1 parame
ters) [0x00000] in :0
System.TypeInitializationException: An exception was thrown by the type initializer for Microsoft.ApplicationIn
sights.Extensibility.Implementation.Tracing.CoreEventSource ---> System.InvalidProgramException: Invalid IL cod
e in Microsoft.Diagnostics.Tracing.EventSource:Initialize (System.Guid,string,string[]): IL_00cc: stloc.1
at Microsoft.Diagnostics.Tracing.EventSource..ctor (EventSourceSettings settings, System.String[] traits) [0x
00000] in :0
at Microsoft.Diagnostics.Tracing.EventSource..ctor (EventSourceSettings settings) [0x00000] in :0
at Microsoft.Diagnostics.Tracing.EventSource..ctor () [0x00000] in :0
at Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.CoreEventSource..ctor () [0x00000] in <
filename unknown>:0
at Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.CoreEventSource..cctor () [0x00000] in
:0
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.InnerInvoke () [0x00000] in :0
at System.Threading.Tasks.Task.Execute () [0x00000] in :0
System.InvalidProgramException: Invalid IL code in Microsoft.Diagnostics.Tracing.EventSource:Initialize (System
.Guid,string,string[]): IL_00cc: stloc.1
at Microsoft.Diagnostics.Tracing.EventSource..ctor (EventSourceSettings settings, System.String[] traits) [0x
00000] in :0
at Microsoft.Diagnostics.Tracing.EventSource..ctor (EventSourceSettings settings) [0x00000] in :0
at Microsoft.Diagnostics.Tracing.EventSource..ctor () [0x00000] in :0
at Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.CoreEventSource..ctor () [0x00000] in <
filename unknown>:0
at Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.CoreEventSource..cctor () [0x00000] in
:0
Unhandled Exception:
System.TypeInitializationException: An exception was thrown by the type initializer for Microsoft.ApplicationIn
sights.Extensibility.Implementation.Tracing.CoreEventSource ---> System.InvalidProgramException: Invalid IL cod
e in Microsoft.Diagnostics.Tracing.EventSource:Initialize (System.Guid,string,string[]): IL_00cc: stloc.1
at Microsoft.Diagnostics.Tracing.EventSource..ctor (EventSourceSettings settings, System.String[] traits) [0x
00000] in :0
at Microsoft.Diagnostics.Tracing.EventSource..ctor (EventSourceSettings settings) [0x00000] in :0
at Microsoft.Diagnostics.Tracing.EventSource..ctor () [0x00000] in :0
at Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.CoreEventSource..ctor () [0x00000] in <
filename unknown>:0
at Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.CoreEventSource..cctor () [0x00000] in
:0
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.InnerInvoke () [0x00000] in :0
at System.Threading.Tasks.Task.Execute () [0x00000] in :0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: An exception was thrown by the type init
ializer for Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.CoreEventSource ---> System.Inva
lidProgramException: Invalid IL code in Microsoft.Diagnostics.Tracing.EventSource:Initialize (System.Guid,strin
g,string[]): IL_00cc: stloc.1
at Microsoft.Diagnostics.Tracing.EventSource..ctor (EventSourceSettings settings, System.String[] traits) [0x
00000] in :0
at Microsoft.Diagnostics.Tracing.EventSource..ctor (EventSourceSettings settings) [0x00000] in :0
at Microsoft.Diagnostics.Tracing.EventSource..ctor () [0x00000] in :0
at Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.CoreEventSource..ctor () [0x00000] in <
filename unknown>:0
at Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.CoreEventSource..cctor () [0x00000] in
:0
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.InnerInvoke () [0x00000] in :0
at System.Threading.Tasks.Task.Execute () [0x00000] in :0
Including ApplicationInsights in class names is redundant because the product name is already included in the namespace. Making the following naming changes will help to both shorten the component names and make them more descriptive.
ApplicationInsightsExceptionMiddleware -> ExceptionTrackingMiddleware
ApplicationInsightsRequestMiddleware -> RequestTrackingMiddleware
It feels that some recent changes set us on a path of using end-to-end tests over lower-level tests, such as integration and unit tests. I think this is a dangerous trend as it will make changing the code more and more difficult over time, especially by outside contributors, who are not intimately familiar with the test infrastructure. Pull request #17 contains comments describing what actually happened to me while integrating changes in pull request #15 with a relatively small set of the end-to-end RequestTelemetryTests
.
This will allow to mark synthetic traffic from availability tests https://azure.microsoft.com/en-us/documentation/articles/app-insights-monitor-web-app-availability/ with special flag "Synthetic Source"
We need to implement synthetic traffic filtering SyntheticTelemetryInitializer
like we will have in 0.15 SDK for old-style web applications:
If header GsmSyntheticTestRunId
present in request - set
telemetry.Context.Operation.SyntheticSource
to Application Insights Availability Monitoring
telemetry.Context.User.Id
to the value of the header SyntheticTest-Location
telemetry.Context.Session.Id
to the value of the header SyntheticTest-RunId
Two things wrong with the script tag here:
type="text/javascript"
instead of language='javascript'
=
signThe first is causing warnings to be logged in Internet Explorer console.
Many of the packages in ASP.NET 5 and DNX now have "Abstractions" packages (as of beta5; in beta4 these were generally "Interfaces" packages) that contain just the raw interfaces, without specific implementations. As a general rule, library packages (such as Application Insights) should reference the abstractions and not concrete implementations.
E.g. the references here: https://github.com/Microsoft/ApplicationInsights-aspnet5/blob/master/src/Microsoft.ApplicationInsights.AspNet/project.json#L13-L17
You should be able to change the reference to Microsoft.Framework.Logging
to instead be Microsoft.Framework.Logging.Abstractions
(in beta5; or use Microsoft.Framework.Logging.Interfaces
in beta4).
Scenarios like ASPNET apps selfhosted can be used offline and when they are online the data needs to be synced.
We will need a telemetry channel that can keep the data offline and sync when online. Also would be useful to have retry logic for data sync instead of fire and forget
Asp.Net team adviced to consider not to use @html helper in Layout.cshtml, use extension method instead to get rid of using statement and passing InstrumentationKey explicitly
We seem to be getting two exceptions from the ASP.Net pipeline with following stack:
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, Object[] args)
at Microsoft.Framework.Runtime.Common.DependencyInjection.ActivatorUtilities.<>c__DisplayClass4_0.b__0(IServiceProvider services)
at Microsoft.Framework.Runtime.Common.DependencyInjection.ActivatorUtilities.CreateInstance(IServiceProvider services, Type type)
at Microsoft.Framework.Runtime.CompilerServices.CreateService[T](IServiceProvider sp, IAssemblyLoadContext loadContext, TypeInformation typeInfo)
at Microsoft.Framework.Runtime.ProjectLibraryExportProvider.b__5_1(TypeInformation typeInfo)
at System.Collections.Generic.DictionaryExtensions.GetOrAdd[TKey,TValue](IDictionary2 dictionary, TKey key, Func
2 factory)
at Microsoft.Framework.Runtime.ProjectLibraryExportProvider.<>c__DisplayClass5_0.b__0(CacheContext ctx)
at Microsoft.Framework.Runtime.Caching.CacheExtensions.<>c__DisplayClass0_01.<Get>b__0(CacheContext ctx) at Microsoft.Framework.Runtime.Caching.Cache.CreateEntry(Object k, Func
2 acquire)
at Microsoft.Framework.Runtime.Caching.Cache.<>c__DisplayClass5_0.b__0()
at System.Lazy1.CreateValue() at System.Lazy
1.LazyInitValue()
at System.Lazy1.get_Value() at Microsoft.Framework.Runtime.Caching.Cache.Get(Object key, Func
2 factory)
at Microsoft.Framework.Runtime.Caching.CacheExtensions.Get[T](ICache cache, Object key, Func2 factory) at Microsoft.Framework.Runtime.ProjectLibraryExportProvider.GetLibraryExport(ILibraryKey target) at Microsoft.Framework.Runtime.CompositeLibraryExportProvider.<>c__DisplayClass2_0.<GetLibraryExport>b__0(ILibraryExportProvider r) at System.Linq.Enumerable.WhereSelectArrayIterator
2.MoveNext()
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable1 source, Func
2 predicate)
at Microsoft.Framework.Runtime.CompositeLibraryExportProvider.GetLibraryExport(ILibraryKey target)
at Microsoft.Framework.Runtime.LibraryManager.GetLibraryExport(String name, String aspect)
at Microsoft.Framework.Runtime.LibraryManager.GetLibraryExport(String name)
at Microsoft.AspNet.Mvc.Razor.Compilation.RoslynCompilationService.GetApplicationReferences()
at System.Lazy1.CreateValue() at System.Lazy
1.LazyInitValue()
at System.Lazy1.get_Value() at Microsoft.AspNet.Mvc.Razor.Compilation.RoslynCompilationService.Compile(RelativeFileInfo fileInfo, String compilationContent) at Microsoft.AspNet.Mvc.Razor.Compilation.RazorCompilationService.Compile(RelativeFileInfo file) at Microsoft.AspNet.Mvc.Razor.Compilation.CompilerCache.OnCacheMiss(RelativeFileInfo file, String normalizedPath, Func
2 compile)
at Microsoft.AspNet.Mvc.Razor.Compilation.CompilerCache.GetOrAddCore(String relativePath, Func2 compile) at Microsoft.AspNet.Mvc.Razor.Compilation.CompilerCache.GetOrAdd(String relativePath, Func
2 compile)
at Microsoft.AspNet.Mvc.Razor.VirtualPathRazorPageFactory.CreateInstance(String relativePath)
at Microsoft.AspNet.Mvc.Razor.RazorViewEngine.LocatePageFromViewLocations(ActionContext context, String pageName, Boolean isPartial)
at Microsoft.AspNet.Mvc.Razor.RazorViewEngine.GetRazorPageResult(ActionContext context, String pageName, Boolean isPartial)
at Microsoft.AspNet.Mvc.Razor.RazorViewEngine.FindView(ActionContext context, String viewName)
at Microsoft.AspNet.Mvc.Rendering.CompositeViewEngine.FindView(ActionContext context, String viewName, Boolean partial)
at Microsoft.AspNet.Mvc.Rendering.CompositeViewEngine.FindView(ActionContext context, String viewName)
at Microsoft.AspNet.Mvc.ViewResult.d__24.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNet.Mvc.Core.FilterActionInvoker.d__52.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.AspNet.Mvc.Core.FilterActionInvoker.d__51.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNet.Mvc.Core.FilterActionInvoker.d__50.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.AspNet.Mvc.Core.FilterActionInvoker.d__45.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNet.Mvc.Core.FilterActionInvoker.d__40.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNet.Mvc.MvcRouteHandler.d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNet.Mvc.MvcRouteHandler.d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNet.Routing.Template.TemplateRoute.d__25.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNet.Routing.RouteCollection.d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNet.Builder.RouterMiddleware.d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNet.Authentication.AuthenticationMiddleware1.<Invoke>d__18.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNet.Authentication.AuthenticationMiddleware
1.d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNet.Authentication.AuthenticationMiddleware1.<Invoke>d__18.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNet.Authentication.AuthenticationMiddleware
1.d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNet.Authentication.AuthenticationMiddleware1.<Invoke>d__18.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNet.Authentication.AuthenticationMiddleware
1.d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNet.Authentication.AuthenticationMiddleware1.<Invoke>d__18.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNet.Authentication.AuthenticationMiddleware
1.d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Microsoft.ApplicationInsights.AspNet.ExceptionTrackingMiddleware.d__4.MoveNext() in C:\GitHub-microsoft\ApplicationInsights-aspnet5\src\Microsoft.ApplicationInsights.AspNet\ExceptionTrackingMiddleware.cs:line 30
Open Source projects hosted on GitHub typically use Git Flow branching model. One of its key differences from the "DevDiv branching model" that we fell into is that the Git Flow master branch serves as DevDiv release branch. Git Flow model is simpler for contributors, well documented and well known. I think we should adopt it before going "public".
Reported by @AlexBulankou
Auto-instrumentation is working fine (requests are getting sent)
Then I add the code to track events and metrics:
TelemetryClient telemetryClient = (TelemetryClient)this.Resolver.GetService(typeof(TelemetryClient));
telemetryClient.TrackEvent("GetMethod");
telemetryClient.TrackMetric("GetMetric", 10);
and this breaks auto-instrumentation - I no longer see requests in Fiddler.
Asp.Net v5 has updated coding style guidelines: https://github.com/aspnet/Home/wiki/Engineering-guidelines#coding-guidelines
We need to confider using those.
This causes Test - TestBasicRequestPropertiesAfterRequestingControllerThatThrows
to fail.
Update: issue summary:
Question here - what kind of heuristic can we use (or should we at all?) to report the proper response code.
PCL collects stack as exception.StackTrace string. We may want to improve this in Core.
Pushing v0.30.0.1-beta of Microsoft.ApplicationInsights.AspNet package to SymbolSource.org failed with an internal error. It is not clear whether the error is caused by the package version, which seemed to be indicated by the error message, or by the new platforms (dnx451 and dnxcore50) it contains.
I am using "Visual Studio Enterprise 2015 CTP" Version 14.0.22919.0 D14REL
My existing dependencies is as below:
"dependencies": {
"EntityFramework.SqlServer": "7.0.0-beta4",
"EntityFramework.Commands": "7.0.0-beta4",
"Microsoft.AspNet.Mvc": "6.0.0-beta4",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta4",
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-beta4",
"Microsoft.AspNet.Authentication.Facebook": "1.0.0-beta4",
"Microsoft.AspNet.Authentication.Google": "1.0.0-beta4",
"Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-beta4",
"Microsoft.AspNet.Authentication.Twitter": "1.0.0-beta4",
"Microsoft.AspNet.Diagnostics": "1.0.0-beta4",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta4",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta4",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta4",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta4",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta4",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-beta4",
"Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta4",
"Microsoft.Framework.ConfigurationModel.UserSecrets": "1.0.0-beta4",
"Microsoft.Framework.CodeGenerators.Mvc": "1.0.0-beta4",
"Microsoft.Framework.Logging": "1.0.0-beta4",
"Microsoft.Framework.Logging.Console": "1.0.0-beta4",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta4"
},
When I adding the new dependency, I cannot find AspNet after ApplicationInsights. There are only something like:
Microsoft.ApplicationInsights.Web
Microsoft.ApplicationInsights.TraceListener
Microsoft.ApplicationInsights.PerfCounterCollector
...
Is this library only available on any other NUGET source?
RequestTelemetry.Url is not initialized
This package provides request telemetry and exception telemetry. It would be good to also have a way to enable dependency telemetry via this package for projects targeting DNX, even if it's only for the full framework (dnx451
) and not CoreCLR (dnxcore50
).
We need to enable the DiagnosticsTelemetryModule
from Core or implement its equivalent in ASP.NET 5 to collect self-diagnostics telemetry.
Here is a feedback from @petehauge
Going through this page to add stuff: https://github.com/Microsoft/ApplicationInsights-aspnetv5/wiki/Getting-Started
• The first & second step were clear (add reference & config instrumentation key), but the 3rd step wasn’t completely obvious… Might be better to tell the user to add the services.AddApplicationInsightsTelemetry(Configuration); line to the “ConfigureServices” method AND tell them to add the correct using statement: using Microsoft.ApplicationInsights.AspNet; The only reason I found this was via the lightbulb suggested fixes…
• Fourth step (add middleware and configure developer mode), should tell users to add this to the “Configure” section. I figured it out because that was the only place where “app.UseApplicationInsightsRequestTelemetry” would resolve properly, needed a bit of guess and check.
• 5th step (add to _layout.cshtml), I’m assuming that this needs to be added AFTER the injection of AppSettings (since that’s where the configuration key is defined). If that’s necessary should probably indicate that…
• Last thing – I have a custom event, I assume that needs to come AFTER the HTMLHelper for injecting the AppInsights Javascript Snippet (since I assume that configures app insights in the browser). Might be good to mention that too (any additional app insights logging needs to happen after this in the ‘head’ section), only if it’s necessary…
Reported by @AlexBulankou
This is the right way to create TelemetryClient instance:
TelemetryClient telemetryClient = (TelemetryClient)this.Resolver.GetService(typeof(TelemetryClient));
This is NOT the right way
TelemetryClient telemetryClient = new TelemetryClient().
but user has no idea :)
What can we do to improve this experience (other than documentation)
Implement telemetry initializer that populates telemetry.Component.Version
to the value read from project.json.
This was blocked before by the issue in Configuration package. More details: aspnet/Configuration#115
For those using the Content-Security-Policy (CSP) HTTP header, including inline JavaScript is not allowed. Would it be possible for Microsoft to create and use a CDN which returns the client side JavaScript? The instrumentation key could be included in the query string portion of the URL. So something like this:
<script src="https://application-insights.com?key=[INSTRUMENTATION KEY]"></script>
"data": {
"baseType": "ExceptionData",
"baseData": {
"ver": 2,
"handledAt": "UserCode",
"properties": {
"DeveloperMode": "true"
},
We currently scope TelemetryClient to the entire application, which can lead to hard to diagnose problems when developers change its request-specific properties, like TelemetryClient.Context.Session.Id. I think the TelemetryClient service should be request-scoped and rely on the container to inject the application-scoped TelemetryConfiguration (see issue #10).
cc: @SergKanz , @abaranch, @upendras, @sergei-nikitin
I think we should avoid using TelemetryConfiguration.Active
and instead add the instance returned by the TelemetryConfiguration.CreateDefault
as an application-scoped service to the DI container.
cc: @SergKanz, @sergei-nikitin, @upendras, @abaranch
I've been trying to create a unit test for middleware. Following stackoverflow example I wrote this code, but it fails to construct middleware as it cannot find the TelemetryClient
. Any ideas?
sentItems.Clear();
var configuration = new TelemetryConfiguration()
{
TelemetryChannel = new FakeTelemetryChannel() { OnSend = item => this.sentItems.Add(item) },
InstrumentationKey = "testestkey"
};
var client = new TelemetryClient(configuration);
var services = new ServiceCollection();
services.AddInstance<TelemetryClient>(client);
services.AddInstance<IApplicationEnvironment>(CallContextServiceLocator.Locator.ServiceProvider.GetService<IApplicationEnvironment>());
services.AddInstance<IServiceManifest>(CallContextServiceLocator.Locator.ServiceProvider.GetService<IServiceManifest>());
var server = TestServer.Create(services.BuildServiceProvider(), (IApplicationBuilder app) =>
{
app.UseMiddleware<RequestTrackingMiddleware>();
app.Use(next =>
{
return async context =>
{
await context.Response.WriteAsync("Hello, world!");
};
});
});
using (server)
{
var response = await server.CreateClient().GetAsync("/");
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}
Page views are sent just fine when running inside IISExpress but those same page views are not sent when running inside the web emulator.
Requests and exceptions are sent correctly when running inside either IISExpress or the web emulator.
@SergKanz, @abaranch, @upendras and @sergei-nikitin,
Since I will be moving away from the ASP.NET 5 work soon, I think people who will be maintaining this code would be in the best position to choose the test isolation framework we will use. Here is what Roy Osherove, the author of the highly recommended book, The Art of Unit Testing has to say on the subject: FakeItEasy or NSubstitute, which should I use?.
Notice that he recommends against using Moq on new projects. He also has a somewhat outdated poll that, shows NSubstitute being the most popular among his blog readers. However, the Microsoft Engineering Excellency team also recommends NSubstitute over Moq on the agile alias when this question comes up.
Here are the links to these frameworks on GitHub.
Although all of them are actively maintained, none of them support dnxcore50 at this time. Contributing to Moq and FakeItEasy would be straightforward, while NSubstitute may be a bit harder due to custom tools they use.
Please comment on your preference.
Once ASP.Net Beta5 bits are available on nuget, refer from nuget instead.
With a simple app, when I try to add Application Insights, following the Getting Started instructions, I see
Unable to resolve service for type 'Microsoft.Framework.Notification.INotifier' while attempting to activate 'Microsoft.ApplicationInsights.AspNet.TelemetryInitializers.OperationNameTelemetryInitializer'
Detailed stack trace:
System.InvalidOperationException: Unable to resolve service for type 'Microsoft.Framework.Notification.INotifier' while attempting to activate 'Microsoft.ApplicationInsights.AspNet.TelemetryInitializers.OperationNameTelemetryInitializer'.
at Microsoft.Framework.DependencyInjection.ServiceLookup.Service.PopulateCallSites(ServiceProvider provider, ISet`1 callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound)
at Microsoft.Framework.DependencyInjection.ServiceLookup.Service.CreateCallSite(ServiceProvider provider, ISet`1 callSiteChain)
at Microsoft.Framework.DependencyInjection.ServiceProvider.GetResolveCallSite(IService service, ISet`1 callSiteChain)
at Microsoft.Framework.DependencyInjection.ServiceLookup.ClosedIEnumerableService.CreateCallSite(ServiceProvider provider, ISet`1 callSiteChain)
at Microsoft.Framework.DependencyInjection.ServiceProvider.GetResolveCallSite(IService service, ISet`1 callSiteChain)
at Microsoft.Framework.DependencyInjection.ServiceProvider.GetServiceCallSite(Type serviceType, ISet`1 callSiteChain)
at Microsoft.Framework.DependencyInjection.ServiceProvider.b__7_0(Type key)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at Microsoft.Framework.DependencyInjection.ServiceProvider.GetService(Type serviceType)
at Microsoft.Framework.DependencyInjection.ServiceProviderExtensions.GetService[T](IServiceProvider provider)
at Microsoft.Framework.DependencyInjection.ApplicationInsightsExtensions.AddServicesToCollection[T](IServiceProvider serviceProvider, ICollection`1 collection)
at Microsoft.Framework.DependencyInjection.ApplicationInsightsExtensions.<>c__DisplayClass8_0.b__0(IServiceProvider serviceProvider)
at Microsoft.Framework.DependencyInjection.ServiceLookup.FactoryService.Invoke(ServiceProvider provider)
at Microsoft.Framework.DependencyInjection.ServiceProvider.ScopedCallSite.Invoke(ServiceProvider provider)
at Microsoft.Framework.DependencyInjection.ServiceProvider.SingletonCallSite.Invoke(ServiceProvider provider)
at Microsoft.Framework.DependencyInjection.ServiceLookup.ConstructorCallSite.Invoke(ServiceProvider provider)
at Microsoft.Framework.DependencyInjection.ServiceProvider.ScopedCallSite.Invoke(ServiceProvider provider)
at Microsoft.Framework.DependencyInjection.ServiceProvider.<>c__DisplayClass8_0.b__0(ServiceProvider provider)
at Microsoft.Framework.DependencyInjection.ServiceProvider.GetService(Type serviceType)
at Microsoft.Framework.Internal.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)
at Microsoft.Framework.Internal.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)
at Microsoft.AspNet.Builder.UseMiddlewareExtensions.<>c__DisplayClass2_0.b__0(RequestDelegate next)
at Microsoft.AspNet.Builder.Internal.ApplicationBuilder.Build()
at Microsoft.AspNet.Hosting.Internal.HostingEngine.BuildApplication()
at Microsoft.AspNet.Hosting.Internal.HostingEngine.Start()
at Microsoft.AspNet.Loader.IIS.RuntimeHttpApplication.ApplicationStart(IHttpApplication application)
at Microsoft.AspNet.Loader.IIS.HttpApplicationBase.InvokeApplicationStart(IHttpApplication application)
Any ideas on what to check?
Asp.Net team proposed to move setting developer mode to ConfigureServices (call to AddApplicationInsights). Let's discuss how code will look like if we will move it there
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.