Commit Graph

169 Commits

Author SHA1 Message Date
Gregor Jasny cfa3ecb1ed feat: don't create temporary objects for serialization
Fix: #646
2023-12-28 21:41:06 +01:00
Gregor Jasny 48f75a87b8 test(core): add more tests 2023-12-28 19:15:15 +01:00
Gregor Jasny 8de5a69691 chore(core): use hidden friends 2023-12-28 13:39:49 +01:00
Gregor Jasny 540a5a5224 feat(core): optimize add
Fixes #671
2023-12-19 18:24:29 +01:00
Gregor Jasny 3eca7c6e21 fix(push): encode push labels
Fixes #652
2023-12-19 18:22:18 +01:00
Kadayam, Harihara(hkadayam) 1833c1848c core: Add Reset APIs to histogram and counters 2023-02-09 21:02:12 +01:00
Romain Geissler 66e60b47c3 Use std::atomic::fetch_add in modern C++. 2022-12-09 10:19:12 +01:00
Gregor Jasny 89e79f2003 build: revert back to C++11
There seem to be many poor souls stuck to C++11. Because we
don't really depend on C++14 features let's wait for a reason
to bump up the standard to C++17 or later.

Close: #619
Fix: #618
Fix: #615
2022-11-28 22:41:49 +01:00
Johnny Jazeix 2ce3bb011e feat(core): Add Info metric 2022-06-18 14:36:33 +02:00
Gregor Jasny 40f64290ff test(core): prevent rotation on slow CPUs
The Debian Sparc64 builds fail because the expected values
were not within their range:

```
[ RUN      ] SummaryTest.quantile_values
 /home/gjasny/prometheus-cpp/core/tests/summary_test.cc:68: Failure
The difference between s.quantile.at(0).value and 0.5 * SAMPLES is 317823, which exceeds 0.05 * SAMPLES, where
s.quantile.at(0).value evaluates to 817823,
0.5 * SAMPLES evaluates to 500000, and
0.05 * SAMPLES evaluates to 50000.
/home/gjasny/prometheus-cpp/core/tests/summary_test.cc:69: Failure
The difference between s.quantile.at(1).value and 0.9 * SAMPLES is 63818, which exceeds 0.01 * SAMPLES, where
s.quantile.at(1).value evaluates to 963818,
0.9 * SAMPLES evaluates to 900000, and
0.01 * SAMPLES evaluates to 10000.
/home/gjasny/prometheus-cpp/core/tests/summary_test.cc:70: Failure
The difference between s.quantile.at(2).value and 0.99 * SAMPLES is 6685, which exceeds 0.001 * SAMPLES, where
s.quantile.at(2).value evaluates to 996685,
0.99 * SAMPLES evaluates to 990000, and
0.001 * SAMPLES evaluates to 1000.
[  FAILED  ] SummaryTest.quantile_values (152010 ms)
```

The reason was that the TimeWindowQuantiles rotated through
the buckets due to the long runtime.
2022-05-20 22:21:58 +02:00
Gregor Jasny 1236f09eb4 fix: handle absolute paths in pkgconfig files
Fixes: #587
2022-05-20 10:31:39 +02:00
Gregor Jasny 47868f9729 ci: fix iwyu 2022-05-19 22:25:07 +02:00
Gregor Jasny bac072291a fix(core): reject invalid label names 2022-04-06 20:57:34 +02:00
Gregor Jasny d647b6f42d fix: fix issues found by CLion static analyzer 2022-04-06 20:48:01 +02:00
Gregor Jasny 20c468b6bd build: require C++14 2022-04-03 21:36:54 +02:00
Gregor Jasny c3a8d07f0b docs(core): add Doxygen comments to new functions 2022-04-03 20:22:17 +02:00
Stephane Janel d81fd3b03c Add new constructor for Histogram and Summary taking rvalue ref of parameters 2022-04-03 19:07:54 +02:00
Stephane Janel 4d668074b0 Binary search for bucket boundaries in Histogram::Observe 2022-04-03 14:41:39 +02:00
Leith Bade e1c9c0c59f Fix incorrect doc reference to "counter" in histogram.h 2022-03-30 17:28:32 +02:00
Leith Bade 1707ea40fc Set clang-format to always left align references and pointers 2022-03-30 17:28:03 +02:00
Leith Bade 47838c7587 Add missing std:: on size_t 2022-03-30 08:31:00 +02:00
Gregor Jasny 86bf360095 core: enforce requirements on bucket boundaries 2022-03-29 22:00:33 +02:00
Gregor Jasny d8b3aa929d feat(core): Allow to remove a Family from their Registry
Fixes: #498
2021-11-15 21:29:22 +01:00
Gregor Jasny 91dd416d76 chore(core): Introduce Labels type 2021-11-14 18:17:14 +01:00
Gregor Jasny 3202b37020 feat(core)!: remove nonstandard append mode 2021-11-14 17:41:37 +01:00
Gregor Jasny 1b01f36156 fix(core): gracefully handle label hash collisions
```
before:

BM_Registry_CreateFamily             49.2 ns         49.0 ns     11087352
BM_Registry_CreateCounter/0           165 ns          165 ns      4170191
BM_Registry_CreateCounter/1          1967 ns         1958 ns       556346
BM_Registry_CreateCounter/8          4280 ns         4269 ns       176711
BM_Registry_CreateCounter/64        27091 ns        27009 ns        25755
BM_Registry_CreateCounter/512      224201 ns       223581 ns         3023
BM_Registry_CreateCounter/4096    2056280 ns      2049876 ns          330

after:

BM_Registry_CreateFamily             47.8 ns         47.8 ns     15131733
BM_Registry_CreateCounter/0           158 ns          158 ns      4295006
BM_Registry_CreateCounter/1          1009 ns         1009 ns      1169219
BM_Registry_CreateCounter/8          3238 ns         3231 ns       203179
BM_Registry_CreateCounter/64        25989 ns        25949 ns        27008
BM_Registry_CreateCounter/512      211288 ns       211220 ns         3265
BM_Registry_CreateCounter/4096    1960240 ns      1959743 ns          350
```

Fixes: #532
2021-11-13 11:57:49 +01:00
Gregor Jasny 1d4e4649c3 docs(core): Document atomic increment
Issue: #293
Issue: #526
Issue: #531
2021-11-12 08:51:52 +01:00
Gregor Jasny a3e4d4289d chore(clang-tidy): Fix cppcoreguidelines-special-member-functions 2021-11-12 08:33:56 +01:00
Gregor Jasny f35499ba5b chore(clang-tidy): Fix modernize-use-override 2021-11-12 08:33:56 +01:00
Gregor Jasny 755f8424d3 fix(clang-tidy): Fix errors detected by clang-tidy 2021-11-12 08:33:56 +01:00
Tim Wynants 722fbcf186 fix: there is a race condition when pushing and collecting histogram data
All increment counters and the total could be changed by an other threads is preparing the cumulative data collection.
2021-10-14 19:34:13 +02:00
Ashish Yadav 342de5e93b fix(core): Locale-independent floating-point serialization
Fixes: #509
2021-09-09 17:56:07 +02:00
Gregor Jasny 952c6bcdfe ci: Run iwyu 8.16 from Debian Experimental 2021-07-22 07:56:33 +02:00
Gregor Jasny 8400b647f4 chore: add missing include for iwyu 2021-06-14 10:07:54 +02:00
Pavel Pimenov 2ef7d1f893 Add const/reserve (#495)
Co-authored-by: pavel pimenov <pimenov_pa@nlmk.com>
2021-05-15 08:02:41 -07:00
Jupp Mueller 5522e6f89e Make summary quantiles non-const (#493)
This change removes an unnecessary API constraint that makes it
harder to dynamically construct quantile configurations for summaries.

Fixes #425
2021-05-14 14:18:23 -07:00
Sebastian Woetzel 1e00fd6043 core: add method to query family if metric exists (#482)
If metrics are dynamically added and removed to and from a family in a
RAAI way, there must only be only owner of the reference returned by the
family.Add method. To allow this we need to know if a metric with
specific labels already exist within the family.

Co-authored-by: Sebastian Woetzel <sebastian.woetzel@meetwise.com>
2021-05-03 07:11:47 -07:00
Gregor Jasny 2412990ee9 core: avoid collecting empty metric families 2021-03-09 13:21:22 +01:00
Gregor Jasny 1d36d42210 core: Replace name check regex (#462)
* core: test for more invalid lables

* core: rewrite label and metric name checks

The std::regex has the problem that it is not available everywhere
and also it's 75 times slower than the naive validity check.

```
BM_Label_Check_Regex          550 ns          550 ns      1270601
BM_Label_Check_NoRegex       7.50 ns         7.50 ns     92802503
```
2021-03-08 11:29:25 -08:00
Gregor Jasny 77b06a8709 core: reject duplicate label names (#463)
Issue: #459
2021-03-08 11:28:04 -08:00
Gregor Jasny 5699348faa feat(cmake): Generate pkg-config files
Fixes: #447
2021-03-04 21:15:31 +01:00
Gregor Jasny f448b2c3de feat(iwyu): Organize includes with include-what-you-use 2021-03-03 22:11:10 +01:00
Gregor Jasny 58141879f6 core: Fix usage of std::to_chars 2021-02-05 12:56:29 +01:00
Gregor Jasny bf0ddfc57b fix: use printf %g or std::to_chars to serialize doubles
This will result in floating point numbers redered with the
necessary precision and avoids trailing zeroes.

Closes: #441
2021-01-10 00:31:14 +01:00
Gregor Jasny 8a74501158 Merge pull request #442 from LesnyRumcajs/add-missing-include
Added missing include
2021-01-05 05:18:33 +01:00
Hubert Bugaj e0cc7b5e3e Added missing include 2021-01-04 13:04:48 +01:00
Gregor Jasny 813a44477d chore: remove extra block 2020-12-14 20:10:29 +01:00
Gregor Jasny acab56c808 chore: re-format with clang-format 11 2020-12-14 20:05:20 +01:00
Gregor Jasny d841f00378 core: enforce proper metric and label names
Closes: #421
2020-12-13 16:46:26 +01:00
Gregor Jasny 80513483a2 chore: use max_digits10 instead of magic number 2020-11-15 19:52:37 +01:00