Last active
June 3, 2018 20:17
-
-
Save thiagoloureiro/d439ffe13a24a35dc33ad2e97410cb03 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ConfigureServices(IServiceCollection services) | |
{ | |
var database = "appmetricsdemo"; | |
var uri = new Uri("http://127.0.0.1:8086"); | |
services.AddMetrics(options => | |
{ | |
options.WithGlobalTags((globalTags, info) => | |
{ | |
globalTags.Add("app", info.EntryAssemblyName); | |
globalTags.Add("env", "stage"); | |
}); | |
}) | |
.AddHealthChecks() | |
.AddReporting( | |
factory => | |
{ | |
factory.AddInfluxDb( | |
new InfluxDBReporterSettings | |
{ | |
InfluxDbSettings = new InfluxDBSettings(database, uri), | |
ReportInterval = TimeSpan.FromSeconds(5) | |
}); | |
}) | |
.AddMetricsMiddleware(options => options.IgnoredHttpStatusCodes = new[] { 404 }); | |
services.AddMvc(options => options.AddMetricsResourceFilter()); | |
} | |
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. | |
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IApplicationLifetime lifetime) | |
{ | |
loggerFactory.AddConsole(Configuration.GetSection("Logging")); | |
app.UseMetrics(); | |
app.UseMetricsReporting(lifetime); | |
app.UseMvc(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment