我们一直致力于使用 Java 应用程序的以下文档对应用程序洞察力进行依赖跟踪:
https://docs.microsoft.com/en-us/azure/azure-monitor/app/java-get-started?tabs=maven
https://docs.microsoft.com/en-us/azure/azure-monitor/app/java-agent
我们使用的当前版本是:
- POM.xml 文件中的 Application Insights Agent 和 applicationinsights-web-auto - 2.6.1
- MySQL 连接器 - 5.1.31
以下文件 - AI-Agents.xml、ApplicationInsights.xml 和 applicationinsights-agent-2.6.1.jar - 已添加到
/home/site/wwwroot/
以下所有尝试都是在 Window 和 Linux App Service 上进行的。
在本地,在 IDE (IntelliJ) 中,当我们将所有这些文件添加到资源文件夹并使用在 VM 选项中配置的上述文件运行应用程序时,可以毫无问题地跟踪依赖关系。但是,在应用服务上复制相同的配置会显示以下异常。
任何人都可以就是否缺少任何配置或是否需要进一步配置才能使自动依赖跟踪正常工作提出建议?
谢谢
2020-08-18T11:18:54.583510165Z: [ERROR] org.apache.catalina.LifecycleException: Failed to start component [/ApplicationInsights]
2020-08-18T11:18:54.583515565Z: [ERROR] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
2020-08-18T11:18:54.583519665Z: [ERROR] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754)
2020-08-18T11:18:54.583523465Z: [ERROR] at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730)
2020-08-18T11:18:54.583555865Z: [ERROR] at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:744)
2020-08-18T11:18:54.583569265Z: [ERROR] at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:624)
2020-08-18T11:18:54.583573565Z: [ERROR] at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1833)
2020-08-18T11:18:54.583577365Z: [ERROR] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
2020-08-18T11:18:54.583581365Z: [ERROR] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
2020-08-18T11:18:54.583585065Z: [ERROR] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
2020-08-18T11:18:54.583588965Z: [ERROR] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
2020-08-18T11:18:54.583592665Z: [ERROR] at java.lang.Thread.run(Thread.java:748)
Application Insights 文件中的内容:
<?xml version="1.0" encoding="utf-8"?>
<ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings" schemaVersion="2014-05-30">
<!-- The key from the portal: -->
<InstrumentationKey>** Your instrumentation key **</InstrumentationKey>
<!-- HTTP request component (not required for bare API) -->
<TelemetryModules>
<Add type="com.microsoft.applicationinsights.web.extensibility.modules.WebRequestTrackingTelemetryModule"/>
<Add type="com.microsoft.applicationinsights.web.extensibility.modules.WebSessionTrackingTelemetryModule"/>
<Add type="com.microsoft.applicationinsights.web.extensibility.modules.WebUserTrackingTelemetryModule"/>
</TelemetryModules>
<!-- Events correlation (not required for bare API) -->
<!-- These initializers add context data to each event -->
<TelemetryInitializers>
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebOperationIdTelemetryInitializer"/>
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebOperationNameTelemetryInitializer"/>
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebSessionTelemetryInitializer"/>
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebUserTelemetryInitializer"/>
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebUserAgentTelemetryInitializer"/>
</TelemetryInitializers>
</ApplicationInsights>
AI-Agents 文件中的内容:
<ApplicationInsightsAgent>
<Instrumentation>
<BuiltIn enabled="true">
<!-- capture logging via Log4j 1.2, Log4j2, and Logback, default is true -->
<Logging enabled="true" />
<!-- capture outgoing HTTP calls performed through Apache HttpClient, OkHttp,
and java.net.HttpURLConnection, default is true -->
<HTTP enabled="true" W3C="true" enableW3CBackCompat="true"/>
<!-- capture JDBC queries, default is true -->
<JDBC enabled="true" />
<!-- capture Redis calls, default is true -->
<Jedis enabled="true" />
<!-- capture query plans for JDBC queries that exceed this value (MySQL, PostgreSQL),
default is 10000 milliseconds -->
<MaxStatementQueryLimitInMS>1000</MaxStatementQueryLimitInMS>
</BuiltIn>
</Instrumentation>
</ApplicationInsightsAgent>