public DashboardMiddleware(RequestDelegate next, RouteCollection routes, IPipelineMonitor monitor, DashboardOptions options) { _next = next ?? throw new ArgumentNullException(nameof(next)); _routes = routes ?? throw new ArgumentNullException(nameof(routes)); _monitor = monitor ?? throw new ArgumentNullException(nameof(monitor)); _options = options ?? throw new ArgumentNullException(nameof(options)); }
protected override bool RunProcessor(ProcessorInstance instance, IPipelineMonitor monitor, PropertyContext context) { if ((context.Stage & instance.Context.AllowedStages) == context.Stage) { return(base.RunProcessor(instance, monitor, context)); } return(false); }
public void Attach(IPipelineMonitor monitor) { _threadTraces.GetOrAdd(Thread.CurrentThread.ManagedThreadId, managedThreadId => { var trace = new ConsolePipelineTrace(managedThreadId); trace.Attach(monitor); return(trace); }); }
/// <summary> /// Creates a new instance of the DashboardContext /// </summary> /// <param name="httpContext"></param> /// <param name="monitor"></param> /// <param name="options"></param> public DashboardContext(HttpContext httpContext, IPipelineMonitor monitor, DashboardOptions options) { HttpContext = httpContext ?? throw new ArgumentNullException(nameof(httpContext)); Request = new DashboardRequest(httpContext); Response = new DashboardResponse(httpContext); Monitor = monitor; Options = options; //var antiforgery = HttpContext.RequestServices.GetService<IAntiforgery>(); }
public void Attach(IPipelineMonitor monitor) { var onRun = Observable.FromEventPattern <PipelineEventArgs>( h => monitor.RunEvent += h, h => monitor.RunEvent -= h); _onRun = onRun .Where(x => Thread.CurrentThread.ManagedThreadId == ManagedThreadId) .Subscribe(OnRun); var onComplete = Observable.FromEventPattern <PipelineEventArgs>( h => monitor.CompleteEvent += h, h => monitor.CompleteEvent -= h); _onComplete = onComplete .Where(x => Thread.CurrentThread.ManagedThreadId == ManagedThreadId) .Subscribe(OnComplete); var onError = Observable.FromEventPattern <PipelineErrorEventArgs>( h => monitor.ErrorEvent += h, h => monitor.ErrorEvent -= h); _onError = onError .Where(x => Thread.CurrentThread.ManagedThreadId == ManagedThreadId) .Subscribe(OnError); var onProcessorRun = Observable.FromEventPattern <PipelineProcessorEventArgs>( h => monitor.ProcessorRunEvent += h, h => monitor.ProcessorRunEvent -= h); _onProcessorRun = onProcessorRun .Where(x => Thread.CurrentThread.ManagedThreadId == ManagedThreadId) .Subscribe(OnProcessorRun); var onProcessorComplete = Observable.FromEventPattern <PipelineProcessorEventArgs>( h => monitor.ProcessorCompleteEvent += h, h => monitor.ProcessorCompleteEvent -= h); _onProcessorComplete = onProcessorComplete .Where(x => Thread.CurrentThread.ManagedThreadId == ManagedThreadId) .Subscribe(OnProcessorComplete); var onProcessorError = Observable.FromEventPattern <PipelineProcessorExceptionEventArgs>( h => monitor.ProcessorExceptionEvent += h, h => monitor.ProcessorExceptionEvent -= h); _onProcessorError = onProcessorError .Where(x => Thread.CurrentThread.ManagedThreadId == ManagedThreadId) .Subscribe(OnProcessorError); }
protected virtual bool RunProcessor(ProcessorInstance instance, IPipelineMonitor monitor, TPipelineContext context) { try { // Telemetry OnProcessorRun monitor?.OnProcessorRunEvent(new PipelineProcessorEventArgs(context, instance.Context, instance.Processor.GetType())); instance.Processor.Run(context, instance.Context); // Telemetry OnProcessorComplete monitor?.OnProcessorCompleteEvent(new PipelineProcessorEventArgs(context, instance.Context, instance.Processor.GetType())); } catch (Exception exception) { // Telemetry OnProcessorException monitor?.OnProcessorExceptionEvent(new PipelineProcessorExceptionEventArgs(context, exception, instance.Context, instance.Processor.GetType())); } return(true); }
public static IApplicationBuilder UseGauchoDashboard(this IApplicationBuilder app, string pathMatch = "/gaucho", IPipelineMonitor monitor = null, DashboardOptions options = null) { if (app == null) { throw new ArgumentNullException(nameof(app)); } if (pathMatch == null) { throw new ArgumentNullException(nameof(pathMatch)); } var routes = app.ApplicationServices.GetRequiredService <RouteCollection>(); options = options ?? app.ApplicationServices.GetService <DashboardOptions>() ?? new DashboardOptions(); monitor = monitor ?? app.ApplicationServices.GetRequiredService <IPipelineMonitor>(); monitor.Options = options; if (monitor == null) { throw new InvalidOperationException("Unable to find the required services. Please add all the required services by calling 'IServiceCollection.AddGaucho' inside the call to 'ConfigureServices(...)' in the application startup code."); } app.Map(new PathString(pathMatch), x => x.UseMiddleware <DashboardMiddleware>(routes, monitor, options)); return(app); }