mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
feat: return ct after finding it
Signed-off-by: Manik Rana <manikrana54@gmail.com>
This commit is contained in:
parent
7e8899241a
commit
03f2a90394
|
@ -21,6 +21,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math"
|
"math"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
|
@ -77,6 +78,7 @@ type OpenMetricsParser struct {
|
||||||
series []byte
|
series []byte
|
||||||
text []byte
|
text []byte
|
||||||
mtype model.MetricType
|
mtype model.MetricType
|
||||||
|
mName string
|
||||||
val float64
|
val float64
|
||||||
ts int64
|
ts int64
|
||||||
hasTS bool
|
hasTS bool
|
||||||
|
@ -234,19 +236,24 @@ func (p *OpenMetricsParser) CreatedTimestamp() *int64 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var labelsPrev labels.Labels
|
if newParser.mName != p.mName {
|
||||||
p.Metric(&labelsPrev)
|
|
||||||
namePrev := labelsPrev.Get(model.MetricNameLabel)
|
|
||||||
// a case like foo_total != foo_created fails even if underlying metric is the same
|
|
||||||
if namePrev != name {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if labelsets are the same
|
||||||
|
|
||||||
// TODO: for histograms
|
// TODO: for histograms
|
||||||
if t, _ := newParser.Next(); t != EntrySeries {
|
// if t, _ := newParser.Next(); t != EntrySeries {
|
||||||
|
// return nil
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return CT value
|
||||||
|
ctBytes := newParser.l.b[newParser.offsets[len(newParser.offsets)-1]+1:newParser.l.start]
|
||||||
|
ct, err := strconv.ParseInt(yoloString(ctBytes), 10, 64)
|
||||||
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
return &ct
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
// If not series, we don't care.
|
// If not series, we don't care.
|
||||||
|
@ -282,6 +289,7 @@ func (p *OpenMetricsParser) CreatedTimestamp() *int64 {
|
||||||
series :newSeries,
|
series :newSeries,
|
||||||
text :newText,
|
text :newText,
|
||||||
mtype :p.mtype,
|
mtype :p.mtype,
|
||||||
|
mName :p.mName,
|
||||||
val :p.val,
|
val :p.val,
|
||||||
ts :p.ts,
|
ts :p.ts,
|
||||||
hasTS :p.hasTS,
|
hasTS :p.hasTS,
|
||||||
|
@ -342,6 +350,7 @@ func (p *OpenMetricsParser) Next() (Entry, error) {
|
||||||
mEnd--
|
mEnd--
|
||||||
}
|
}
|
||||||
p.offsets = append(p.offsets, mStart, mEnd)
|
p.offsets = append(p.offsets, mStart, mEnd)
|
||||||
|
p.mName = string(p.l.b[mStart:mEnd])
|
||||||
default:
|
default:
|
||||||
return EntryInvalid, p.parseError("expected metric name after "+t.String(), t2)
|
return EntryInvalid, p.parseError("expected metric name after "+t.String(), t2)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue