mirror of
https://github.com/prometheus/prometheus.git
synced 2026-05-28 04:02:21 -04:00
Fix linting and failing tests
Signed-off-by: Carrie Edwards <edwrdscarrie@gmail.com>
This commit is contained in:
parent
9f9e408405
commit
c13c6bc1f5
2 changed files with 10 additions and 14 deletions
|
|
@ -3659,7 +3659,7 @@ func TestTypeUnitMismatchAnnotations(t *testing.T) {
|
|||
typeAndUnitLabelsEnabled: true,
|
||||
expectedWarningAnnotations: []string{},
|
||||
expectedInfoAnnotations: []string{
|
||||
`PromQL info: mismatched type or unit metadata "series"`,
|
||||
`PromQL info: mismatched type or unit metadata for metric "series"`,
|
||||
},
|
||||
},
|
||||
"info annotation when mismatched unit": {
|
||||
|
|
@ -3671,7 +3671,7 @@ func TestTypeUnitMismatchAnnotations(t *testing.T) {
|
|||
typeAndUnitLabelsEnabled: true,
|
||||
expectedWarningAnnotations: []string{},
|
||||
expectedInfoAnnotations: []string{
|
||||
`PromQL info: mismatched type or unit metadata "series"`,
|
||||
`PromQL info: mismatched type or unit metadata for metric "series"`,
|
||||
},
|
||||
},
|
||||
"info annotation when mismatched type and unit": {
|
||||
|
|
@ -3683,7 +3683,7 @@ func TestTypeUnitMismatchAnnotations(t *testing.T) {
|
|||
typeAndUnitLabelsEnabled: true,
|
||||
expectedWarningAnnotations: []string{},
|
||||
expectedInfoAnnotations: []string{
|
||||
`PromQL info: mismatched type or unit metadata "series"`,
|
||||
`PromQL info: mismatched type or unit metadata for metric "series"`,
|
||||
},
|
||||
},
|
||||
"no info annotation when type is unknown": {
|
||||
|
|
|
|||
|
|
@ -90,18 +90,14 @@ func (s *typeAndUnitMismatchSeriesSet) Next() bool {
|
|||
typ: mType,
|
||||
unit: mUnit,
|
||||
}
|
||||
} else {
|
||||
if s.prev.typ != mType || s.prev.unit != mUnit {
|
||||
// Skip annotation if either type is "unknown" - this allows unknown to coexist with known types
|
||||
if s.prev.typ == "unknown" || mType == "unknown" {
|
||||
// Update to the known type if we have one
|
||||
if s.prev.typ == "unknown" && mType != "unknown" {
|
||||
s.prev.typ = mType
|
||||
s.prev.unit = mUnit
|
||||
}
|
||||
} else {
|
||||
s.annotations.Add(fmt.Errorf("%w for metric %q", annotations.MismatchedTypeOrUnitInfo, metric))
|
||||
} else if s.prev.typ != mType || s.prev.unit != mUnit {
|
||||
if s.prev.typ == "unknown" || mType == "unknown" {
|
||||
if s.prev.typ == "unknown" && mType != "unknown" {
|
||||
s.prev.typ = mType
|
||||
s.prev.unit = mUnit
|
||||
}
|
||||
} else {
|
||||
s.annotations.Add(fmt.Errorf("%w for metric %q", annotations.MismatchedTypeOrUnitInfo, metric))
|
||||
}
|
||||
}
|
||||
return true
|
||||
|
|
|
|||
Loading…
Reference in a new issue