当前位置: 首页>>代码示例>>C#>>正文


C# Microsoft.ApplicationInsights.TelemetryClient.TrackException方法代码示例

本文整理汇总了C#中Microsoft.ApplicationInsights.TelemetryClient.TrackException方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.ApplicationInsights.TelemetryClient.TrackException方法的具体用法?C# Microsoft.ApplicationInsights.TelemetryClient.TrackException怎么用?C# Microsoft.ApplicationInsights.TelemetryClient.TrackException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.ApplicationInsights.TelemetryClient的用法示例。


在下文中一共展示了Microsoft.ApplicationInsights.TelemetryClient.TrackException方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TaskScheduler_UnobservedTaskException

 private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     var client = new Microsoft.ApplicationInsights.TelemetryClient();
     client.TrackException(e.Exception);
     _logger.Error(e.Exception);
     e.SetObserved();
 }
开发者ID:sunnycase,项目名称:love-life,代码行数:7,代码来源:App.xaml.cs

示例2: App_UnhandledException

 private void App_UnhandledException(object sender, Windows.UI.Xaml.UnhandledExceptionEventArgs e)
 {
     var client = new Microsoft.ApplicationInsights.TelemetryClient();
     client.TrackException(e.Exception);
     _logger.Error(e.Exception);
     e.Handled = true;
 }
开发者ID:sunnycase,项目名称:love-life,代码行数:7,代码来源:App.xaml.cs

示例3: Index

        //
        // GET: /Home/

        public async Task<ActionResult> Index()
        {
            // Get most popular albums
            var albums = await GetTopSellingAlbums(6);
            //var albums = GetTopSellingAlbums(6);

            // Trigger some good old ADO code 
            var albumCount = GetTotalAlbumns(); 
            Trace.Write(string.Format("Total number of Albums = {0} and Albums with 'The' = {1}", albumCount.Item1, albumCount.Item2));

            var telemetryClient = new Microsoft.ApplicationInsights.TelemetryClient();

            //Sample Trace telemetry
            TraceTelemetry traceSample = new TraceTelemetry();
            traceSample.Message = "Slow response - database";
            traceSample.SeverityLevel = SeverityLevel.Warning;
            telemetryClient.TrackTrace(traceSample);

            //Sample event telemetry
            var properties = new Dictionary<string, string> { { "Property 1",string.Format("Album Count {0}" ,albumCount.Item1) } };
            var measurements = new Dictionary<string, double> { { "Sample Meassurement", albumCount.Item1 } };
            telemetryClient.TrackEvent("Top Selling Albums", properties, measurements);

            //Sample exception telemetry
            try
            {
                albumCount = null;
                int count=albumCount.Item1;
            }
            catch (Exception ex)
            {
                telemetryClient.TrackException(ex, properties, measurements);
            }

            //Obtains the ip address from the request
            var request = new RequestTelemetry();
            request.Url = HttpContext.Request.Url;
            request.Duration = System.TimeSpan.FromMilliseconds(100);
            request.Success = false;
            request.Name = "TEST REQUEST " + request.Name;
            telemetryClient.TrackRequest(request);

            return View(albums);
        }
开发者ID:pablodam20,项目名称:Glimpse.ApplicationInsights,代码行数:47,代码来源:HomeController.cs

示例4: GlobalKeyDown

 internal void GlobalKeyDown(CoreWindow sender, KeyEventArgs args)
 {
     try
     {
         if (args.VirtualKey == Windows.System.VirtualKey.Right)
         {
             NavigateNext();
         }
         else if (args.VirtualKey == Windows.System.VirtualKey.Left)
         {
             NavigatePrevious();
         }
     }
     catch (Exception ex)
     {
         var tc = new Microsoft.ApplicationInsights.TelemetryClient();
         var properties = new Dictionary<String, string> { { "Module", "Navigation" } };
         tc.TrackException(ex, properties);
         System.Diagnostics.Debugger.Break();
     }
 }
开发者ID:AmadeusW,项目名称:Mirror,代码行数:21,代码来源:NavigationController.cs

示例5: OnLaunched

        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {

#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif
            var tc = new Microsoft.ApplicationInsights.TelemetryClient();

            var navigation = new NavigationController(launchScreenCallback);
            CoreWindow.GetForCurrentThread().KeyDown += navigation.GlobalKeyDown;

            await SettingsController.LoadSettings();

            try
            {
                var clockModel = new ClockModel();
                Task.Run(() => clockModel.Update());
                (Resources["clockViewModel"] as ClockViewModel).Initialize(clockModel);
                TimerController.RegisterModel(clockModel);
                navigation.RegisterView(typeof(ClockView));
                clockModel.NightFallDelegate += TimeOfDayChangedHandler;
            }
            catch (Exception ex)
            {
                var properties = new Dictionary<String, string> { { "Module", "Clock" } };
                tc.TrackException(ex, properties);
                System.Diagnostics.Debugger.Break();
            }

            try
            { 
                var weatherModel = new WeatherModel_wunderground();
                Task.Run(() => weatherModel.Update());
                TimerController.RegisterModel(weatherModel);
                (Resources["weatherThisWeekViewModel"] as WeatherThisWeekViewModel).Initialize(weatherModel);
                (Resources["weatherTodayViewModel"] as WeatherTodayViewModel).Initialize(weatherModel);
                navigation.RegisterView(typeof(WeatherThisWeekView));
                navigation.RegisterView(typeof(WeatherTodayView));
            }
            catch (Exception ex)
            {
                var properties = new Dictionary<String, string> { { "Module", "Weather" } };
                tc.TrackException(ex, properties);
                System.Diagnostics.Debugger.Break();
            }

            try
            { 
                var transitModel = new TransitModel_translink();
                Task.Run(() => transitModel.Update());
                TimerController.RegisterModel(transitModel);
                (Resources["transitViewModel"] as TransitViewModel).Initialize(transitModel);
                TimerController.RegisterViewModel((Resources["transitViewModel"] as TransitViewModel));
                navigation.RegisterView(typeof(TransitView));
            }
            catch (Exception ex)
            {
                var properties = new Dictionary<String, string> { { "Module", "Transit" } };
                tc.TrackException(ex, properties);
                System.Diagnostics.Debugger.Break();
            }

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new ThemeAwareFrame(ElementTheme.Light);

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                rootFrame.Navigate(typeof(ClockView), e.Arguments);
            }
            // Ensure the current window is active
            Window.Current.Activate();
            tc.TrackEvent("Smart Mirror has loaded.");
//.........这里部分代码省略.........
开发者ID:AmadeusW,项目名称:Mirror,代码行数:101,代码来源:App.xaml.cs


注:本文中的Microsoft.ApplicationInsights.TelemetryClient.TrackException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。