public Task InvokeAsync(HttpContext context) { if (!extensions.TryGet <IVostokApplicationDiagnostics>(out var diagnostics)) { return(next.Invoke(context)); } var diagnosticPath = GetDiagnosticPath(context); if (diagnosticPath == null) { return(next.Invoke(context)); } if (diagnosticPath == string.Empty) { return(HandleListRequest(context, diagnostics.Info)); } if (DiagnosticEntry.TryParse(diagnosticPath, out var entry) && diagnostics.Info.TryQuery(entry, out var payload)) { return(HandleInfoRequest(context, payload)); } return(next.Invoke(context)); }
private void RegisterDiagnostics(IVostokApplicationDiagnostics diagnostics) { var info = GetInfo(); var infoEntry = new DiagnosticEntry("scheduled", info.Name); var infoProvider = new ScheduledActionsInfoProvider(GetInfo); var healthCheck = new ScheduledActionsHealthCheck(GetInfo); diagnosticInfoRegistration = diagnostics.Info.RegisterProvider(infoEntry, infoProvider); healthCheckRegistration = diagnostics.HealthTracker.RegisterCheck($"scheduled ({info.Name})", healthCheck); }
private void RegisterRequestTracker(IServiceCollection services, DiagnosticFeaturesSettings settings) { if (environment.HostExtensions.TryGet <IVostokApplicationDiagnostics>(out var diagnostics) && settings.AddCurrentRequestsInfoProvider) { var requestTracker = new RequestTracker(); services.AddSingleton <IRequestTracker>(requestTracker); var infoEntry = new DiagnosticEntry(DiagnosticConstants.Component, "requests-in-progress"); var infoProvider = new CurrentRequestsInfoProvider(requestTracker); disposables.Add(diagnostics.Info.RegisterProvider(infoEntry, infoProvider)); }
private void RegisterDiagnosticFeatures(IVostokHostingEnvironment environment) { if (!environment.HostExtensions.TryGet <IVostokApplicationDiagnostics>(out var diagnostics)) { return; } foreach (var actionRunner in runner.Runners) { var info = actionRunner.GetInfo(); var infoEntry = new DiagnosticEntry("scheduled", info.Name); var infoProvider = new ScheduledActionsInfoProvider(actionRunner); var healthCheck = new ScheduledActionsHealthCheck(actionRunner); disposables.Add(diagnostics.Info.RegisterProvider(infoEntry, infoProvider)); disposables.Add(diagnostics.HealthTracker.RegisterCheck($"scheduled ({info.Name})", healthCheck)); } }
private void RegisterThrottlingProvider(IServiceCollection services, DiagnosticFeaturesSettings settings) { var throttlingProvider = throttlingBuilder.BuildProvider(); services.AddSingleton <IThrottlingProvider>(throttlingProvider); if (environment.HostExtensions.TryGet <IVostokApplicationDiagnostics>(out var diagnostics)) { if (settings.AddThrottlingInfoProvider) { var infoEntry = new DiagnosticEntry(DiagnosticConstants.Component, "request-throttling"); var infoProvider = new ThrottlingInfoProvider(throttlingProvider); disposables.Add(diagnostics.Info.RegisterProvider(infoEntry, infoProvider)); } if (settings.AddThrottlingHealthCheck) { var healthCheck = new ThrottlingHealthCheck(throttlingProvider); disposables.Add(diagnostics.HealthTracker.RegisterCheck("Request throttling", healthCheck)); } } }
private string CreateInfoUrl(DiagnosticEntry entry) => pathPrefix.TrimStart('/') + '/' + entry;