chore: comments

Signed-off-by: Manik Rana <manikrana54@gmail.com>
This commit is contained in:
Manik Rana 2024-08-06 11:01:35 +05:30
parent 11aeea2d4e
commit 3e66526214

View file

@ -263,8 +263,8 @@ func (p *OpenMetricsParser) CreatedTimestamp() *int64 {
peekWithoutNameLsetHash uint64 peekWithoutNameLsetHash uint64
) )
p.Metric(&currLset) p.Metric(&currLset)
currWithoutNameLsetHash, buf := currLset.HashWithoutLabels(buf, labels.MetricName, "le", "quantile") currFamilyLsetHash, buf := currLset.HashWithoutLabels(buf, labels.MetricName, "le", "quantile")
// Search for the _created line for the currName using ephemeral parser until // Search for the _created line for the currFamilyLsetHash using ephemeral parser until
// we see EOF or new metric family. We have to do it as we don't know where (and if) // we see EOF or new metric family. We have to do it as we don't know where (and if)
// that CT line is. // that CT line is.
// TODO(bwplotka): Make sure OM 1.1/2.0 pass CT via metadata or exemplar-like to avoid this. // TODO(bwplotka): Make sure OM 1.1/2.0 pass CT via metadata or exemplar-like to avoid this.
@ -272,7 +272,7 @@ func (p *OpenMetricsParser) CreatedTimestamp() *int64 {
for { for {
eType, err := peek.Next() eType, err := peek.Next()
if err != nil { if err != nil {
// This means p will give error too later on, so def no CT line found. // This means peek will give error too later on, so def no CT line found.
// This might result in partial scrape with wrong/missing CT, but only // This might result in partial scrape with wrong/missing CT, but only
// spec improvement would help. // spec improvement would help.
// TODO(bwplotka): Make sure OM 1.1/2.0 pass CT via metadata or exemplar-like to avoid this. // TODO(bwplotka): Make sure OM 1.1/2.0 pass CT via metadata or exemplar-like to avoid this.
@ -282,8 +282,7 @@ func (p *OpenMetricsParser) CreatedTimestamp() *int64 {
// Assume we hit different family, no CT line found. // Assume we hit different family, no CT line found.
return nil return nil
} }
// We are sure this series is the same metric family as in currLset
// because otherwise we would have EntryType first which we ruled out before.
var peekedLset labels.Labels var peekedLset labels.Labels
peek.Metric(&peekedLset) peek.Metric(&peekedLset)
peekedName := peekedLset.Get(model.MetricNameLabel) peekedName := peekedLset.Get(model.MetricNameLabel)
@ -294,7 +293,7 @@ func (p *OpenMetricsParser) CreatedTimestamp() *int64 {
// We got a CT line here, but let's search if CT line is actually for our series, edge case. // We got a CT line here, but let's search if CT line is actually for our series, edge case.
peekWithoutNameLsetHash, _ = peekedLset.HashWithoutLabels(buf, labels.MetricName, "le", "quantile") peekWithoutNameLsetHash, _ = peekedLset.HashWithoutLabels(buf, labels.MetricName, "le", "quantile")
if peekWithoutNameLsetHash != currWithoutNameLsetHash { if peekWithoutNameLsetHash != currFamilyLsetHash {
// CT line for a different series, for our series no CT. // CT line for a different series, for our series no CT.
return nil return nil
} }