Commit Graph

146 Commits (90e832c861df33e17b7240ddf1d57441860953dd)

Author SHA1 Message Date
Bartlomiej Plotka 619e7aaf95
Merge pull request #15453 from prometheus/nhcb-scrape-optimize2
nhcb: scrape optimize string manipulation
2024-11-26 09:02:43 -07:00
Bartlomiej Plotka 11d9da1e48
Merge pull request #15260 from tcolgate/quoteexemplarkeys
bugfix: allow quoted exemplar keys in openmetrics text format
2024-11-26 02:52:17 -07:00
György Krajcsovits a48d05912d nhcb: optimize, do not recalculate suffixes multiple times
Reduce string manipulation by just cutting off the histogram suffixes from
the series name label once.

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2024-11-25 15:37:38 +01:00
huochexizhan 4f48e76086 chore: fix some function names in comment
Signed-off-by: huochexizhan <huochexizhan@outlook.com>
2024-11-19 12:02:10 +08:00
Tristan Colgate-McFarlane 48abdcd83f
bugfix: allow quoted exemplar keys in openmetrics text format
Signed-off-by: Tristan Colgate-McFarlane <tristan@cerbos.dev>
2024-11-12 15:29:44 +00:00
Bartlomiej Plotka 76432aaf4e
Merge pull request #15220 from prometheus/nhcb-scrape-optimize
perf(nhcb): scrape optimize
2024-11-08 19:02:48 +01:00
Matthieu MOREL af1a19fc78 enable errorf rule from perfsprint linter
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-11-06 16:50:36 +01:00
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 25ef4d3483 benchmark, rename parser omtext_with_nhcb
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2024-10-21 15:40:48 +02:00
György Krajcsovits bee1eb7720 goimports run
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2024-10-21 14:02:32 +02:00
György Krajcsovits 555bd6292a Better docstring on test
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2024-10-21 13:48:21 +02:00
György Krajcsovits a6947e1e6d Remove omcounterdata.txt as redundant
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2024-10-21 13:45:33 +02:00
György Krajcsovits eaee6bacc7 Fix failing benchmarks
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2024-10-21 13:40:16 +02:00
György Krajcsovits 5ee0980cd1 Add unit test to show that current wrapper is sub-optimal
https://github.com/prometheus/prometheus/pull/14978#discussion_r1800755481

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2024-10-21 13:35:33 +02:00
György Krajcsovits 482bb453c6 Followup to #15164
Update test cases

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2024-10-21 11:03:07 +02:00
György Krajcsovits 8c1b5a6251 Merge branch 'main' into nhcb-scrape-impl 2024-10-21 11:00:41 +02:00
Ayoub Mrini d8c1605930
Merge pull request #15164 from machine424/quantile
feat: normalize "le" and "quantile" labels values upon ingestion
2024-10-19 21:13:03 +02:00
machine424 8bcb4d865d
feat: normalize "le" and "quantile" labels values upon ingestion
Signed-off-by: machine424 <ayoubmrini424@gmail.com>

