57 Commits
Author SHA1 Message Date
BlindSpot e940f68c3a fix(patch): [sc-1297] use lock for subsummary to get its values 2023-05-26 19:10:09 +03:00
Sam Amin 022c317f5f Fixed Histogram Concurrency Issue
Issue:
In Histogram, some values were being dropped when the histogram is accessed concurrently by multiple threads.

Fix:
In getOrCreateHistogram, the code was copying the dictionary into a local variable, and checking it for the label without a lock. If not there, it would take the lock again to add it. But in line 224, after taking the lock again, it was rechecking the local variable, which of course would not have changed in the meantime. But the original dictionary could have changed, and that's the one we should check the second time.

Improved the concurrency test, as it was missing the bug by only checking the total count and sum without labels.
2022-10-17 11:41:11 +01:00
Fabian Fett 34b9687eb1 Remove unused weak references 2022-08-29 16:32:52 +02:00
688e1fd540 Release 1.0.0 (#69)
* Sanitize Dimensions (#68)

* Add failing test for sanitising dimension

* Fix test

* Add new DimensionsSanitizer

* Remove labels parametrisation (#63)

* Stop leaking 'le', 'quantile' in Summary/Histogram labels, remove labels parametrisation

* chore: Remove base labels protocol and add ExpressibleByArrayLiteral

* chore: Cleanup documentation. Remove deprecations

Co-authored-by: Jari (LotU) <j.koopman@jarict.nl>

* Add async/await APIs (#67)

* Add async/await APIs

* Revert unrelated change

* Add #if swift for 5.2

* Fix Swift version number check

* Add task API

Co-authored-by: Tim Condon <0xTim@users.noreply.github.com>
Co-authored-by: Anton <avolokhov@apple.com>
2022-06-20 13:33:40 +02:00
Anton Volokhov 0d1cb7ca3f fix display unit 2021-09-02 00:20:25 +01:00
Anton ba329daafa move labels equality check out of critical section in summary/histogram (#61)
* move labels equality check out of critical section in summary/histogram

* preconditions, addressing review comments
2021-08-31 10:25:09 +02:00
Anton b31a6e6d09 Finer concurrency in 'MetricType.observe' / 'MetricType.collect' (#59)
* finer concurrency when collecting metrics

* better concurrency for 'PromHistogram.observe'

* make subHistograms a map
2021-08-24 10:33:21 +02:00
Mikhail Akopov e85499c759 Introduce PromSummary.capacity to improve performance (#57)
* Introduce PromSummary.capacity to improve performance

* Add a test for summary with custom capacity

* Use Deque instead of Array to store summary values

* Revert "Use Deque instead of Array to store summary values"

This reverts commit 1dd8c32f1a.

* Use CircularBuffer instead of Array to store summary values

* Slightly improve wording in comments
2021-08-05 13:00:05 +02:00
Rauhul VarmaandJari 1478fd9939 Fix various misspellings (#53)
Co-authored-by: Jari (LotU) <j.koopman@jarict.nl>
2021-07-30 12:05:26 +02:00
AntonandJari 8fb92e78be fix Buckets helpers to not throw fatal error (#41)
* fix Buckets to not throw fatal error

* fix compiler warning

* simplify linear buckets creation

Co-authored-by: Jari (LotU) <j.koopman@jarict.nl>
2021-03-10 15:42:59 +01:00
tdotclare d7e25d93f5 Update SwiftPrometheus to use SwiftMetric 2.* (TimeUnit change to struct) (#31)
* Update SwiftPrometheus to use SwiftMetric 2.* SemVer (TimeUnit def change)

* Update Package.swift

* Update SummaryTests.swift

* Update Summary.swift
2020-03-25 09:33:48 +01:00
Jari (LotU) 275d379fb4 Get summary up to spec (#26)
* Get summary up to spec

* Update linuxmain
2020-01-15 23:05:42 +01:00
Jari (LotU) 48b181744a Get Gauge up to spec (#27)
* Get Gauge up to spec

* Update wording remarks
2019-12-04 16:34:59 +01:00
Jari (LotU)andKonrad `ktoso` Malawski 96cb1a3a33 Get Histogram up to Prometheus spec (#25)
* Add Histogram bucket generation methods

* Make buckets a separate type

* Linux tests

* Make buckets ExpressibleByArrayLiteral

* Add histogram.time()

* Use DispatchTime.now().uptimeNanoseconds instead of Date()

* Apply suggestions from code review

Co-Authored-By: Konrad `ktoso` Malawski <konrad_malawski@apple.com>

* Fix final review remarks
2019-11-21 11:20:23 +01:00
Jari (LotU)andJoe Smith f3acccc876 Timer units (#17)
* package.resolved

* WIP: Implement Time Units

* Wrap tests & Up NIO version

* Apply suggestions from code review

Co-Authored-By: Joe Smith <yasumoto7@gmail.com>

* Update linux tests
2019-10-17 15:50:51 +02:00
Joe Smith b6e38ea8db Do not recreate a new counter if we already have one. (#13)
* Do not recreate a new counter if we already have one.

* Apply across the board

* Newline for CI

* Newline for CI
2019-09-30 14:11:46 +02:00
Jari (LotU) 01b4acc136 Get metric promises (#12)
* Update to promises

* Minor cleanup

* NIO 2

* Byte Buffers & no promises

* Move ByteBuffer methods to extensions and (temp) remove Swift 4 tests

* NIO Bump & docs

* Add some helpers & update test wording
2019-08-27 10:50:10 +02:00
Konrad `ktoso` Malawski dbcfd45cf7 Fix typos in doc comments 2019-07-08 10:50:50 +09:00
MrLotU bb6db844c3 Remove docs & update getMetrics() 2019-07-05 10:03:37 +02:00
MrLotU cb00e4a00c Fixup tests & NIO version 2019-07-04 16:50:59 +02:00
MrLotU 984e26de67 Address comments 2019-07-04 14:27:57 +02:00
MrLotU cd98111e9b Tests! 🎉
Finalize

Final docs update

Remove info
2019-06-07 17:10:07 -07:00
MrLotU b59fd7ed06 WIP 2019-06-07 17:08:15 -07:00
MrLotU 12a55f1567 Update a whole buch of things & 100% doc coverage
Signed-off-by: MrLotU <j.koopman@jarict.nl>
2019-06-07 17:08:14 -07:00
MrLotU 037582f68f .
Signed-off-by: MrLotU <j.koopman@jarict.nl>
2019-06-07 17:08:14 -07:00
MrLotU ac83a7af30 Rebase 2019-06-07 17:06:08 -07:00
Joe Smith 20e7fc7438 Review fixups 2019-04-16 10:45:36 -07:00
Joe Smith b6fd495e65 Review feedback 2019-04-15 10:26:29 -07:00
Joe Smith dbbf9505cd Show off the problem with dual-writing metrics from one function call.
We might want to instead break this out into two separate functions— one that takes a label, the other that doesn't. That might allow us to then properly pass the callback and only call it once when everything is done.
2019-04-07 11:53:00 -07:00
Joe Smith 04e4d4857d Code review feedback 2019-04-07 11:42:08 -07:00
Jari (LotU)andYasumoto 6b53a9d9a7 Update Sources/Prometheus/MetricTypes/Summary.swift
No need to name closure arguments

Co-Authored-By: Yasumoto <yasumoto7@gmail.com>
2019-04-07 09:54:29 -07:00
Jari (LotU)andYasumoto 953d14f066 Update Sources/Prometheus/MetricTypes/Histogram.swift
Do not return the value we just wrote.

Co-Authored-By: Yasumoto <yasumoto7@gmail.com>
2019-04-07 09:54:16 -07:00
Jari (LotU)andYasumoto c2b953f324 Update Sources/Prometheus/MetricTypes/Gauge.swift
No `observedValue` name for closure param

Co-Authored-By: Yasumoto <yasumoto7@gmail.com>
2019-04-07 09:43:19 -07:00
Joe Smith 10118b209e Fixup tests since we're now all async 2019-04-05 13:27:09 -07:00
MrLotU 32b157053e All thread safe? 🤔 2019-01-02 17:47:08 +01:00
MrLotU a8e35e9947 Bunch of more thread-safety (I hope) 2019-01-02 17:37:00 +01:00
MrLotU f1bc21d7e7 Add a whole bunch of queue statements 2019-01-02 17:16:36 +01:00
MrLotU 855358aea6 Docs & tests
Signed-off-by: MrLotU <j.koopman@jarict.nl>
2018-12-10 17:29:15 +01:00
MrLotU f71033e88e Fix issue with Histogram & Summary 2018-11-21 14:56:16 +01:00
MrLotU 1a821d8aa0 Fix some formatting issues 2018-11-21 14:32:09 +01:00
MrLotU 5513bbecfb Fixup a small bug 2018-11-21 13:49:29 +01:00
MrLotU c654c5a148 Add Info 2018-11-18 13:16:30 +01:00
MrLotU c5b6fd8403 Make types constants 2018-11-18 12:42:12 +01:00
MrLotU dd7db34b6c Cleanup, fix some small mistakes 2018-11-18 12:41:15 +01:00
MrLotU 317b719b41 Fixup error in Counter/Gauge 2018-11-18 12:30:02 +01:00
MrLotU 3fdf15d053 Fixup labeling Summary and Histogram 2018-11-18 12:25:28 +01:00
MrLotU a1455d8ada Workable code, that needs cleaning up 2018-11-18 12:16:39 +01:00
MrLotU 3d5d06d5d2 Make summary label-able 2018-11-18 11:59:04 +01:00
MrLotU 913a256ce0 Add Prom instance to all metrics, internalise some things 2018-11-18 11:28:40 +01:00
MrLotU 18d0d7a20c Wrap most functionality 2018-11-18 11:09:38 +01:00