insights 没有权限
Today on the ASP.NET Community Standup we learned about how you can use Application Insights in a disconnected scenario to get some cool - ahem - insights into your application.
今天,在ASP.NET Community Standup上,我们了解了如何在不连接的情况下使用Application Insights ,以获取有关应用程序的一些很棒的见解。
Typically when someone sees Application Insights in the File | New Project dialog they assume it's a feature that only works in Azure, that will create some account for you and send your data to the cloud. While App Insights totally does do a lot of cool stuff when you have a cloud-hosted app and it does add a lot of value, it also supports a very useful "SDK only" mode that's totally offline.
通常,当有人在文件|文件中看到Application Insights。 他们认为“新建项目”对话框是仅在Azure中可用的功能,它将为您创建一些帐户并将您的数据发送到云。 当您拥有云托管应用程序时,虽然App Insights确实可以做很多很酷的事情,并且确实增加了很多价值,但它还支持非常有用的“仅SDK”模式,该模式完全脱机。
Click "Add Application Insights to project" and then under "Send telemetry to" you click "Install SDK only" and no data gets sent to the cloud.
单击“将Application Insights添加到项目”,然后在“将遥测发送到”下单击“仅安装SDK”,并且不会将任何数据发送到云。
Once you make your new project, can you learn more about AppInsights here.
创建新项目后,您可以在此处了解有关AppInsights的更多信息。
For ASP.NET Core apps, Application Insights will include this package in your project.json - "Microsoft.ApplicationInsights.AspNetCore": "1.0.0" and it'll add itself into your middleware pipeline and register services in your Startup.cs. Remember, nothing is hidden in ASP.NET Core, so you can modify all this to your heart's content.
对于ASP.NET Core应用程序,Application Insights将在您的project.json-“ Microsoft.ApplicationInsights.AspNetCore”:“ 1.0.0”中包含此程序包,并将其添加到中间件管道中并在Startup.cs中注册服务。 记住,ASP.NET Core中没有任何隐藏的内容,因此您可以根据自己的喜好修改所有内容。
if (env.IsDevelopment())
{
// This will push telemetry data through Application Insights pipeline faster, allowing you to view results immediately.
builder.AddApplicationInsightsSettings(developerMode: true);
}
Request telemetry and Exception telemetry are added separately, as you like.
您可以根据需要分别添加请求遥测和异常遥测。
Make sure you show the Application Insights Toolbar by right-clicking your toolbars and ensuring it's checked.
右键单击工具栏并确保已选中它,以确保显示Application Insights工具栏。
The button it adds is actually pretty useful.
它添加的按钮实际上非常有用。
Run your app and click the Application Insights button.
运行您的应用程序,然后单击“ Application Insights”按钮。
NOTE: I'm using Visual Studio Community. That's the free version of VS you can get at http://visualstudio.com/free. I use it exclusively and I think it's pretty cool that this feature works just great on VS Community.
注意:我正在使用Visual Studio社区。 那是VS的免费版本,您可以从http://visualstudio.com/free获得。 我专门使用它,并且认为此功能在VS社区上很好用非常酷。
You'll see the Search window open up in VS. You can keep it running while you debug and it'll fill with Requests, Traces, Exceptions, etc.
您将看到“搜索”窗口在VS中打开。 您可以在调试时使其保持运行状态,并填充请求,跟踪,异常等。
I added a Exceptional case to /about, and here's what I see:
我在/ about中添加了一个例外情况,这是我看到的内容:
I can dig into each issue, filter, search, and explore deeper:
我可以深入研究每个问题,进行过滤,搜索和深入研究:
And once I've found something interesting, I can explore around it with the full details of the HTTP Request. I find the "telemetry 5 minutes before and after" query to be very powerful.
找到有趣的内容后,就可以使用HTTP请求的全部详细信息进行探索。 我发现“前后5分钟的遥测”查询功能非常强大。
Notice where it says "dependencies for this operation?" That's not dependencies like "Dependency Injection" - that's larger system-wide dependencies like "my app depends on this web service."
请注意在其上面写着“此操作的依赖性?”。 那不是像“依赖注入”这样的依赖,而是像“我的应用程序依赖于此Web服务”之类的更大的系统范围的依赖。
You can custom instrument your application with the TrackDependancy API if you like, and that will cause your system's dependency to light up in AppInsights charts and reports. Here's a dumb example as I pretend that putting data in ViewData is a dependency. It should be calling a WebAPI or a Database or something.
您可以根据需要使用TrackDependancy API自定义对应用程序的检测,这将导致系统的依存关系在AppInsights图表和报告中显示出来。 这是一个愚蠢的示例,因为我假装将数据放入ViewData是一个依赖项。 它应该调用WebAPI或数据库之类的东西。
var telemetry = new TelemetryClient();
var success = false;
var startTime = DateTime.UtcNow;
var timer = System.Diagnostics.Stopwatch.StartNew();
try
{
ViewData["Message"] = "Your application description page.";
}
finally
{
timer.Stop();
telemetry.TrackDependency("ViewDataAsDependancy", "CallSomeStuff", startTime, timer.Elapsed, success);
}
Once I'm Tracking external Dependencies I can search for outliers, long durations, categorize them, and they'll affect the generated charts and graphs if/when you do connect your App Insights to the cloud. Here's what I see, after making this one code change. I could build this kind of stuff into all my external calls AND instrument the JavaScript as well. (note Client and Server in this chart.)
跟踪外部依赖关系后,我可以搜索异常值,长时间,对其进行分类,如果将App Insights连接到云时,它们将影响生成的图表。 更改此代码后,这就是我看到的内容。 我可以在所有外部调用中加入这种内容,并同时对JavaScript进行检测。 (请注意此图表中的客户端和服务器。)
And once it's all there, I can query all the insights like this:
一切准备就绪后,我可以查询所有洞察力,如下所示:
To be clear, though, you don't have to host your app in the cloud. You can just send the telemetry to the cloud for analysis. Your existing on-premises IIS servers can run a "Status Monitor" app for instrumentation.
不过要明确一点,您不必将应用程序托管在云中。 您可以将遥测发送到云中进行分析。 您现有的本地IIS服务器可以运行“状态监视器”应用进行检测。
There's a TON of good data here and it's REALLY easy to get started either:
这里有大量的好数据,而且很容易上手:
All in all, I am pretty impressed. There's SDKs for Java, Node, Docker, and ASP.NET - There's a LOT here. I'm going to dig deeper.
总而言之,我印象深刻。 有用于Java,Node,Docker和ASP.NET的SDK-这里有很多。 我要深入研究。
翻译自: https://www.hanselman.com/blog/exploring-application-insights-for-disconnected-or-connected-deep-telemetry-in-aspnet-apps
insights 没有权限