// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { IOC iOC = new IOC(); iOC.InjecaoAppService(services); iOC.InjecaoDomain(services); // Register the Swagger generator, defining 1 or more Swagger documents services.AddSwaggerGen(options => { options.ConfigureSwaggerGenOptions(Configuration); }); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(option => option.Configure(Configuration) ); services.AddAuthorization(options => { options.AddPolicy("APIFonetica", policy => policy.RequireClaim("APIFoneticaNumero")); }); services.AddMvcCore().AddMetricsCore(); // .AddApiExplorer() // .AddFormatterMappings() // .AddDataAnnotations() // .AddJsonFormatters() // .AddCors() ; services.AddResponseCompression(); services.AddGlobalExceptionHandlerMiddleware(); // services.AddDistributedMemoryCache(); // services.AddRouting(); services.AddHealthChecks() .AddGCInfoCheck("MEMORIA"); // var metrics = new MetricsBuilder() // .Configuration.Configure( // options => // { // options.AddServerTag(); // options.AddEnvTag(); // options.AddAppTag(); // }) // .OutputMetrics.AsPrometheusPlainText() // .OutputMetrics.AsPrometheusProtobuf() // .Build(); // services.AddMetrics(metrics); // services.AddMetricsEndpoints(); // services.AddMetricsTrackingMiddleware(); // services.AddMetricsReportingHostedService(); // var health = AppMetricsHealth.CreateDefaultBuilder() //.HealthChecks.RegisterFromAssembly(services) //.BuildAndAddTo(services); // services.AddHealth(health); // services.AddHealthEndpoints(); // services.AddHealthReportingHostedService(); var health = AppMetricsHealth.CreateDefaultBuilder();//.Configuration.Configure(new HealthOptions() { Enabled = true, ApplicationName = "http://health.local.com", ReportingEnabled = true }) //.Report.ToMetrics(metrics) //.HealthChecks.AddSqlCachedCheck("Teste de conexão com o banco.", () => new MySql.Data.MySqlClient.MySqlConnection("Server=mysql;Database=healthcheck;Uid=healthcheckuser;Pwd=healthcheckpws;SslMode=none;"), // TimeSpan.FromSeconds(10), // TimeSpan.FromMinutes(1)) //.HealthChecks.AddPingCheck("Google Ping", "google.com", TimeSpan.FromSeconds(10)) //.HealthChecks.AddHttpGetCheck("GitHub", new Uri("https://github.com"), TimeSpan.FromSeconds(10)) //.HealthChecks.RegisterFromAssembly(services) //.BuildAndAddTo(services); services.AddHealth(health); var metrics = new MetricsBuilder() .Configuration.Configure( options => { options.AddServerTag(); options.AddEnvTag(); options.AddAppTag(); }) .OutputMetrics.AsPrometheusPlainText() .Build(); services.AddMetrics(metrics); services.AddMetricsReportingHostedService(); services.AddHealthReportingHostedService(); services.AddMetricsEndpoints(); services.AddHealthEndpoints(); services.AddMetricsTrackingMiddleware(); services.AddMvc().AddMetrics(); services.AddMvc().AddMetrics(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); }