On some GOOS (e.g. dragonfly), statfs.Blocks is int64, which can
cause a type mismatch when multiplied with Bsize. Cast both operands to
uint64 explicitly.
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
Initial implementation of https://github.com/prometheus/prometheus/issues/17790.
Only implements ST-per-sample for Counters. Tests and benchmarks updated.
Note: This increases the size of the RefSample object for all users, whether st-per-sample is turned on or not.
Signed-off-by: Owen Williams <owen.williams@grafana.com>
Parser configuration is now per-engine/API/loader and no longer uses package-level flags, so behavior is consistent and tests don't rely on save/restore of global variables.
Signed-off-by: Martin Valiente Ainz <64830185+tinitiuset@users.noreply.github.com>
As for float samples, Kahan summation is used for the `sum` and `avg` aggregation and for the respective `_over_time` functions.
Kahan summation is not perfect. This commit also adds tests that even Kahan summation cannot reliably pass.
These tests are commented out.
Note that the behavior might be different on other hardware platforms. We have to keep an eye on test failing on other hardware platforms and adjust them accordingly.
Signed-off-by: Aleksandr Smirnov <5targazer@mail.ru>
* fix(teststorage/appender.go): TODO and Sample staleness check
Allow different order of consecutive stale samples between the expected
and actual array for RequireEqual and RequireNotEqual by trying to
swap the expected side until it matches.
Also fix the definition of stale sample in the test, it's not only
float, but defined for native histograms as well.
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
* add unit tests
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
---------
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
testutil.T was needed before https://go.dev/doc/go1.13#testingpkgtesting
Now it's inconsistent and confusing, so let's kill it.
Signed-off-by: bwplotka <bwplotka@gmail.com>
Fix two issues in fuzzing infrastructure:
- Correct artifact upload path from promql/testdata/fuzz to util/fuzzing/testdata/fuzz to match where Go stores crash artifacts
- Fix GetCorpusForFuzzParseExpr to preserve original parser flag values instead of always resetting them to false, which was disabling experimental features before actual fuzzing ran
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
- Added comprehensive edge case tests for SanitizeLabelName (10 cases)
- Added comprehensive edge case tests for SanitizeFullLabelName (15 cases)
- Added more test cases for link generation functions (4 additional cases)
- Fixed unicode test case: corrected expected underscores from 7 to 5
- Fixed digits test case: corrected expected output from '_____' to '_2345'
- Converted tests to table-driven format with named subtests
- Achieved 100% code coverage for the package
Signed-off-by: Ritik Shukla <ritikshukla@Ritiks-MacBook-Air.local>
* tsdb: add support for OOO exemplars in CircularExemplarStorage
Doubly linked exemplar storage resize.
Split exemplar buffer resize into shrink and grow functions.
Skip duplicate OOO exemplars, re-initialize emptied index after deleting its last exemplar.
Signed-off-by: Julius Hinze <julius.hinze@grafana.com>
- Emit `Vary: Accept-Encoding` in newCompressedResponseWriter so shared caches
key responses by content-coding. This prevents cache poisoning and
undecodable bytes when a compressed variant is cached and later served to a
client that didn't advertise support. (RFC 9110 §12.5.5 "Vary";
RFC 9111 §4.1 cache key & Vary)
- When selecting gzip/deflate, set `Content-Encoding` and delete any existing
`Content-Length` so Go's net/http can frame the message correctly
(chunked for HTTP/1.1; implicit for HTTP/2+). This avoids stale length
mismatches and related proxy/client issues.
Signed-off-by: Joshua Rogers <MegaManSec@users.noreply.github.com>