prometheus/model/labels
George Krajcsovits acd9aa0afb
fix(textparse/protobuf): metric family name corrupted by NHCB parser (#17156)
* fix(textparse): implement NHCB parsing in ProtoBuf parser directly

The NHCB conversion does some validation, but we can only return error
from Parser.Next() not Parser.Histogram(). So the conversion needs to
happen in Next().

There are 2 cases:
1. "always_scrape_classic_histograms" is enabled, in which case we
convert after returning the classic series. This is to be consistent
with the PromParser text parser, which collects NHCB while spitting out
classic series; then returns the NHCB.
2. "always_scrape_classic_histograms" is disabled. In which case we never
return the classic series.

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>

* refactor(textparse): skip classic series instead of adding NHCB around

Do not return the first classic series from the EntryType state,
switch to EntrySeries. This means we need to start the histogram
field state from -3 , not -2.

In EntrySeries, skip classic series if needed.

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>

* reuse nhcb converter

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>

* test(textparse/nhcb): test corrupting metric family name

NHCB parse doesn't always copy the metric name from the underlying
parser. When called via HELP, UNIT, the string is directly referenced
which means that the read-ahead of NHCB can corrupt it.

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2025-09-08 17:26:41 +02:00
..
labels_common.go fix(textparse/protobuf): metric family name corrupted by NHCB parser (#17156) 2025-09-08 17:26:41 +02:00
labels_dedupelabels.go fix(ci): run linter with all build tags (#17027) 2025-08-08 09:43:41 +00:00
labels_dedupelabels_test.go Add ByteSize method for Labels (#16717) 2025-07-04 15:09:01 +01:00
labels_slicelabels.go fix(ci): run linter with all build tags (#17027) 2025-08-08 09:43:41 +00:00
labels_slicelabels_test.go Add ByteSize method for Labels (#16717) 2025-07-04 15:09:01 +01:00
labels_stringlabels.go chore: enable unused-receiver rule from revive 2025-08-04 09:43:33 +00:00
labels_stringlabels_test.go Add ByteSize method for Labels (#16717) 2025-07-04 15:09:01 +01:00
labels_test.go Replace gopkg.in/yaml.v2 with go.yaml.in/yaml/v2 (#17151) 2025-09-06 13:04:24 +02:00
matcher.go Fix Matcher.String() with empty label name 2024-06-13 18:46:35 +02:00
matcher_test.go Quote label name in matchers when needed 2024-05-08 16:58:51 +02:00
regexp.go chore: enable unused-receiver rule from revive 2025-08-04 09:43:33 +00:00
regexp_test.go Apply analyzer "modernize" to the whole codebase 2025-08-27 14:48:41 +02:00
sharding.go Use stringlabels by default 2025-04-15 17:52:24 +01:00
sharding_dedupelabels.go Labels: use single byte as separator - small speedup 2024-07-15 09:47:16 +01:00
sharding_stringlabels.go Use stringlabels by default 2025-04-15 17:52:24 +01:00
sharding_test.go Add ShardedPostings() support to TSDB (#10421) 2024-01-29 11:57:27 +00:00
test_utils.go Labels: Call NewScratchBuilder in test_utils 2024-02-23 13:50:27 +00:00