internal static string ExpectedTraceDataOutput(string delimiter, TraceFilter filter, TraceEventCache cache, string source, TraceEventType eventType, int id, object[] data) { if (filter != null && !filter.ShouldTrace(cache, source, eventType, id, null, null, data, null)) { return(string.Empty); } string secondDelimiter = delimiter == "," ? DefaultDelimiter : ","; var builder = new StringBuilder(); builder.AppendHeader(source, eventType, id, delimiter); builder.Append(delimiter); if (data != null) { for (int i = 0; i < data.Length; ++i) { if (i != 0) { builder.Append(secondDelimiter); } builder.Append(EscapedString(data[i].ToString())); } } builder.Append(delimiter); builder.AppendTraceEventCache(cache, delimiter); return(builder.AppendLine().ToString()); }
/// <summary> /// Process Web Job Function Invocation Exceptions /// </summary> /// <param name="filter">The <see cref="TraceFilter"/> containing information about the exception.</param> public void Process(TraceFilter filter) { // Get Web Job scm Host URI: yoursite.scm.azurewebsites.net var httpHost = Environment.GetEnvironmentVariable("HTTP_HOST"); var events = filter.GetEvents().Where(e => e.Exception != null); foreach (var traceEvent in events) { var tags = new List <string>() { "UnhandledException" }; tags.AddRange(Tags); // Add all trace properties to custom data var customData = traceEvent.Properties.ToDictionary(traceEventProperty => traceEventProperty.Key, traceEventProperty => traceEventProperty.Value); // If the FunctionInvocationId is available to us, we can use it to build a clickable link using the http host if (traceEvent.Properties.ContainsKey("MS_FunctionInvocationId") && !string.IsNullOrEmpty(httpHost)) { var functionInvocationId = traceEvent.Properties["MS_FunctionInvocationId"]; customData["Dashboard URL"] = $"https://{httpHost}/azurejobs/#/functions/invocations/{functionInvocationId}"; } // If the FunctionDescriptor is available to us, we can use it to tag the executed function in raygun if (traceEvent.Properties.ContainsKey("MS_FunctionDescriptor")) { var functionDescriptor = (FunctionDescriptor)traceEvent.Properties["MS_FunctionDescriptor"]; tags.Add(functionDescriptor.ShortName); } _client.Send(traceEvent.Exception, tags.Distinct().ToList(), customData); } }
public override async Task <JArray> ExecuteAsync(IClient client) { var senderAddress = "0x12890d2cce102216644c59daE5baed380d84830c"; var privateKey = "0xb5b1870957d373ef0eeffecc6e4812c0fd08f554b37b233526acc331bf1544f7"; var web3 = new Web3.Web3(new Account(privateKey), client); var receipt = await web3.TransactionManager.TransactionReceiptService.SendRequestAndWaitForReceiptAsync( new TransactionInput { From = senderAddress, To = senderAddress, Value = new HexBigInteger(Web3.Web3.Convert.ToWei(1)) }); var traceTransaction = new TraceFilter(client); //ToAddress = new []{receiverAddress}, FromBlock = new BlockParameter(receipt.BlockNumber), Count = 1} return(await traceTransaction.SendRequestAsync(new TraceFilterDTO { FromBlock = new BlockParameter(receipt.BlockNumber), ToBlock = new BlockParameter(receipt.BlockNumber), FromAddresses = new[] { senderAddress }, Count = 10, })); }
private TraceFilter CalcListenerFilter(TraceLevel switchFilterLevel, TraceFilter listenerFilter) { SourceLevels convertedSourceLevel = switchFilterLevel == TraceLevel.Off ? SourceLevels.Off : (SourceLevels)((1 << (int)switchFilterLevel + 1) - 1); if (listenerFilter == null || listenerFilter is SourceFilter) { return(new EventTypeFilter(convertedSourceLevel)); } var listenerLevel = ((EventTypeFilter)listenerFilter).EventType; SourceLevels finalFilterLevel; if (convertedSourceLevel == SourceLevels.All) { finalFilterLevel = listenerLevel; } else if (listenerLevel == SourceLevels.All) { finalFilterLevel = convertedSourceLevel; } else { finalFilterLevel = (int)listenerLevel < (int)convertedSourceLevel ? listenerLevel : convertedSourceLevel; } return(new EventTypeFilter(finalFilterLevel)); }
public void TestTraceFilter() { TraceFilter filter = new TraceFilter(); filter.Offset = 0; filter.StartDate = DateTime.Now; filter.Urls = new List <string>(); filter.Urls.Add("http://dummytest"); filter.Sort = "any"; filter.Expand = new List <TraceExpandValue>(); filter.Expand.Add(TraceExpandValue.application); string qs = filter.ToString(); Assert.IsTrue(qs.Contains("offset=0")); Assert.IsTrue(qs.Contains("startDate")); Assert.IsTrue(qs.Contains("urls=http://dummytest")); Assert.IsTrue(qs.Contains("sort=any")); Assert.IsTrue(qs.Contains("expand=application")); Assert.IsFalse(qs.Contains("limit")); Assert.IsFalse(qs.Contains("endDate")); Assert.IsFalse(qs.Contains("filterTags")); Assert.IsFalse(qs.Contains("servers")); }
public void SetListenerFilter(String listenerName, TraceFilter filter) { if (Listeners.ContainsKey(listenerName)) { Listeners[listenerName].Filter = filter; } }
public DefaultDocumentMiddleware() { _traceFilter = new TraceFilter(null, this); ConfigurationChanged(new DefaultDocumentConfiguration()); this.RunFirst(); }
public CacheSessionMiddleware( ICache cache) { _cache = cache; _traceFilter = new TraceFilter(null, this); ConfigurationChanged(new SessionConfiguration()); }
public OutputCacheMiddleware( ICache cache) { _cache = cache; _traceFilter = new TraceFilter(null, this); ConfigurationChanged(new OutputCacheConfiguration()); }
public AnalysisReporterMiddleware() { this.RunAfter <IAuthorization>(null, false); this.RunAfter <IRequestRewriter>(null, false); this.RunAfter <IResponseRewriter>(null, false); _traceFilter = new TraceFilter(null, this); }
private IReadOnlyDictionary <string, object> GetBindingData(TraceFilter value) { Dictionary <string, object> bindingData = new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase); bindingData.Add("ErrorTrigger", value); bindingData.Add("Message", value.Message); return(bindingData); }
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)); }
public TraceApiService(IClient client) : base(client) { TraceBlock = new TraceBlock(client); TraceCall = new TraceCall(client); TraceFilter = new TraceFilter(client); TraceGet = new TraceGet(client); TraceRawTransaction = new TraceRawTransaction(client); TraceTransaction = new TraceTransaction(client); }
public void SetUp() { _mockConfiguration = GetMock <MockConfiguration, IConfiguration>(); _mockConfiguration.Clear(); _traceMessages = new List <string>(); Trace = (c, f) => _traceMessages.Add(f()); _traceFilter = new TraceFilter(SetupMock <IConfiguration>(), this); }
public StaticFilesMiddleware(IHostingEnvironment hostingEnvironment) { _hostingEnvironment = hostingEnvironment; _traceFilter = new TraceFilter(null, this); this.RunAfter <IOutputCache>(null, false); this.RunAfter <IRequestRewriter>(null, false); this.RunAfter <IResponseRewriter>(null, false); this.RunAfter <IAuthorization>(null, false); }
public DocumenterMiddleware( IHostingEnvironment hostingEnvironment) { this.RunAfter <IAuthorization>(null, false); this.RunAfter <IRequestRewriter>(null, false); this.RunAfter <IResponseRewriter>(null, false); _traceFilter = new TraceFilter(null, this); _resourceManager = new ResourceManager(hostingEnvironment, new MimeTypeEvaluator()); }
public NotFoundMiddleware( IHostingEnvironment hostingEnvironment) { this.RunLast(); _hostingEnvironment = hostingEnvironment; _traceFilter = new TraceFilter(null, this); ConfigurationChanged(new NotFoundConfiguration()); }
public IRoutingSegment Initialize( TraceFilter traceFilter, string name, Func <IOwinContext, bool> filter) { _traceFilter = traceFilter; Name = name; Filter = filter; return(this); }
/// <param name="filter">The TraceFilter included in the MultiFilter's specified FilterGroup</param> /// <param name="negate">Indicates whether the result of the filter should be inversed when ShouldTrace is evaluated (i.e True -> False and False - True). /// Specify true to negate the result or false to leave as is.</param> /// <exception cref="System.ArgumentNullException">Thrown if the filter argument is null</exception> public MultiFilterMember(TraceFilter filter, bool negate) { if (null == filter) { throw new ArgumentNullException("filter"); } Negate = negate; Filter = filter; }
/// <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> /// Creates a FilterMember so that the TraceFilter can be added to the FilterGroup /// </summary> /// <param name="filter">The TraceFilter to be added</param> /// <param name="negate">Whether the result of the Filter should be inversed</param> /// <exception cref="System.ArgumentNullException">Thrown if the filter argument is null</exception> public void Add(TraceFilter filter, bool negate) { if (null == filter) { throw new ArgumentNullException("filter"); } MultiFilterMember member = new MultiFilterMember(filter, negate); this.Add(member); }
public MainWindow() { InitializeComponent(); var threads = Environment.ProcessorCount > 2 ? 2 : 1; fileLoader = new FileLoader((int)threads, Dispatcher); traceFilter = new TraceFilter(fileLoader.NetworkTraces); statusUpdate = new Timer(TimerTick); statusUpdate.Change(100, 100); FileView.DataContext = traceFilter.FilteredTraces; }
/// <summary> /// Returns a list of traces from a certain organization. Other filtering options are available /// through the use of TraceFilter params. /// </summary> /// <param name="organizationId">Organization from which the traces will be retrieved.</param> /// <param name="filter">Query params that can be added to request.</param> /// <returns>A TraceFilterResponse object with the List of Trace objects.</returns> public TraceFilterResponse GetTraces(string organizationId, TraceFilter filter) { string endpoint = String.Format(NgEndpoints.ORGANIZATION_TRACES, organizationId); if (filter != null) { endpoint += filter.ToString(); } return(GetResponseAndDeserialize <TraceFilterResponse>(endpoint)); }
public Session( ICache cache, IOwinContext context, SessionConfiguration configuration, TraceFilter traceFilter) { _cache = cache; _context = context; _configuration = configuration; _traceFilter = traceFilter; }
/// <summary> /// Constructs a new router /// </summary> public Router( IConfiguration configuration, IDependencyGraphFactory dependencyGraphFactory) { _dependencyGraphFactory = dependencyGraphFactory; _traceFilter = new TraceFilter(configuration, this); _owinContextKey = "R:" + Guid.NewGuid().ToShortString(false); _dependencies = new List <IDependency>(); _segments = new List <IRoutingSegment>(); }
public VersioningContext( IOwinContext context, VersioningConfiguration configuration, TraceFilter traceFilter) { OriginalUrl = new Uri(context.Request.Uri.ToString()); OriginalPath = new PathString(context.Request.Path.Value); _configuration = configuration; _traceFilter = traceFilter; }
public void TraceEvent_FormatString_Test(TraceFilter filter, TraceEventCache eventCache, string source, TraceEventType eventType, int id, string format, object[] args) { using (var target = new DelimitedListTraceListener(_stream)) { target.Filter = filter; target.TraceOutputOptions = TraceOptions.ProcessId | TraceOptions.ThreadId | TraceOptions.DateTime | TraceOptions.Timestamp; target.TraceEvent(eventCache, source, eventType, id, format, args); } string expected = CommonUtilities.ExpectedTraceEventOutput(filter, eventCache, source, eventType, id, format, args); Assert.Equal(expected, File.ReadAllText(_fileName)); }
internal static string ExpectedTraceEventOutput(TraceFilter filter, TraceEventCache cache, string source, TraceEventType eventType, int id, string format, object[] args) { if (filter != null && !filter.ShouldTrace(cache, source, eventType, id, format, args, null, null)) return string.Empty; var builder = new StringBuilder(); builder.AppendHeader(source, eventType, id); builder.Append(EscapedString(args != null ? string.Format(format, args) : format)); builder.Append(DefaultDelimiter); builder.Append(DefaultDelimiter); builder.AppendTraceEventCache(cache); return builder.AppendLine().ToString(); }
internal static string ExpectedTraceDataOutput(TraceFilter filter, TraceEventCache cache, string source, TraceEventType eventType, int id, object data) { if (filter != null && !filter.ShouldTrace(cache, source, eventType, id, null, null, data, null)) return string.Empty; var builder = new StringBuilder(); builder.AppendHeader(source, eventType, id); builder.Append(DefaultDelimiter); builder.Append(EscapedString(data.ToString())); builder.Append(DefaultDelimiter); builder.AppendTraceEventCache(cache); return builder.AppendLine().ToString(); }
/// <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) { SendGridMessage message = new SendGridMessage() { From = _sendGridConfig.FromAddress, Subject = "WebJob Error Notification", Text = filter.GetDetailedMessage(5) }; message.AddTo(_sendGridConfig.ToAddress); _sendGrid.DeliverAsync(message); }
public void TraceEvent_FormatString_Test(TraceFilter filter, TraceEventCache eventCache, string source, TraceEventType eventType, int id, string format, object[] args) { using (var target = GetListener()) { target.Filter = filter; target.TraceOutputOptions = TraceOptions.ProcessId | TraceOptions.ThreadId | TraceOptions.DateTime | TraceOptions.Timestamp | TraceOptions.LogicalOperationStack; target.TraceEvent(eventCache, source, eventType, id, format, args); } string expected = CommonUtilities.ExpectedTraceEventOutput(filter, eventCache, source, eventType, id, format, args); Assert.Equal(expected, File.Exists(_fileName) ? File.ReadAllText(_fileName) : ""); }
/// <summary> /// Notify all subscribers that the threshold for the /// specified filter has been reached. /// </summary> protected virtual void Notify(TraceFilter filter) { // Throttle notifications if requested bool shouldNotify = NotificationThrottle == null || (DateTime.UtcNow - _lastNotification) > NotificationThrottle; if (shouldNotify) { foreach (var subscription in Subscriptions) { subscription(filter); } _lastNotification = DateTime.UtcNow; } }
internal static string ExpectedTraceDataOutput(string delimiter, TraceFilter filter, TraceEventCache cache, string source, TraceEventType eventType, int id, object[] data) { if (filter != null && !filter.ShouldTrace(cache, source, eventType, id, null, null, data, null)) return string.Empty; string secondDelimiter = delimiter == "," ? DefaultDelimiter : ","; var builder = new StringBuilder(); builder.AppendHeader(source, eventType, id, delimiter); builder.Append(delimiter); if (data != null) { for (int i = 0; i < data.Length; ++i) { if (i != 0) builder.Append(secondDelimiter); builder.Append(EscapedString(data[i].ToString())); } } builder.Append(delimiter); builder.AppendTraceEventCache(cache, delimiter); return builder.AppendLine().ToString(); }
public ErrorValueBinder(ParameterInfo parameter, TraceFilter value) : base(parameter.ParameterType) { _parameter = parameter; _value = value; }
public void TraceData_ObjectArray_Test(string delimiter,TraceFilter filter, TraceEventCache eventCache, string source, TraceEventType eventType, int id, object[] data) { using (var target = new DelimitedListTraceListener(_stream)) { target.Delimiter = delimiter; target.Filter = filter; target.TraceOutputOptions = TraceOptions.ProcessId | TraceOptions.ThreadId | TraceOptions.DateTime | TraceOptions.Timestamp; target.TraceData(eventCache, source, eventType, id, data); } string expected = CommonUtilities.ExpectedTraceDataOutput(delimiter, filter, eventCache, source, eventType, id, data); Assert.Equal(expected, File.ReadAllText(_fileName)); }
public CompositeTraceFilter(TraceFilter innerTraceFilter, Func<TraceEvent, bool> predicate = null, string message = null) { InnerTraceFilter = innerTraceFilter; _predicate = predicate; _message = message; }
private IReadOnlyDictionary<string, object> GetBindingData(TraceFilter value) { Dictionary<string, object> bindingData = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase); bindingData.Add("ErrorTrigger", value); bindingData.Add("Message", value.Message); return bindingData; }