Hi @Adarsh
The docs have been updated to address this gap. You can find the references at the following links:
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
My application has Beans that instantiates telemetry client with required telemetry configuration and custom telemetry initializer in the following way shown below.
@Bean@Scope("singleton")
TelemetryConfiguration telemetryConfiguration() {
TelemetryConfiguration telemetryConfiguration= TelemetryConfiguration.getActive(); telemetryConfiguration.setInstrumentationKey(instrumentationKey); telemetryConfiguration.getTelemetryInitializers().add(customTelemetryInitializer);
return telemetryConfiguration;}
@Bean
@DependsOn({"telemetryConfiguration"})
TelemetryClient azureMonitor(TelemetryConfiguration telemetryConfiguration) { return new TelemetryClient(telemetryConfiguration);
}
And my customInitializer has this code to add new properties:
@Setter private String id;
@Setter private String name;
@Override
public void initialize(Telemetry telemetry) {
if (telemetry.getContext().getCloud().getRoleInstance() != null) { telemetry.getContext().getProperties().put("id", id); telemetry.getContext().getProperties().put("name", name);
}
}
I expected that the id and name would be set(in a service that gets executed for every request) and is shown in every appinsights table even if the code does not have any usage of TelemetryClient and calling methods like TrackEvent or TrackMetric or TrackException or TrackTrace? The SDK automatically collects request telemetry, traces , dependencies and will this override put the properties before sending to appinsights? Not sure if ApplicationInsights.json plays a role in these kind of works.
Also is there any document on how initializer can be implemented and used in JAVA? I could find the document only for C# and JavaScript.
Any help would be greatly appreciated. Thanks!