You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

升级Application Insights至3.4.9后遇权限及类找不到问题求助

Application Insights 3.x版本升级报错解决步骤

错误原因说明

3.x版本对SDK架构进行了大幅重构,与2.x版本API不兼容:

  • com.microsoft.applicationinsights.TelemetryConfiguration访问权限改为包内私有,无法从外部包直接调用;
  • WebRequestTrackingFilter被移除,其请求跟踪功能由SDK自动完成配置。

一、替换Maven依赖

移除原有的com.microsoft.azure:applicationinsights-web依赖,改用适配Spring Boot的Starter依赖,版本指定为3.4.9:

<dependency>
    <groupId>com.microsoft.azure</groupId>
    <artifactId>applicationinsights-spring-boot-starter</artifactId>
    <version>3.4.9</version>
</dependency>

二、删除手动配置代码

3.x版本的Starter会自动完成请求跟踪、遥测配置等核心功能的初始化,无需手动编写AppInsightsConfig类,直接删除该类即可。

三、配置遥测密钥/连接字符串

通过配置文件或环境变量设置应用洞察的身份信息,无需编写代码读取环境变量:

配置文件方式(application.properties)

# 使用Instrumentation Key(兼容原2.x配置)
azure.application-insights.instrumentation-key=${APPLICATION_INSIGHTS_IKEY}

# 推荐使用Connection String(3.x版本标准方式)
# azure.application-insights.connection-string=${APPLICATION_INSIGHTS_CONNECTION_STRING}

环境变量方式

直接设置环境变量APPLICATION_INSIGHTS_IKEY或APPLICATION_INSIGHTS_CONNECTION_STRING,SDK会自动读取该值完成配置。

四、验证功能

启动Spring Boot应用,发起接口请求后,可登录Azure门户的Application Insights控制台,查看请求跟踪、遥测数据,确认功能正常。


内容的提问来源于stack exchange,提问作者Adrian Kato

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.14 18:28:32