Application Insights Java Agent: ConnectionStringOverrides Feature Fails to Route Telemetry as Expected

Open
#4,049 8 comments 0 reactions 0 assignees View on GitHub

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 in THE_ONE_BE.
  • Requests to /OsaEcommerceServerNL/ should be tracked in THE_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 in THE_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 in THE_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 in THE_ONE_BE.
  • /OsaEcommerceServerNL/ is also tracked in THE_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 in THE_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

  1. Set up a Tomcat server with two applications running on distinct context paths (/OsaEcommerceServerBE and /OsaEcommerceServerNL).
  2. Configure the Application Insights agent using the provided JSON configurations for each case.
  3. Make requests to http://localhost:8081/OsaEcommerceServerBE/ and http://localhost:8081/OsaEcommerceServerNL/.
  4. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/ApplicationInsights-Java

All issues in microsoft/ApplicationInsights-Java

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.