本文整理汇总了C#中Microsoft.ApplicationInsights.TelemetryClient类的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.ApplicationInsights.TelemetryClient类的具体用法?C# Microsoft.ApplicationInsights.TelemetryClient怎么用?C# Microsoft.ApplicationInsights.TelemetryClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Microsoft.ApplicationInsights.TelemetryClient类属于命名空间,在下文中一共展示了Microsoft.ApplicationInsights.TelemetryClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: 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();
}
示例3: updateWith10DayData
private void updateWith10DayData(string response)
{
var json = JObject.Parse(response);
JToken forecastToken;
if (!json.TryGetValue("forecast", out forecastToken))
{
var tc = new Microsoft.ApplicationInsights.TelemetryClient();
var properties = new Dictionary<String, string> { { "response", response } };
tc.TrackEvent($"Unexpected response in {nameof(updateWith10DayData)}", properties);
return;
}
var allDaily = forecastToken["simpleforecast"]["forecastday"].Children();
var dailyForecast = new List<WeatherDetailsModel>();
foreach (var daily in allDaily.Take(10))
{
var rawEpoch = Int64.Parse(daily["date"]["epoch"].ToString());
var epoch = DateTimeOffset.FromUnixTimeSeconds(rawEpoch);
var forecast = new WeatherDetailsModel()
{
Conditions = daily["conditions"].ToString(),
TemperatureHigh = Int32.Parse(daily["high"]["celsius"].ToString()),
TemperatureLow = Int32.Parse(daily["low"]["celsius"].ToString()),
Rainfall = Int32.Parse(daily["qpf_allday"]["mm"].ToString()),
Snowfall = Int32.Parse(daily["snow_allday"]["cm"].ToString()),
Time = epoch.DateTime,
};
dailyForecast.Add(forecast);
}
DailyForecast = dailyForecast;
}
示例4: Login
public ActionResult Login(LoginModel model, string returnUrl)
{
var telemetryClient = new Microsoft.ApplicationInsights.TelemetryClient();
TraceTelemetry traceSample = new TraceTelemetry();
if (ModelState.IsValid && WebSecurity.Login(
model.UserName, model.Password, persistCookie: model.RememberMe))
{
// Migrate the user's shopping cart
MigrateShoppingCart(model.UserName);
//Sample Trace telemetry
traceSample.Message = "Login succesfull";
traceSample.SeverityLevel = SeverityLevel.Information;
telemetryClient.TrackTrace(traceSample);
return RedirectToLocal(returnUrl);
}
//Sample Trace telemetry
traceSample.Message = "Login failed";
traceSample.SeverityLevel = SeverityLevel.Information;
telemetryClient.TrackTrace(traceSample);
// If we got this far, something failed, redisplay form
ModelState.AddModelError("", "The user name or password provided is incorrect.");
return View(model);
}
示例5: Index
//
// GET: /ShoppingCart/
public ActionResult Index()
{
var telemetryClient = new Microsoft.ApplicationInsights.TelemetryClient();
var cart = ShoppingCart.GetCart(storeDB, this.HttpContext);
// Set up our ViewModel
var viewModel = new ShoppingCartViewModel
{
CartItems = cart.GetCartItems(),
CartTotal = cart.GetTotal()
};
foreach (var item in viewModel.CartItems)
{
Trace.Write("Cart item: " + item.AlbumId);
}
//Sample Trace Telemetry
TraceTelemetry sampleTelemetry = new TraceTelemetry();
sampleTelemetry.Message = "Normal response- Database";
sampleTelemetry.SeverityLevel = SeverityLevel.Information;
telemetryClient.TrackTrace(sampleTelemetry);
// Return the view
return View(viewModel);
}
示例6: App
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
TelemetryClient = new Microsoft.ApplicationInsights.TelemetryClient();
this.InitializeComponent();
this.Suspending += OnSuspending;
}
示例7: App
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
TelemetryClient = new Microsoft.ApplicationInsights.TelemetryClient();
MapService.ServiceToken = "Your token here";
this.InitializeComponent();
this.Suspending += OnSuspending;
}
示例8: App
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
TelemetryClient = new Microsoft.ApplicationInsights.TelemetryClient();
TelemetryClient.Context.Properties.Add("Alias", "");
this.InitializeComponent();
this.Suspending += OnSuspending;
}
示例9: App
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
TelemetryClient = new Microsoft.ApplicationInsights.TelemetryClient();
this.InitializeComponent();
this.Suspending += OnSuspending;
this.UnhandledException += this.App_UnhandledException;
}
示例10: App
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
TelemetryClient = new Microsoft.ApplicationInsights.TelemetryClient();
this.InitializeComponent();
BaseViewModel.NavigationService = new NavigationHelper();
this.Suspending += OnSuspending;
}
示例11: App
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
TelemetryClient = new Microsoft.ApplicationInsights.TelemetryClient();
ParseObject.RegisterSubclass<Toilet>();
ParseClient.Initialize("xSi6lznksibSQE8LXWhEYLNghkZNVA3yCPATXPJ2", "wdorZjmU5SRAiHElPRBilEBzICmcAoepvpEoTrO7");
this.InitializeComponent();
this.Suspending += OnSuspending;
}
示例12: App
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
TelemetryClient = new Microsoft.ApplicationInsights.TelemetryClient();
this.InitializeComponent();
this.Suspending += OnSuspending;
if (ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
HardwareButtons.BackPressed += HardwareButtons_BackPressed;
}
示例13: App
public App()
{
TelemetryClient = new Microsoft.ApplicationInsights.TelemetryClient();
this.InitializeComponent();
this.Suspending += OnSuspending;
Router.Current.Scheme = "solidnavigation://";
Router.Current.AddRoute("tasks/{taskid}/comments", typeof(TaskDetailsPage), typeof(CommentTarget));
Router.Current.AddRoute("tasks/{taskid}", typeof(TaskDetailsPage), typeof(TaskDetailsTarget));
Router.Current.AddRoute("lists/{listid}", typeof(TasksPage), typeof(TaskListTarget));
Router.Current.AddRoute("", typeof(ListsPage), typeof(HomeTarget));
}
示例14: 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);
}
示例15: 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();
}
}