ApplicationInsights-Java
ApplicationInsights-Java copied to clipboard
APPLICATIONINSIGHTS_CONNECTION_STRING does not work in 3.5.x, works in 3.4.x
Expected behavior
APPLICATIONINSIGHTS_CONNECTION_STRING works in 3.5.x
Actual behavior
APPLICATIONINSIGHTS_CONNECTION_STRING does not work in 3.5.x (tried 3.5.0, 3.5.1, 3.5.2)
To Reproduce
- add dependency com.microsoft.azure:applicationinsights-runtime-attach:3.4.19
- add applicationinsights.json in src/resources, see bellow
- provide connection string via APPLICATIONINSIGHTS_CONNECTION_STRING environment variable
- attach to agent via ApplicationInsights.attach();
- start app
- agent connects to appinsights, traces are sent to apinsights; we had this setup for more than 1 year
- upgrade to com.microsoft.azure:applicationinsights-runtime-attach:3.5.2
- start app (no other changes, no changes to applicationinsights.json)
- agent does not connect, see error bellow in app console
*************************
Application Insights Java Agent 3.5.2 startup failed (PID 46492)
*************************
Description:
Error loading connection string from a file ("unknown-from-application-insights-json").
Please use this format instead:
{ "connectionString": "${file:connection-string-file.txt}" }
Action:
Learn more about configuration options here: https://go.microsoft.com/fwlink/?linkid=2153358
System information
Please provide the following information:
- SDK Version: 3.5.x
- OS type and version: Mac M2
- Application Server type and version (if applicable):
- Using spring-boot? yes
- Additional relevant libraries (with version, if applicable):
Logs
2023-05-30 17:02:01.940+03:00 ERROR c.m.applicationinsights.agent - Application Insights Java Agent 3.4.13 startup failed (PID 20200)
java.lang.IllegalArgumentException: Missing 'InstrumentationKey'
at com.azure.monitor.opentelemetry.exporter.implementation.configuration.ConnectionStringBuilder.mapToConnectionConfiguration(ConnectionStringBuilder.java:85)
at com.azure.monitor.opentelemetry.exporter.implementation.configuration.ConnectionStringBuilder.setConnectionString(ConnectionStringBuilder.java:39)
at com.azure.monitor.opentelemetry.exporter.implementation.configuration.ConnectionString.lambda$parse$0(ConnectionString.java:37)
at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)
{
"connectionString": "unknown-from-application-insights-json",
"role": {
"name": "app-role"
},
"sampling": {
"percentage": 100
},
"instrumentation": {
"logging": {
"level": "INFO"
}
},
"preview": {
"processors": [
{
"type": "attribute",
"actions": [
{
"key": "http.url",
"pattern": "^(.*)(?<pii>[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4})(.*)",
"action": "extract"
}
]
},
{
"type": "attribute",
"include": {
"matchType": "strict",
"attributes": [
{
"key": "pii"
}
]
},
"actions": [
{
"key": "http.url",
"action": "hash"
},
{
"key": "pii",
"action": "delete"
}
]
}
],
"sampling": {
"overrides": [
{
"telemetryType": "request",
"attributes": [
{
"key": "http.url",
"value": ".*/actuator/health.*",
"matchType": "regexp"
}
],
"percentage": 0
},
{
"telemetryType": "request",
"attributes": [
{
"key": "http.url",
"value": ".*/actuator/dbcheck.*",
"matchType": "regexp"
}
],
"percentage": 0
},
{
"telemetryType": "dependency",
"attributes": [
{
"key": "db.system",
"value": "mssql",
"matchType": "strict"
}
],
"percentage": 50
}
]
}
}
}