Skip to content

Add possibility to use multiple custom destinations(instrumentation keys) #1674

@born-to-be-mad

Description

@born-to-be-mad

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions