您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

用于 Java 的 Azure Application Insights 库Azure Application Insights libraries for Java

概述Overview

使用 Application Insights 检测、会审和诊断 Web 应用与服务中的问题。Detect, triage, and diagnose issues in your web apps and services with Application Insights.

若要开始使用 Application Insights,请参阅 Java Web 项目中的 Application Insights 入门To get started with Application Insights, see Get started with Application Insights in a Java web project.

客户端库Client library

使用 Application Insights 客户端库添加遥测,以跟踪应用中的事件、异常和用户指标。Add telemetry to track events, exceptions, and user metrics in your apps with the Application Insights client library.

向 Maven pom.xml 文件中添加依赖项,以便在项目中使用客户端库。Add a dependency to your Maven pom.xml file to use the client library in your project.

<dependency>
    <groupId>com.microsoft.azure</groupId>
    <artifactId>applicationinsights-web</artifactId>   
    <version>1.0.8</version>
</dependency>

示例Example

创建新的指标条目并记录其值。Create a new metric entry and record a value for it.

    MetricTelemetry sample = new MetricTelemetry();
    sample.setName("metric name");
    sample.setValue(42.3);
    telemetryClient.TrackMetric(sample);

示例Samples

详细了解可在应用中使用的 Application Insights 示例 Java 代码Explore more sample Java code for Application Insights you can use in your apps.