Co-authored-by: beorn7 <beorn@grafana.com>
2024-10-18 17:37:29 +02:00
Alex Greenbank 421a3c22ea
scrape: provide a fallback format (#15136)
scrape: Remove implicit fallback to the Prometheus text format

Remove implicit fallback to the Prometheus text format in case of invalid/missing Content-Type and fail the scrape instead. Add ability to specify a `fallback_scrape_protocol` in the scrape config.

---------

Signed-off-by: alexgreenbank <alex.greenbank@grafana.com>
Signed-off-by: Alex Greenbank <alex.greenbank@grafana.com>
Co-authored-by: Björn Rabenstein <beorn@grafana.com>
2024-10-18 17:12:31 +02:00
machine424 18b81ad79d
feat: ProtobufParse.formatOpenMetricsFloat: improve float formatting by using strconv.AppendFloat instead of fmt.Sprint
Signed-off-by: machine424 <ayoubmrini424@gmail.com>
2024-10-18 15:19:55 +02:00
György Krajcsovits 5ee698de2c Apply review comments
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2024-10-17 12:55:45 +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
Manik Rana c3b8582cf4
[PERF] textparse: optimize OM `p.isCreatedSeries()` (#15150)
* refac: remove p.Metric usage

Signed-off-by: Manik Rana <manikrana54@gmail.com>

* perf: use bytes instead of strings

Signed-off-by: Manik Rana <manikrana54@gmail.com>

* chore: comments

Signed-off-by: Manik Rana <Manikrana54@gmail.com>

---------

Signed-off-by: Manik Rana <manikrana54@gmail.com>
Signed-off-by: Manik Rana <Manikrana54@gmail.com>
2024-10-14 10:18:15 +01:00
George Krajcsovits a1700aab3a
Apply suggestions from code review
Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
Signed-off-by: George Krajcsovits <krajorama@users.noreply.github.com>
2024-10-14 11:13:58 +02:00
György Krajcsovits 0a40a09da5 Use const instead of -53
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2024-10-14 11:09:03 +02:00
Manik Rana 032ca9ef96
[PERF] textparse: further optimzations for OM `CreatedTimestamps` (#15097)
* feat: Added more tests; some changes/optimizations when pair-programming with Bartek.

Signed-off-by: Manik Rana <manikrana54@gmail.com>

* chore: imports

Signed-off-by: Manik Rana <manikrana54@gmail.com>

* chore: gofumpt

Signed-off-by: Manik Rana <manikrana54@gmail.com>

* feat: use an efficient replacement to p.Metric

Signed-off-by: Manik Rana <manikrana54@gmail.com>

* feat: reduce mem allocs + comments

Signed-off-by: Manik Rana <manikrana54@gmail.com>

* chore: gofumpt

Signed-off-by: Manik Rana <manikrana54@gmail.com>

* chore: use single quotes

Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
Signed-off-by: Manik Rana <Manikrana54@gmail.com>

* refac: rename

Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
Signed-off-by: Manik Rana <Manikrana54@gmail.com>

* refac: rename to seriesHash

Signed-off-by: Manik Rana <manikrana54@gmail.com>

* refac: switch condition order

Co-authored-by: George Krajcsovits <krajorama@users.noreply.github.com>
Signed-off-by: Manik Rana <Manikrana54@gmail.com>

* refac: switch condition order

Co-authored-by: George Krajcsovits <krajorama@users.noreply.github.com>
Signed-off-by: Manik Rana <Manikrana54@gmail.com>

* feat: stronger checking

Co-authored-by: George Krajcsovits <krajorama@users.noreply.github.com>
Signed-off-by: Manik Rana <Manikrana54@gmail.com>

* chore: fmt

Signed-off-by: Manik Rana <manikrana54@gmail.com>

* refac: pass pointer of buf into seriesHash()

Signed-off-by: Manik Rana <manikrana54@gmail.com>

---------

Signed-off-by: Manik Rana <manikrana54@gmail.com>
Signed-off-by: Manik Rana <Manikrana54@gmail.com>
Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
Co-authored-by: George Krajcsovits <krajorama@users.noreply.github.com>
2024-10-10 12:01:13 +01: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 14f92319d9 Add basic benchmark cases for NHCB over OM
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2024-10-09 15:16:27 +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 2a3aa500e9 Make nhcb unit test pass with many exceptions marked as TODOs
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2024-10-07 14:27:23 +02:00
György Krajcsovits e0444d9384 Merge branch 'main' into nhcb-scrape-impl 2024-10-07 14:02:46 +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
Bartlomiej Plotka f6e110d588
textparse: Refactored main testing utils for reusability; fixed proto Units. (#15095)
Signed-off-by: bwplotka <bwplotka@gmail.com>
2024-10-07 12:17:44 +01: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
György Krajcsovits ed2e7dc258 Merge branch 'main' into nhcb-scrape-impl
# Conflicts:
#	scrape/scrape.go
2024-10-07 11:23:44 +02:00
Bartlomiej Plotka 8d281c3491
textparse: Refactored benchmark (#15083)
* textparse: Refactored benchmark.

Signed-off-by: bwplotka <bwplotka@gmail.com>

* Kill sinks, tested, nothing is inlined.

Signed-off-by: bwplotka <bwplotka@gmail.com>

* Addressed comments.

Signed-off-by: bwplotka <bwplotka@gmail.com>

---------

Signed-off-by: bwplotka <bwplotka@gmail.com>
2024-10-07 09:55:26 +01:00
Matthieu MOREL ab64966e9d
fix: use "ErrorContains" or "EqualError" instead of "Contains(t, err.Error()" and "Equal(t, err.Error()" (#15094)
* fix: use "ErrorContains" or "EqualError" instead of "Contains(t, err.Error()" and "Equal(t, err.Error()"

---------

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
2024-10-06 16:35:29 +00:00
Manik Rana 47aeca9663
feat: naive fixes and optimzations for `CreatedTimestamp` function (#14965)
* enhance: wip ct parse optimizations

Signed-off-by: Manik Rana <manikrana54@gmail.com>

* feat: further work on optimization

Signed-off-by: Manik Rana <manikrana54@gmail.com>

* feat: further improvements and remove unused code

Signed-off-by: Manik Rana <manikrana54@gmail.com>

* feat: improve optimizations and fix some CT parse errors

Signed-off-by: Manik Rana <manikrana54@gmail.com>

* fix: check for LsetHash along with name

Signed-off-by: Manik Rana <manikrana54@gmail.com>

* chore: cleanup and documentation

Signed-off-by: Manik Rana <manikrana54@gmail.com>

* enhance: improve comments and add cleaner functions

Signed-off-by: Manik Rana <manikrana54@gmail.com>

* feat: improve comments and add cleaner functions

Signed-off-by: Manik Rana <manikrana54@gmail.com>

* chore: rename to resetCTParseValues

Signed-off-by: Manik Rana <manikrana54@gmail.com>

* fix: post-merge fixes

Signed-off-by: Manik Rana <manikrana54@gmail.com>

* fix: add all possible reserved suffixes

Signed-off-by: Manik Rana <manikrana54@gmail.com>

* test: separate CT values for each metric

Signed-off-by: Manik Rana <manikrana54@gmail.com>

---------

Signed-off-by: Manik Rana <manikrana54@gmail.com>
Signed-off-by: Manik Rana <Manikrana54@gmail.com>
2024-10-04 13:11:02 +01:00