使用 Azure Monitor Application Insights 监视 Azure FunctionsMonitoring Azure Functions with Azure Monitor Application Insights

Azure Functions 内置集成了 Azure Application Insights 来监视函数。Azure Functions offers built-in integration with Azure Application Insights to monitor functions.

Application Insights 收集日志、性能和错误数据,并自动检测性能异常。Application Insights collects log, performance, and error data, and automatically detects performance anomalies. Application Insights 包含功能强大的分析工具,可帮助你诊断问题并了解函数的使用方式。Application Insights includes powerful analytics tools to help you diagnose issues and to understand how your functions are used. 当你能够洞察应用程序数据后,你可以持续改善性能和可用性。When you have the visibility into your application data, you can continuously improve performance and usability. 你甚至可以在本地函数应用项目开发过程中使用 Application Insights。You can even use Application Insights during local function app project development.

Azure Functions 中内置了必需的 Application Insights 检测。The required Application Insights instrumentation is built into Azure Functions. 你只需提供有效的检测密钥便可将函数应用连接到 Application Insights 资源。The only thing you need is a valid instrumentation key to connect your function app to an Application Insights resource. 在 Azure 中创建函数应用资源时,应将检测密钥添加到应用程序设置中。The instrumentation key should be added to your application settings when your function app resource is created in Azure. 如果函数应用还没有此密钥,你可以手动设置此密钥。If your function app doesn't already have this key, you can set it manually. 有关详细信息,请参阅监视 Azure FunctionsFor more information read more about monitoring Azure Functions.

针对 Windows 上的 Java 应用程序的分布式跟踪(公共预览版)Distributed tracing for Java applications on Windows (public preview)

重要

当前在 Windows 上的 Java Azure Functions 的公共预览版中提供此功能,不支持针对 Linux 上的 Java Azure Functions 的分布式跟踪。This feature is currently in public preview for Java Azure Functions on Windows, distributed tracing for Java Azure Functions on Linux is not supported. 对于消耗计划,此功能会进行 8-9 秒的冷启动。For Consumption plan it has a cold start of 8-9 seconds.

如果你的应用程序是以 Java 编写的,则你可以通过函数应用程序查看更丰富的数据,包括请求、依赖项、日志和指标。If your applications are written in Java you can view richer data from your functions applications, including, requests, dependencies, logs, and metrics. 借助更多数据,你还可以查看并诊断端到端事务,以及查看应用程序映射,该映射聚合了许多事务来显示一个拓扑视图,可以在其中了解各个系统如何交互,以及平均性能和错误率。The additional data also lets you see and diagnose end-to-end transactions and see the application map, which aggregates many transactions to show a topological view of how the systems interact, and what the average performance and error rates are.

端到端诊断和应用程序映射可以洞察每个事务/请求。The end-to-end diagnostics and the application map provide visibility into one single transaction/request. 将这两个功能结合使用,对于找出每个请求出现可靠性问题和性能瓶颈的根本原因非常有帮助。Together these two features are very helpful for finding the root cause of reliability issues and performance bottlenecks on a per request basis.

如何为 Java 函数应用启用分布式跟踪?How to enable distributed tracing for Java Function apps?

导航到函数应用的“概述”边栏选项卡并转到“配置”。Navigate to the functions app Overview blade, go to configurations. 在“应用程序设置”下,单击“+ 新建应用程序设置”。Under Application Settings, click "+ New application setting". 添加使用以下值的下面两个应用程序设置,然后单击左上方的“保存”。Add the following two application settings with below values, then click Save on the upper left. 大功告成!DONE!

XDT_MicrosoftApplicationInsights_Java -> 1
ApplicationInsightsAgent_EXTENSION_VERSION -> ~2

后续步骤Next Steps