Application Insights Java Agent: ConnectionStringOverrides Feature Fails to Route Telemetry as Expected
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- azure, java
- Domain
- observability
Research direction
Start by reproducing the five configurations with the Java agent on Tomcat 10.1.33, using the two context paths /OsaEcommerceServerBE and /OsaEcommerceServerNL. Trace how preview.connectionStringOverrides and the top-level connectionString are interpreted. Done means each path routes telemetry to its configured resource and the agent behaves as documented when the top-level connection string is absent.
Written by the indexing model from the issue text.
Description
Expected behavior
I expected requests to be tracked in the respective Application Insights resources based on the httpPathPrefix defined in the configuration. Specifically:
- Requests to
/OsaEcommerceServerBE/should be tracked inTHE_ONE_BE. - Requests to
/OsaEcommerceServerNL/should be tracked inTHE_ONE_NL.
Actual behavior
The behavior observed differs depending on the configuration JSON:
Case 1
Configuration:
{
"role": {
"name": "testrolename",
"instance": "testroleinstance"
},
"sampling": {
"percentage": 100
},
"preview": {
"connectionStringOverrides": [
{
"httpPathPrefix": "/OsaEcommerceServerBE",
"connectionString": "THE_ONE_BE"
},
{
"httpPathPrefix": "/OsaEcommerceServerNL",
"connectionString": "THE_ONE_NL"
}
]
},
"connectionString": "THE_ONE_BE"
}
Observed Behavior:
/OsaEcommerceServerBE/is tracked inTHE_ONE_BE./OsaEcommerceServerNL/is not tracked anywhere.
Case 2
Configuration:
{
"role": {
"name": "testrolename",
"instance": "testroleinstance"
},
"sampling": {
"percentage": 100
},
"preview": {
"connectionStringOverrides": [
{
"httpPathPrefix": "/OsaEcommerceServerNL",
"connectionString": "THE_ONE_BE"
},
{
"httpPathPrefix": "/OsaEcommerceServerNL",
"connectionString": "THE_ONE_NL"
}
]
},
"connectionString": "THE_ONE_BE"
}
Observed Behavior:
- Both
/OsaEcommerceServerBE/and/OsaEcommerceServerNL/are tracked inTHE_ONE_BE.
Case 3
Configuration:
{
"role": {
"name": "testrolename",
"instance": "testroleinstance"
},
"sampling": {
"percentage": 100
},
"preview": {
"connectionStringOverrides": [
{
"httpPathPrefix": "/OsaEcommerceServerBE",
"connectionString": "THE_ONE_BE"
},
{
"httpPathPrefix": "/OsaEcommerceServerBE",
"connectionString": "THE_ONE_NL"
}
]
},
"connectionString": "THE_ONE_BE"
}
Observed Behavior:
/OsaEcommerceServerBE/is tracked inTHE_ONE_BE./OsaEcommerceServerNL/is also tracked inTHE_ONE_BE.
Case 4
Configuration:
{
"role": {
"name": "testrolename",
"instance": "testroleinstance"
},
"sampling": {
"percentage": 100
},
"preview": {
"connectionStringOverrides": [
{
"httpPathPrefix": "/OsaEcommerceServerNL",
"connectionString": "THE_ONE_BE"
},
{
"httpPathPrefix": "/OsaEcommerceServerBE",
"connectionString": "THE_ONE_NL"
}
]
},
"connectionString": "THE_ONE_BE"
}
Observed Behavior:
/OsaEcommerceServerBE/is not tracked anywhere./OsaEcommerceServerNL/is tracked inTHE_ONE_BE.
Case 5
Configuration:
{
"role": {
"name": "testrolename",
"instance": "testroleinstance"
},
"sampling": {
"percentage": 100
},
"preview": {
"connectionStringOverrides": [
{
"httpPathPrefix": "/OsaEcommerceServerNL",
"connectionString": "THE_ONE_BE"
},
{
"httpPathPrefix": "/OsaEcommerceServerBE",
"connectionString": "THE_ONE_NL"
}
]
}
}
Observed Behavior:
- No requests are tracked at all.
Logs
When the connectionString field is not specified in the configuration, the Application Insights Java agent failed to start, citing that no connection string was provided. This indicates that the connectionStringOverrides feature does not work as expected without a main connectionString specified.
To Reproduce
- Set up a Tomcat server with two applications running on distinct context paths (
/OsaEcommerceServerBEand/OsaEcommerceServerNL). - Configure the Application Insights agent using the provided JSON configurations for each case.
- Make requests to
http://localhost:8081/OsaEcommerceServerBE/andhttp://localhost:8081/OsaEcommerceServerNL/. - Observe the Application Insights telemetry data.
System information
- SDK Version: 21
- OS type and version: Windows 10
- Application Server type and version: Apache Tomcat 10.1.33
- Using spring-boot? Yes, version 3.1.5
- Additional relevant libraries: None applicable
- Dominant language
- Java
- Stars
- 327
- Forks
- 222
- Avg merge
- 22h 34m
- Merged PRs (30d)
- 14
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/ApplicationInsights-Java
-
microsoft/ApplicationInsights-Java#4851 · 1 assignee ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
microsoft/ApplicationInsights-Java#4817 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
microsoft/ApplicationInsights-Java#4770 · 2 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
microsoft/ApplicationInsights-Java#4769 · 2 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
microsoft/ApplicationInsights-Java#4729 · 120 comments ·
All issues in microsoft/ApplicationInsights-Java
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
Two open-case totals on one screen: the Programs tile says 15,858 and the nav badge says 15,868 Openbug frontend maui-pilot
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
objectionary/eo-graphs#74 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100