本文整理汇总了C#中Microsoft.ApplicationInsights.TelemetryClient.TrackTrace方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.ApplicationInsights.TelemetryClient.TrackTrace方法的具体用法?C# Microsoft.ApplicationInsights.TelemetryClient.TrackTrace怎么用?C# Microsoft.ApplicationInsights.TelemetryClient.TrackTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.ApplicationInsights.TelemetryClient
的用法示例。
在下文中一共展示了Microsoft.ApplicationInsights.TelemetryClient.TrackTrace方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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);
}
示例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);
}
示例4: LogOff
public ActionResult LogOff()
{
WebSecurity.Logout();
var telemetryClient = new Microsoft.ApplicationInsights.TelemetryClient();
//Sample Trace telemetry
TraceTelemetry traceSample = new TraceTelemetry();
traceSample.Message = "Logged off";
traceSample.SeverityLevel = SeverityLevel.Information;
telemetryClient.TrackTrace(traceSample);
return RedirectToAction("Index", "Home");
}
示例5: Register
public ActionResult Register(RegisterModel model)
{
if (ModelState.IsValid)
{
// Attempt to register the user
try
{
WebSecurity.CreateUserAndAccount(model.UserName, model.Password);
WebSecurity.Login(model.UserName, model.Password);
// Migrate the newly registered user's shopping cart
MigrateShoppingCart(model.UserName);
var telemetryClient = new Microsoft.ApplicationInsights.TelemetryClient();
//Sample Trace telemetry
TraceTelemetry traceSample = new TraceTelemetry();
traceSample.Message = "Registered succesfully";
traceSample.SeverityLevel = SeverityLevel.Information;
telemetryClient.TrackTrace(traceSample);
return RedirectToAction("Index", "Home");
}
catch (MembershipCreateUserException e)
{
var telemetryClient = new Microsoft.ApplicationInsights.TelemetryClient();
//Sample Trace telemetry
TraceTelemetry traceSample = new TraceTelemetry();
traceSample.Message = "Registration failed";
traceSample.SeverityLevel = SeverityLevel.Error;
telemetryClient.TrackTrace(traceSample);
ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
}
}
// If we got this far, something failed, redisplay form
return View(model);
}