public EndpointMonitor(IHttpClientFactory httpClientFactory, EndpointService service, ILogger <EndpointMonitor> logger, ITokenService tokenService, PrometheusPublisher prometheusPublisher, ApplicationInsightsPublisher aiPublisher) { _httpClientFactory = httpClientFactory; _tokenService = tokenService; _service = service; _logger = logger; _prometheusPublisher = prometheusPublisher; _aiPublisher = aiPublisher; }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <EpMonContext>(); services.Configure <IISServerOptions>(options => { options.AutomaticAuthentication = false; }); services.AddStartupJob <MigrateDatabaseJob>(); services.AddHttpClient("default").ConfigurePrimaryHttpMessageHandler(messageHandler => { var handler = new HttpClientHandler(); if (handler.SupportsAutomaticDecompression) { handler.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip; } //do not use cookies to avoid load balancer issues handler.UseCookies = false; return(handler); }); services.AddSingleton <ITokenService, CachedTokenService>(); services.AddTransient <EndpointMonitor, EndpointMonitor>(); services.AddTransient <EndpointStore, EndpointStore>(); services.AddTransient <EndpointService, EndpointService>(); services.AddSingleton <PrometheusPublisher, PrometheusPublisher>(); var aiKey = Configuration.GetSection("EpMon:ApplicationInsightsKey").Value; var publisher = new ApplicationInsightsPublisher(aiKey); services.AddSingleton(publisher); services.AddMvc(options => options.EnableEndpointRouting = false).AddNewtonsoftJson(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo { Title = "EpMon API", Version = "v1" }); }); services.AddScheduledJobs(); }