Azure Application Insights JS集成失败,AI异常
我们的一个应用程序使用application Insights,我们发现application Insights中报告了以下错误,有人能帮助我了解如何修复它吗: AI:TelemetryInitializerFailed消息:“其中一个遥测初始化器失败,遥测项将不会发送:TypeError”道具:“{exception:[对象错误]{stack:'TypeError:无法读取未定义的属性'correlationKey'\n at\n在n.track()\n在n.trackDependencyData()\n在n.jaxComplete()\n在XMLHttpRequest.(),消息:'无法读取未定义的属性'correlationKey',名称:'TypeError'} 这是因为使用了AI版本吗?似乎是AI.0.js..不确定这意味着什么请提供帮助 你们认为这可能是因为上面的JS版本吗?我不明白为什么JS版本显示为“ai.0.JS:1.45057”) 我们的自定义初始值设定项代码 `从“@angular/core”导入{Injectable}; 从“applicationinsights js”导入{AppInsights}Azure Application Insights JS集成失败,AI异常,azure,azure-application-insights,Azure,Azure Application Insights,我们的一个应用程序使用application Insights,我们发现application Insights中报告了以下错误,有人能帮助我了解如何修复它吗: AI:TelemetryInitializerFailed消息:“其中一个遥测初始化器失败,遥测项将不会发送:TypeError”道具:“{exception:[对象错误]{stack:'TypeError:无法读取未定义的属性'correlationKey'\n at\n在n.track()\n在n.trackDependencyDa
@Injectable()
export class AppInsightService {
private appInsightConfig = (<any>window).environment && (<any>window).environment.appInsights || {};
private config: Microsoft.ApplicationInsights.IConfig = {
instrumentationKey: this.appInsightConfig.instrumentationKey,
};;
constructor() {
if (!AppInsights.config && this.appInsightConfig.instrumentationKey) {
AppInsights.downloadAndSetup(this.config);
AppInsights.queue.push(() => {
AppInsights.context.addTelemetryInitializer(this.getCustomTelemetryInitializer());
});
}
}
logPageView(name?: string, url?: string, properties?: any, measurements?: any, duration?: number) {
AppInsights.trackPageView(name, url, properties, measurements, duration);
}
logEvent(name: string, properties?: any, measurements?: any) {
AppInsights.trackEvent(name, properties, measurements);
}
logError(error: Error, properties?: any, measurements?: any) {
AppInsights.trackException(error, null, properties, measurements);
}
private shouldSkipMetric(envelope :Microsoft.ApplicationInsights.IEnvelope) {
return this.appInsightConfig.trimKeepAlive && envelope.name === Microsoft.ApplicationInsights.Telemetry.RemoteDependencyData.envelopeType && /session\/keepalive/.test(envelope.data.baseData.name);
}
private getCustomTelemetryInitializer() {
return (envelope: Microsoft.ApplicationInsights.IEnvelope) => {
if (this.shouldSkipMetric(envelope)) {
return false;
}
envelope.tags['ai.device.roleName'] = this.appInsightConfig.roleName;
};
}
@Injectable()
导出类AppInsightService{
私有appInsightConfig=(窗口).environment&&(窗口).environment.appInsights | |{};
私有配置:Microsoft.ApplicationInsights.IConfig={
instrumentationKey:this.appInsightConfig.instrumentationKey,
};;
构造函数(){
如果(!AppInsights.config&&this.appInsightConfig.instrumentationKey){
AppInsights.downloadAndSetup(this.config);
AppInsights.queue.push(()=>{
AppInsights.context.addTelemetryInitializer(this.getCustomTelemetryInitializer());
});
}
}
logPageView(名称?:字符串、url?:字符串、属性?:任意、测量?:任意、持续时间?:编号){
trackPageView(名称、url、属性、度量、持续时间);
}
logEvent(名称:字符串、属性?:任意、测量?:任意){
AppInsights.trackEvent(名称、属性、度量);
}
日志错误(错误:错误,属性?:任何,测量?:任何){
trackException(错误、null、属性、度量);
}
private shouldSkipMetric(信封:Microsoft.ApplicationInsights.IEDevelope){
返回this.appInsightConfig.trimKeepAlive&&envelope.name==Microsoft.ApplicationInsights.Telemetry.RemoteDependencyData.envelopeType&&session\/keepalive/.test(envelope.data.baseData.name);
}
私有getCustomTelemetryInitializer(){
返回(信封:Microsoft.ApplicationInsights.IEDevelope)=>{
if(此.shouldSkipMetric(信封)){
返回false;
}
信封.tags['ai.device.roleName']=this.appInsightConfig.roleName;
};
}
谢谢,此错误意味着您的一个遥测初始值设定项正在崩溃,因此导致遥测数据丢失。
correlationKey
不是Application Insights JS SDK知道的内容,因此我认为这是您的应用程序本身添加的遥测初始值设定项。您有自定义的遥测初始值设定项吗izers?添加一个类似于此。appInsights.context.addTelemetryInitializer(/*some function*/)
感谢您的回复,这意味着问题出在自定义初始化器中,我们只需设置云角色名,即使我们使用旧库,也可以,或者您建议我们升级到新的AI库。因为我认为我的团队至少使用了旧库,因为它似乎是AI.0.js.1。发布了自定义初始化r代码在上面的主要问题帖子中。