ApplicationInsights-Java icon indicating copy to clipboard operation
ApplicationInsights-Java copied to clipboard

Issue when Connection string configured at runtime

Open RenancoGitHub opened this issue 1 year ago • 7 comments

Hey guys, i have an application in java 11, application insights jar 3.4.8 and pom core-version 3.4.10 and trying this configuration:

image

The idea is to turn on/off the application insights logging in runtime. When i tested it and set the key false means that i will set an empty key ConnectionString.configure(""); and logs will not sent to application insights. That worked fine. When i change de key set to true with my real connection string, now my requests will send to application insights. That worked aswell.

image

Ok. But now when i back the configuration false and reconfigure de connection String to an empty string, the logs keep sending to application insights and i get the warning that connection is already set:

image

Everytime i do a request i create a new telemetry client like this and tried to flush but still cant override the previous connection string configuration:

image

Looks like i can only change de connection if i rebuild the application every request to changes take effect. Is there another way to implement this idea? Turn on/off the aplication insights injestion while in runtime application?

RenancoGitHub avatar Mar 08 '23 17:03 RenancoGitHub