prometheus-net icon indicating copy to clipboard operation
prometheus-net copied to clipboard

feat: Info metric

Open jetelain opened this issue 1 year ago • 0 comments

Adds Info Metric: https://github.com/prometheus/OpenMetrics/blob/main/specification/OpenMetrics.md#info

Info metrics are used to expose textual information which SHOULD NOT change during process lifetime. Common examples are an application's version, revision control commit, and the version of a compiler. A MetricPoint of an Info Metric contains a LabelSet. An Info MetricPoint's LabelSet MUST NOT have a label name which is the same as the name of a label of the LabelSet of its Metric. Info MAY be used to encode ENUMs whose values do not change over time, such as the type of a network interface. MetricFamilies of type Info MUST have an empty Unit string.

According to Java library:

Info metrics are used to expose textual information which should not change during process lifetime. The value of an Info metric is always 1.

Usage:

Metrics
  .CreateInfo("application_info", "Application Version", new[] { "version", "commit" })
  .WithLabels("1.2.3", "60e9106a83ff1274fec0022c37366f04822b1d1b");

Also adds a default Info Metric for dotnet runtime informations:

# HELP dotnet_info .NET runtime
# TYPE dotnet_info info
dotnet_info{version="6.0.36",framework=".NET 6.0.36",runtime="win10-x64"} 1

Can be disabled with Metrics.SuppressDefaultMetrics(new SuppressDefaultMetricOptions() { SuppressRuntimeInfoMetrics = true } );.

jetelain avatar Nov 25 '24 07:11 jetelain