1
0
Форкнуть 0
ASP.NET Core web applications monitoring
Перейти к файлу
Sergey Kanzhelev 57853eb3ab Do not inject JavaScript is instrumentation key is empty 2015-03-30 13:53:35 -07:00
src/ApplicationInsights.AspNet Do not inject JavaScript is instrumentation key is empty 2015-03-30 13:53:35 -07:00
test test that empty instrumentation key will not break customer applicaiton 2015-03-30 11:48:40 -07:00
.gitignore initial version of .gitignore 2015-03-17 19:57:17 -07:00
ApplicationInsights.AspNet.sln Add unit tests for WebUserAgentTelemetryInitializer 2015-03-28 07:29:29 +00:00
LICENSE Initial commit 2015-03-17 12:39:40 -07:00
Readme.md Update Readme.md 2015-03-25 16:39:07 -07:00
global.json move solution to the root level 2015-03-23 21:58:57 -07:00

Readme.md

Microsoft Application Insights for Asp.Net vNext applications

This repository has a code for Application Insights monitoring of Asp.Net vNext applications. Read about contrubution policies on Application Insights Home repository

Getting Started

Add NuGet feed http://appinsights-aspnet.azurewebsites.net/nuget/. It has NuGet: Microsoft.ApplicationInsights.AspNet.

For standard Asp.Net template you need to modify four files (this will be the default template instrumentation in future).

project.json Add new reference:

"Microsoft.ApplicationInsights.AspNet": "1.0.0.0-alpha"

config.json Configure instrumentation key:

 "ApplicationInsights": {
 	"InstrumentationKey": "11111111-2222-3333-4444-555555555555"
 }

Startup.cs Add service:

services.AddApplicationInsightsTelemetry(Configuration);

Add middleware and configure developer mode:

// Add Application Insights monitoring to the request pipeline as a very first middleware.
app.UseApplicationInsightsRequestTelemetry();
...
// Add the following to the request pipeline only in development environment.
if (string.Equals(env.EnvironmentName, "Development", StringComparison.OrdinalIgnoreCase))
{
	app.SetApplicationInsightsTelemetryDeveloperMode();
}
...
// Add Application Insights exceptions handling to the request pipeline.
app.UseApplicationInsightsExceptionTelemetry();

_Layout.cshtml Define using and injection:

@using Microsoft.ApplicationInsights.AspNet
@inject Microsoft.ApplicationInsights.DataContracts.RequestTelemetry RequestTelelemtry

And insert HtmlHelper to the end of <head> section:

	@Html.ApplicationInsightsJavaScriptSnippet(RequestTelelemtry.Context.InstrumentationKey);
</head>

Developing

  1. Repository (private now): https://github.com/microsoft/AppInsights-aspnetv5
  2. Asp.Net information: https://github.com/aspnet/home
  3. VS 2015 installation:
  1. Make sure you have these (only these and in this order) feeds configured in Visual Studio. You may need to restart Visual Studio to allow packages to be restored correctly: