从WPF到应用程序见解未记录的上下文属性

时间:2018-02-17 21:24:28

标签: c# wpf analytics azure-application-insights telemetry

我正在尝试从WPF应用程序向Tele Insights记录遥测。正在记录事件和页面视图,但不会记录上下文属性。

我已将客户端初始化为:

    internal InsightsLogging(string instrumentationKey)
    {
        TelemetryConfiguration configuration = TelemetryConfiguration.Active;
        configuration.InstrumentationKey = instrumentationKey;

        QuickPulseTelemetryProcessor processor = null;
        configuration.TelemetryProcessorChainBuilder
            .Use((next) =>
            {
                processor = new QuickPulseTelemetryProcessor(next);
                return processor;
            })
            .Build();

        var QuickPulse = new QuickPulseTelemetryModule();
        QuickPulse.Initialize(configuration);
        QuickPulse.RegisterTelemetryProcessor(processor);

        Client = new TelemetryClient(configuration);
        Client.InstrumentationKey = instrumentationKey;
        Client.Context.Session.Id = Guid.NewGuid().ToString();
        Client.Context.Device.OperatingSystem = Environment.OSVersion.ToString();
        Client.Context.Device.Id = EnvironmentUtility.GetMACAddress();
        Client.Context.Component.Version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
        Client.Context.User.Id = LoggingDataProvider.User;
        Client.Context.User.AuthenticatedUserId = LoggingDataProvider.User;
        Client.Context.User.AccountId = LoggingDataProvider.Account;
        Client.Context.Component.Version = Assembly.GetEntryAssembly().GetName().Version.ToString();
        Client.Context.User.UserAgent = "App";
    }

日志最终看起来像: Logs

请注意,未填充任何“user_ *”列。值得注意的是,appName也是不正确的 - 它是Azure上应用程序洞察实例的名称。

0 个答案:

没有答案