change interfaces - snippet accept instrumentaiton key and parameters now
This commit is contained in:
Родитель
ee0da53636
Коммит
49a5c752f9
|
@ -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>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Загрузка…
Ссылка в новой задаче