使用以下代码示例检查和添加属性:
import com.microsoft.applicationinsights.TelemetryClient;
import com.microsoft.applicationinsights.telemetry.Telemetry;
import com.microsoft.applicationinsights.telemetry.TelemetryContext;
// 获取TelemetryClient和TelemetryContext实例
TelemetryClient client = new TelemetryClient();
Telemetry telemetry = new Telemetry();
TelemetryContext context = telemetry.getContext();
// 添加属性
context.getProperties().put("attribute1", "value1");
context.getProperties().put("attribute2", "value2");
// 发送遥测
client.track(telemetry);
这些属性将出现在应用程序洞察器中,在遥测搜索和筛选中提供有用的上下文信息。