Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Allow connectionString to be overridden multiple times without restarting the AppInsights Agent

Open
#3,473 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
java, spring-boot
Domain
observability

Research direction

Start with BytecodeUtilImpl.java around lines 70-73 to understand why ConnectionString.configure() is currently one-time, then inspect InheritedConnectionStringSpanProcessor.java around lines 58-62 and the linked connection-string override documentation. Trace how connection strings are associated with spans and telemetry destinations. Done would require a supported design for changing destinations across the application lifecycle or for distinct custom spans.

Written by the indexing model from the issue text.

Description

Needs: Attention :wave:

Is your feature request related to a problem? Please describe.
As per your documentation, it's possible to override connection strings per each httpPathPrefix:
https://learn.microsoft.com/en-us/azure/azure-monitor/app/java-standalone-config#connection-string-overrides-preview

{
  "preview": {
    "connectionStringOverrides": [
      {
        "httpPathPrefix": "/myapp1",
        "connectionString": "..."
      },
      {
        "httpPathPrefix": "/myapp2",
        "connectionString": "..."
      }
    ]
  }
}

This config is being processed in the following class of AppInsights Agent: InheritedConnectionStringSpanProcessor.java:L58-L62

I understand that this feature is geared towards a use-case where an app being instrumented with AppInsights is an MVC app, and a connectionStringOverride is applied at a Controller method level, where each Controller method has a different PathPrefix. I.e. this use-case is described in OpenTelemetryAPI documentation as creating a custom span per controller method:
https://opentelemetry.io/docs/instrumentation/java/manual/#create-spans

Describe the solution you would like
We are looking for a way to change connectionString multiple times throughout application lifecycle, not per httpPathPrefix

Ideally we would be able to run ConnectionString.configure() and change to a desired connectionString, and ApplicationInsight agent taking that into account, and posting metrics to a newly specified location.

com.microsoft.applicationinsights.connectionstring.ConnectionString.configure(CONNECTION_STRING)

Currently ConnectionString.configure(CONNECTION_STRING) can be run only once to set ConnectionString:
https://github.com/microsoft/ApplicationInsights-Java/blob/main/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/classicsdk/BytecodeUtilImpl.java#L70-L73

We need a way to determine custom OpenTelemetry spans, and have a different ConnectionString per each of these spans.

Describe alternatives you have considered
Describe any alternative solutions or features you've considered.

Additional context
Our app is not Spring MVC app that has different httpPathPrefix, but is rather a SpringBoot cron-executed org.springframework.boot.CommandLineRunner task, that runs periodically, and needs to send AppInsights telemetry to 3 different AppInsights containers.

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.