-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow connectionString to be overridden multiple times without restarting the AppInsights Agent #3473
Comments
@slavik112211 You can download here a SNAPSHOT version with the connection string check removed. Could you please try it? |
Fantastic, thanks @jeanbisutti. Will provide feedback early next week. |
confirming that the provided applicationinsights-agent-3.5-SNAPSHOT.jar correctly sets the connectionString multiple times throught the lifecycle of the application using: Please proceed with merging your change into Production version. Please note, our app is not using the agent jar directly (i.e. applicationinsights-agent-3.5-SNAPSHOT.jar), but rather uses |
@slavik112211 Thanks for testing. The fix will work both with |
@jeanbisutti With a similar need, with the 2.x SDK, we were able to create different TelemetryClient instances that sent data to different application insight resources by setting the respective instrumentation key.
However, when moving to the 3.x SDK, it does not appear that we have same capability. I was hoping that something like this would have worked...
...but unfortunately all of the telemetry is being sent to the application insight resource that was set with this line of code...
Is there a way to accomplish what we're attempting to do with having multiple TelemetryClients with different connection strings in the same application? Thank you for your time |
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
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.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 thesespans
.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-executedorg.springframework.boot.CommandLineRunner
task, that runs periodically, and needs to send AppInsights telemetry to 3 different AppInsights containers.The text was updated successfully, but these errors were encountered: