@@ -47,6 +47,8 @@ type Desc struct {
47
47
fqName string
48
48
// help provides some helpful information about this metric.
49
49
help string
50
+ // unit is a OpenMetrics unit.
51
+ unit string
50
52
// constLabelPairs contains precalculated DTO label pairs based on
51
53
// the constant labels.
52
54
constLabelPairs []* dto.LabelPair
@@ -76,7 +78,7 @@ type Desc struct {
76
78
// For constLabels, the label values are constant. Therefore, they are fully
77
79
// specified in the Desc. See the Collector example for a usage pattern.
78
80
func NewDesc (fqName , help string , variableLabels []string , constLabels Labels ) * Desc {
79
- return V2 .NewDesc (fqName , help , UnconstrainedLabels (variableLabels ), constLabels )
81
+ return V2 .NewDesc (fqName , help , "" , UnconstrainedLabels (variableLabels ), constLabels )
80
82
}
81
83
82
84
// NewDesc allocates and initializes a new Desc. Errors are recorded in the Desc
@@ -89,10 +91,14 @@ func NewDesc(fqName, help string, variableLabels []string, constLabels Labels) *
89
91
//
90
92
// For constLabels, the label values are constant. Therefore, they are fully
91
93
// specified in the Desc. See the Collector example for a usage pattern.
92
- func (v2 ) NewDesc (fqName , help string , variableLabels ConstrainableLabels , constLabels Labels ) * Desc {
94
+ func (v2 ) NewDesc (fqName , help , unit string , variableLabels ConstrainableLabels , constLabels Labels ) * Desc {
95
+ if variableLabels == nil {
96
+ variableLabels = UnconstrainedLabels (nil )
97
+ }
93
98
d := & Desc {
94
99
fqName : fqName ,
95
100
help : help ,
101
+ unit : unit ,
96
102
variableLabels : variableLabels .compile (),
97
103
}
98
104
if ! model .IsValidMetricName (model .LabelValue (fqName )) {
0 commit comments