/// <summary> /// Triggered when an error is reported in other functions. /// Called whenever 2 errors occur within a 3 minutes sliding window (throttled at a maximum of 2 notifications per 10 minutes). /// </summary> public static void GlobalErrorMonitor([ErrorTrigger("0:03:00", 2, Throttle = "0:10:00")] TraceFilter filter, TextWriter log, [SendGrid(From = "*****@*****.**", To = "*****@*****.**")] out Mail mail) { mail = new Mail(); mail.Subject = "WebJob - Warning - An error has been detected in a job"; mail.AddContent(new Content("text/plain", filter.GetDetailedMessage(1))); Console.Error.WriteLine("An error has been detected in a function."); log.WriteLine(filter.GetDetailedMessage(1)); }
/// <summary> /// Job triggered when an error is reported in other jobs. /// Called whenever 1 error occurs within a 1 minute sliding window (throttled at a maximum of 1 notification per 15 seconds). /// </summary> public static void GlobalErrorMonitorJob([ErrorTrigger("0:01:00", 1, Throttle = "0:00:15")] TraceFilter filter, TextWriter log, [NotificationHub(TagExpression = "JobsFailing")] out Notification[] notifications) { var notification = new WebJobHealthNotification() { Message = filter.GetDetailedMessage(1), Status = WebJobHealthStatus.Failure, Title = $"An error has been detected in a job", }; notifications = GetPlatformNotifications(notification).ToArray(); Console.Error.WriteLine("An error has been detected in a job."); log.WriteLine(filter.GetDetailedMessage(1)); }
public void UnHandledException([ErrorTrigger("0:01:00", 1)] TraceFilter filter, TextWriter log) { foreach (var traceEvent in filter.Events) { _telemetryClient.TrackException(traceEvent.Exception); } // log the last detailed errors to the Dashboard log.WriteLine(filter.GetDetailedMessage(1)); }
/// <summary> /// Global error monitor function that will be triggered whenever errors /// pass the specified sliding window threshold. /// </summary> /// <param name="filter">The <see cref="TraceFilter"/> that caused the error /// trigger to fire.</param> public static void ErrorMonitor( [ErrorTrigger("00:30:00", 10)] TraceFilter filter, TextWriter log) { // send a SMS notification _notifier.WebNotify(filter); // log last 5 detailed errors to the Dashboard log.WriteLine(filter.GetDetailedMessage(5)); }
/// <summary> /// Send an email notification using SendGrid. /// </summary> /// <param name="filter">The <see cref="TraceFilter"/> that triggered the notification.</param> public void EmailNotify(TraceFilter filter) { SendGridMessage message = new SendGridMessage() { From = _sendGridConfig.FromAddress, Subject = "WebJob Error Notification", Text = filter.GetDetailedMessage(5) }; message.AddTo(_sendGridConfig.ToAddress); _sendGrid.DeliverAsync(message); }
/// <summary> /// Send an email notification using SendGrid. /// </summary> /// <param name="filter">The <see cref="TraceFilter"/> that triggered the notification.</param> public void EmailNotify(TraceFilter filter) { var message = new SendGridMessage() { From = _sendGridConfig.FromAddress, Subject = "WebJob Error Notification" }; message.AddContent("text/plain", filter.GetDetailedMessage(5)); message.AddTo(_sendGridConfig.ToAddress); _sendGrid.SendEmailAsync(message).Wait(); }
/// <summary> /// Send an email notification using SendGrid. /// </summary> /// <param name="filter">The <see cref="TraceFilter"/> that triggered the notification.</param> public void EmailNotify(TraceFilter filter) { Mail message = new Mail() { From = _sendGridConfig.FromAddress, Subject = "WebJob Error Notification" }; message.AddContent(new Content("text/plain", filter.GetDetailedMessage(5))); Personalization personalization = new Personalization(); personalization.AddTo(_sendGridConfig.ToAddress); message.AddPersonalization(personalization); _sendGrid.client.mail.send.post(requestBody: message.Get()); }
/// <summary> /// Triggered when an error is reported in other functions. /// Called whenever 2 errors occur within a 3 minutes sliding window (throttled at a maximum of 2 notifications per 10 minutes). /// </summary> public static void GlobalErrorMonitor([ErrorTrigger("0:03:00", 2, Throttle = "0:10:00")] TraceFilter filter, TextWriter log) { Console.Error.WriteLine("An error has been detected in a function."); log.WriteLine(filter.GetDetailedMessage(1)); }