Commit Graph

28 Commits (975d5d7357a220192fe1307b10ded9b35130ab1c)

Author SHA1 Message Date
György Krajcsovits eafe72a0d0 perf(nhcb): optimize away most allocations in convertnhcb
In general aim for the happy case when the exposer lists the buckets
in ascending order.

Use Compact(2) to compact the result of nhcb convert.

This is more in line with how client_golang optimizes spans vs
buckets.
aef8aedb4b/prometheus/histogram.go (L1485)

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2024-10-28 08:34:54 +01:00
George Krajcsovits eb3b349024
fix(nhcb): created timestamp fails when keeping classic histograms (#15218)
The wrong source was used to return the created timestamp, leading to
index out of bound panic. One line fix.

Refactor the requirement test to be generic and be able to
test OpenMetrics and Prom parsers as well.
There are some differencies in what the parsers support, the Prom
parser doesn't have created timestamp.

The protobuf parser uses different formatting to identify the metric
for the scrape loop.
Each parser represents the sample timestamp differently.

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2024-10-28 08:31:43 +01:00
George Krajcsovits 469573b13b
fix(nhcb): do not return nhcb from parse if exponential is present (#15209)
From: https://github.com/prometheus/prometheus/pull/14978#discussion_r1800755481
Also encode the requirement table set in #13532

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2024-10-24 18:14:05 +02:00
George Krajcsovits 2182b83271
feat(nhcb): implement created timestamp handling (#15198)
Call through to the underlaying parser if we are not in a histogram
and the entry is a series or exponential native histogram. Otherwise store
and retrieve CT for NHCB.

* fix(omparser): losing exemplars when CT is parsed

Fixes: #15137
Ignore exemplars while peeking ahead during CT parsing.
Simplify state reset with defer().

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2024-10-24 07:38:58 +02:00
George Krajcsovits aa81210c8b
NHCB scrape: refactor state handling and speed up scrape test (#15193)
* NHCB: scrape use state field and not booleans

From comment https://github.com/prometheus/prometheus/pull/14978#discussion_r1800898724

Also make compareLabels read only and move storeLabels to the first
processed classic histogram series.

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

* Speed up TestConvertClassicHistogramsToNHCB 3x

Reduce the startup time and timeouts

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

* lint fix

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

---------

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2024-10-22 17:49:25 +01:00
György Krajcsovits 8c1b5a6251 Merge branch 'main' into nhcb-scrape-impl 2024-10-21 11:00:41 +02:00
György Krajcsovits d930648afb Add doc string for NHCBParser
Very high level since we'll do a lot of optimizations so not
worth going into details at this time.

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2024-10-14 14:35:11 +02:00
György Krajcsovits c13585665d Merge branch 'main' into nhcb-scrape-impl
# Conflicts:
#	promql/promqltest/test.go
#	util/convertnhcb/convertnhcb.go
2024-10-14 14:26:11 +02:00
György Krajcsovits 9b5d7287bb Use labels hash to determine change in metric like CT
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2024-10-09 15:16:46 +02:00
György Krajcsovits 530e9514b7 Fix case of keeping classic series
Make it more obvious that the code in if had side effect.

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2024-10-09 13:08:54 +02:00
György Krajcsovits 8dfa733596 Fix labels handling with dedupelabels tag
Use scratch builder.
Use hash compare instead of compare by label.

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2024-10-09 12:29:59 +02:00
György Krajcsovits f3c8ed2947 minor fixes
Fix lint errors.
No need to pre-allocate exemplars.

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2024-10-09 11:45:31 +02:00
György Krajcsovits fbbf10baad Use the proper way to iterate labels
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2024-10-09 11:24:24 +02:00
György Krajcsovits 7fccf1e6be Disable CT handling and enable exemplar handling
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2024-10-09 11:08:08 +02:00
György Krajcsovits e931587bf8 Factor out label compare and store
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2024-10-08 10:12:25 +02:00
György Krajcsovits 16f28be713 Fix CT handling
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2024-10-07 16:59:07 +02:00
György Krajcsovits 6bebeaf41b Fix not checking all labels before deciding to store NHCB
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2024-10-07 15:41:54 +02:00
György Krajcsovits e1a7008b6c Add unit test nhcbparse_test.go
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2024-10-07 14:02:10 +02:00
György Krajcsovits 9c4816df36 Rename bType to bName as Type returns the binary name and not the type name
See Parser.Type() function.

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2024-10-07 11:31:43 +02:00
Jeanette Tan 97ba2fc39d use caps for NHCB
Signed-off-by: Jeanette Tan <jeanette.tan@grafana.com>
2024-09-25 13:38:30 +02:00
Jeanette Tan f35c6649e4 don't blindly convert series with the classic histogram name suffixes if they are not actually histograms based on metadata
Signed-off-by: Jeanette Tan <jeanette.tan@grafana.com>
2024-09-25 13:38:15 +02:00
Jeanette Tan e3899187da expand tests for protobuf and fix problems
Signed-off-by: Jeanette Tan <jeanette.tan@grafana.com>
2024-09-25 13:38:08 +02:00
Jeanette Tan cd498964e6 expand tests and support conversion to nhcb in the middle of scrape
Signed-off-by: Jeanette Tan <jeanette.tan@grafana.com>
2024-09-25 13:38:04 +02:00
Jeanette Tan 41c7f7d352 don't reuse the buffer
Signed-off-by: Jeanette Tan <jeanette.tan@grafana.com>
2024-09-25 13:38:01 +02:00
Jeanette Tan 57bde06d2c add doc comments
Signed-off-by: Jeanette Tan <jeanette.tan@grafana.com>
2024-09-25 13:37:56 +02:00
Jeanette Tan cbd5488cd3 skip nhcb conversion if there is native histogram of same name
Signed-off-by: Jeanette Tan <jeanette.tan@grafana.com>
2024-09-25 13:37:51 +02:00
Jeanette Tan 0e5072b873 keep only 1 nhcb in memory at at time
Signed-off-by: Jeanette Tan <jeanette.tan@grafana.com>
2024-09-25 13:37:46 +02:00
Jeanette Tan 172d4f2405 insert nhcb parser as intermediate layer
Signed-off-by: Jeanette Tan <jeanette.tan@grafana.com>
2024-09-25 13:37:37 +02:00