1
0
Форкнуть 0

change interfaces - snippet accept instrumentaiton key and parameters now

This commit is contained in:
Sergey Kanzhelev 2015-03-17 22:27:45 -07:00
Родитель ee0da53636
Коммит 49a5c752f9
3 изменённых файлов: 9 добавлений и 6 удалений

Просмотреть файл

@ -11,7 +11,7 @@
return app; return app;
} }
public static IApplicationBuilder UseApplicationInsightsTelemetry(this IApplicationBuilder app) public static IApplicationBuilder UseApplicationInsightsExceptionTelemetry(this IApplicationBuilder app)
{ {
app.UseMiddleware<ApplicationInsightsMiddleware>(); app.UseMiddleware<ApplicationInsightsMiddleware>();
return app; return app;

Просмотреть файл

@ -8,7 +8,7 @@
public static class ApplicationInsightsExtensions public static class ApplicationInsightsExtensions
{ {
public static void AddTelemetry(this IServiceCollection services, IConfiguration config) public static void AddApplicationInsightsTelemetry(this IServiceCollection services, IConfiguration config)
{ {
TelemetryConfiguration.Active.InstrumentationKey = config.Get("ApplicationInsights:InstrumentationKey"); TelemetryConfiguration.Active.InstrumentationKey = config.Get("ApplicationInsights:InstrumentationKey");

Просмотреть файл

@ -1,15 +1,18 @@
namespace Microsoft.AspNet.Mvc.Rendering //namespace Microsoft.AspNet.Mvc.Rendering
namespace Microsoft.ApplicationInsights.AspNet
{ {
using Microsoft.ApplicationInsights; using Microsoft.ApplicationInsights;
using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Mvc.Rendering;
using System.Collections.Generic;
public static class ApplicationInsightsJavaScriptSnippetExtensions public static class ApplicationInsightsJavaScriptSnippetExtensions
{ {
public static HtmlString ApplicationInsightsJavaScriptSnippet(this IHtmlHelper helper) public static HtmlString ApplicationInsightsJavaScriptSnippet(this IHtmlHelper helper, string instrumentationKey, Dictionary<string, string> parameters = null)
{ {
//see: https://github.com/aspnet/Mvc/issues/2056 //see: https://github.com/aspnet/Mvc/issues/2056
var client = (TelemetryClient)helper.ViewContext.HttpContext.ApplicationServices.GetService(typeof(TelemetryClient)); //var client = (TelemetryClient)helper.ViewContext.HttpContext.ApplicationServices.GetService(typeof(TelemetryClient));
return new HtmlString("<script language='javascript'>alert('Key: ' + '" + client.Context.InstrumentationKey + "');</script>"); return new HtmlString("<script language='javascript'>alert('Key: ' + '" + instrumentationKey + "');</script>");
} }
} }
} }