When custom client is configured with own instrumentation key it is ignored and handled by Agent client:
@Value("${appinsights.analytics.instrumentationkey}")
private String instrumentationKey;
@PostConstruct
public void init() {
TelemetryConfiguration telemetryConfiguration = TelemetryConfiguration.createDefault();
telemetryConfiguration.setInstrumentationKey(instrumentationKey);
client = new TelemetryClient(telemetryConfiguration);
}
Agent configuration:
{
"connectionString": "InstrumentationKey=another-instrumentation-key;IngestionEndpoint=https://eastus2-0.in.applicationinsights.azure.com/",
"role": {
"name": "test-service"
},
"selfDiagnostics": {
"destination": "console"
}
}
The destination(instrumentation key) from custom client should be used, not configured globally in the agent.
Alternatives
We were trying to tune the client, but then we have realized that BytecodeUtilImpl.java#L220 configures agent client in the global scope.
Additional context
The client is set globally in the source code below https://github.com/microsoft/ApplicationInsights-Java/blob/3.0.2/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/instrumentation/sdk/BytecodeUtilImpl.java#L220
When custom client is configured with own instrumentation key it is ignored and handled by Agent client:
Agent configuration:
{ "connectionString": "InstrumentationKey=another-instrumentation-key;IngestionEndpoint=https://eastus2-0.in.applicationinsights.azure.com/", "role": { "name": "test-service" }, "selfDiagnostics": { "destination": "console" } }The destination(instrumentation key) from custom client should be used, not configured globally in the agent.
Alternatives
We were trying to tune the client, but then we have realized that BytecodeUtilImpl.java#L220 configures agent client in the global scope.
Additional context
The client is set globally in the source code below https://github.com/microsoft/ApplicationInsights-Java/blob/3.0.2/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/instrumentation/sdk/BytecodeUtilImpl.java#L220