@@ -21,7 +21,7 @@ UpDownCounter becomes gauge
21
21
PrometheusType . Untyped , PrometheusType . Counter , PrometheusType . Gauge , PrometheusType . Summary , PrometheusType . Histogram , PrometheusType . Histogram , PrometheusType . Histogram , PrometheusType . Histogram , PrometheusType . Gauge ,
22
22
] ;
23
23
24
- public PrometheusMetric ( string name , string unit , PrometheusType type , bool disableTotalNameSuffixForCounters )
24
+ public PrometheusMetric ( string name , string unit , PrometheusType type , bool disableTotalNameSuffixForCounters , bool disableAppendingUnitName )
25
25
{
26
26
// The metric name is
27
27
// required to match the regex: `[a-zA-Z_:]([a-zA-Z0-9_:])*`. Invalid characters
@@ -32,7 +32,7 @@ public PrometheusMetric(string name, string unit, PrometheusType type, bool disa
32
32
var openMetricsName = SanitizeOpenMetricsName ( sanitizedName ) ;
33
33
34
34
string ? sanitizedUnit = null ;
35
- if ( ! string . IsNullOrEmpty ( unit ) )
35
+ if ( ! disableAppendingUnitName && ! string . IsNullOrEmpty ( unit ) )
36
36
{
37
37
sanitizedUnit = GetUnit ( unit ) ;
38
38
@@ -86,9 +86,9 @@ public PrometheusMetric(string name, string unit, PrometheusType type, bool disa
86
86
87
87
public PrometheusType Type { get ; }
88
88
89
- public static PrometheusMetric Create ( Metric metric , bool disableTotalNameSuffixForCounters )
89
+ public static PrometheusMetric Create ( Metric metric , bool disableTotalNameSuffixForCounters , bool disableAppendingUnitName )
90
90
{
91
- return new PrometheusMetric ( metric . Name , metric . Unit , GetPrometheusType ( metric ) , disableTotalNameSuffixForCounters ) ;
91
+ return new PrometheusMetric ( metric . Name , metric . Unit , GetPrometheusType ( metric ) , disableTotalNameSuffixForCounters , disableAppendingUnitName ) ;
92
92
}
93
93
94
94
internal static string SanitizeMetricName ( string metricName )
0 commit comments