-
Notifications
You must be signed in to change notification settings - Fork 14
Metrics
Brian Lehnen edited this page Jun 2, 2019
·
5 revisions
Metrics are provided via App.Metrics. This is provided via a seperate assembly - DotNetWorkQueue.AppMetrics
######Usage
Add a reference to both DotNetWorkQueue.AppMetrics and App.Metrics. You'll need to create an instance, and inject it into the queue container. Each queue will then report metrics to this instance of App.Metrics. You may share the same instance of App.Metrics among any number of containers/queues.
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("metricsettings.json")
.Build();
var influxOptions = new MetricsReportingInfluxDbOptions();
configuration.GetSection(nameof(MetricsReportingInfluxDbOptions)).Bind(influxOptions);
var metricsRoot = new MetricsBuilder()
.Configuration.ReadFrom(configuration)
.Configuration.Configure(
options =>
{
options.AddServerTag();
options.AddAppTag(appName);
})
.Report.ToInfluxDb(influxOptions)
.Build();
var metrics = new DotNetWorkQueue.AppMetrics.Metrics(metricsRoot);
container.RegisterNonScopedSingleton<IMetrics>(metrics);
var scheduler = new AppMetricsTaskScheduler(
TimeSpan.FromSeconds(3),
async () =>
{
await Task.WhenAll(metricsRoot.ReportRunner.RunAllAsync());
});
scheduler.Start();
The above code creates a new AppMetrics module and injects it into the queue container. Any queue created from this container will report metrics to this instance.
See Sample
For any issues please use the GitHub issues