Skip to content

Commit c0ea965

Browse files
committed
Remove redundant tests and comments for OM creation
Signed-off-by: Arianna Vespri <arianna.vespri@yahoo.it>
1 parent 57cda4a commit c0ea965

2 files changed

Lines changed: 3 additions & 41 deletions

File tree

expfmt/openmetrics_create.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ func WithCreatedLines() EncoderOption {
5050
}
5151
}
5252

53-
54-
5553
// MetricFamilyToOpenMetrics converts a MetricFamily proto message into the
5654
// OpenMetrics text format and writes the resulting lines to 'out'. It returns
5755
// the number of bytes written and any error encountered. The output will have
@@ -89,15 +87,6 @@ func WithCreatedLines() EncoderOption {
8987
// its type will be set to `unknown` in that case to avoid invalid OpenMetrics
9088
// output.
9189
//
92-
// - According to the OM specs, the `# UNIT` line is optional, but if populated,
93-
// the unit has to be present in the metric name as its suffix:
94-
// (see https://github.com/prometheus/OpenMetrics/blob/v1.0.0/specification/OpenMetrics.md#unit).
95-
// However, in order to accommodate any potential scenario where such a change in the
96-
// metric name is not desirable, the users are here given the choice of either explicitly
97-
// opt in, in case they wish for the unit to be included in the output AND in the metric name
98-
// as a suffix (see the description of the WithUnit function above),
99-
// or not to opt in, in case they don't want for any of that to happen.
100-
//
10190
// - No support for the following (optional) features: info type,
10291
// stateset type, gaugehistogram type.
10392
//
@@ -141,7 +130,6 @@ func MetricFamilyToOpenMetrics(out io.Writer, in *dto.MetricFamily, options ...E
141130
if metricType == dto.MetricType_COUNTER && strings.HasSuffix(compliantName, "_total") {
142131
compliantName = name[:len(name)-6]
143132
}
144-
145133

146134
// Comments, first HELP, then TYPE.
147135
if in.Help != nil {

expfmt/openmetrics_create_test.go

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ foos_total 42.0
619619
# UNIT name_seconds seconds
620620
`,
621621
},
622-
// 15: Histogram plus unit, but unit not opted in.
622+
// 15: Histogram plus unit
623623
{
624624
in: &dto.MetricFamily{
625625
Name: proto.String("request_duration_microseconds"),
@@ -669,33 +669,7 @@ request_duration_microseconds_sum 1.7560473e+06
669669
request_duration_microseconds_count 2693
670670
`,
671671
},
672-
// 16: No metric, unit opted in, no unit in name.
673-
{
674-
in: &dto.MetricFamily{
675-
Name: proto.String("name_total"),
676-
Help: proto.String("doc string"),
677-
Type: dto.MetricType_COUNTER.Enum(),
678-
Unit: proto.String("seconds"),
679-
Metric: []*dto.Metric{},
680-
},
681-
out: `# HELP name doc string
682-
# TYPE name counter
683-
# UNIT name seconds
684-
`,
685-
},
686-
// 17: No metric, unit opted in, BUT unit == nil.
687-
{
688-
in: &dto.MetricFamily{
689-
Name: proto.String("name_total"),
690-
Help: proto.String("doc string"),
691-
Type: dto.MetricType_COUNTER.Enum(),
692-
Metric: []*dto.Metric{},
693-
},
694-
out: `# HELP name doc string
695-
# TYPE name counter
696-
`,
697-
},
698-
// 18: Counter, timestamp given, unit opted in, _total suffix.
672+
// 16: Counter, timestamp given, unit given, _total suffix.
699673
{
700674
in: &dto.MetricFamily{
701675
Name: proto.String("some_measure_total"),
@@ -743,7 +717,7 @@ some_measure_total{labelname="val1",basename="basevalue"} 42.0
743717
some_measure_total{labelname="val2",basename="basevalue"} 0.23 1.23456789e+06
744718
`,
745719
},
746-
// 11: Gauge histogram.
720+
// 17: Gauge histogram.
747721
{
748722
in: &dto.MetricFamily{
749723
Name: proto.String("name"),

0 commit comments

Comments
 (0)