-
Notifications
You must be signed in to change notification settings - Fork 110
Configuration
Alex Meyer-Gleaves edited this page Sep 19, 2016
·
9 revisions
Configuration of the metrics library can be done using the Config property of the static Metric class.
The root context name for metrics inside a process can be configured in the following ways (in decreasing order of priority):
- Set the environment variable: Metrics.GlobalContextName
- Set the app settings key Metrics.GlobalContextName
- If none of the above is set the default is MachineName.ProcessName
The global context name can contain the following variable placeholders:
-
$Env.MachineName$ will be replaced with the machine name -
$Env.ProcessName$ will be replaced with the process name -
$Env.AppDomainAppVirtualPath$ will be replaced with the app virtual path -
$Env.$ will be replaced with the corresponding environment variable
Metric.Config
.WithHttpEndpoint("http://localhost:1234/metrics/")
.WithAllCounters()
.WithInternalMetrics()
.WithReporting(config => config
.WithConsoleReport(TimeSpan.FromSeconds(30))
.WithCSVReports(@"c:\temp\reports\", TimeSpan.FromMinutes(30))
.WithTextFileReport(@"C:\temp\reports\metrics.txt", TimeSpan.FromHours(1))
);
The following settings can be placed in the app.config ( or web.config ) file to control a few aspects of the Metrics.NET library:
<!-- Completely disable all metrics -->
<add key="Metrics.CompletelyDisableMetrics" value="true"/>
<!-- Equivalent of calling Metric.Config.WithHttpEndpoint("http://localhost:1234/") -->
<add key="Metrics.HttpListener.HttpUriPrefix" value="http://localhost:1234/"/>
<!-- Equivalent of calling
Metric.Config.WithReporting(config =>
config.WithCSVReports(@"..\MetricsCSV\", TimeSpan.FromSeconds(10))
-->
<add key="Metrics.CSV.Path" value="..\MetricsCSV\"/>
<add key="Metrics.CSV.Interval.Seconds" value="10"/>
For any issues please use the GitHub issues. For any other questions and ideas feel free to ping us: @PaulParau, @HinteaDan, @BogdanGaliceanu.