Commit Graph

138 Commits

Author SHA1 Message Date
Nathan Harris 8e5110dcd6 Add `Timer.recordNanoseconds` Generic Overload (#28) (#30)
Motivation:

As discussed in Issue #28, there are a few preferred lightweight APIs for getting timestamps such as `DispatchTime` but those APIs return `UInt64` types, which need to be handled for overflow.

Modifications:

Added a generic `BinaryInteger` overload method for `recordNanoseconds` that guards against accidental overflows from `UInt64` to `Int64`

Result:

Users now have access to a new method to record nanosecond measurements with `Timer` that guards against overflows.
2019-05-25 21:36:56 -07:00
Nathan Harris e4883dab79 Add guards for Int64 overflow in `Timer` methods (#29)
Motivation:

`Timer.record*` methods are generic to cover all cases of `BinaryInteger` values and converts the passed value into `Int64` before doing time unit conversions and overflow checks.

Modifications:

All methods that accept `BinaryInteger` types and converts to `Int64` now guards against values higher than `Int64.max`

Result:

Users can reliably use the `Timer.record*` APIs with `BinaryInteger` types without concern for unknowing fatal errors.
2019-05-24 22:41:41 -07:00
Konrad `ktoso` Malawski 4a9e0de637
doc: #26 clarify which init to use, reformat docs for easier noticing this (#27)
* doc: #26 clarify which init to use, reformat docs for easier noticing this

* Mark all "we do not expect this API to be used in normal..." as warnings
2019-05-25 14:33:16 +09:00
tomer doron 4c24199dea update readme 1.0.0 release info (#25)
motivation: prepare for 1.0.0 release

changes: update readme with 1.0.0 release info
2019-05-06 16:02:12 -07:00
Yim Lee e7de07004c Fix API documentation (#24)
Motivation:

API documentation contains typos and grammatical errors.

Modifications:

Fix typos and grammatical errors. Update to use code syntax where
appropriate.

Result:

Eliminate typos and grammatical errors found.
2019-04-24 22:54:53 -07:00
tomer doron ecdc7bee47
add script to generate podspec (#22)
motivation: distribute the library via podspec

changes:
* add build_podspec.sh script
* adjust sanity check to support more types of copyright years format
2019-04-23 12:22:24 -07:00
tomer doron e89e97d7b3
Add 'Show on GitHub' link to API docs (#21)
Motivation:

Allowing readers of the API documentation to drill into the implementation of documented declarations can be educational and helpful for debugging, among several other reasons.

Modifications:

Add --github-file-prefix appending the current version in order to keep stable links. This means that documentation generated from any non-release revision may resolve incorrectly. This can be refined in the doc generation script later if it is deemed problematic by resolving to the commit sha if it doesn't exactly align with the version.

Result:

Users will be able to click a 'Show on GitHub' for all documented API declarations.
2019-04-23 12:04:33 -07:00
tomer doron b017e02759
add note about convergence tag (#20)
motivation: starting convergence period for swift-metrics 1.0.0 release

changes:
* add info in readme about the convergence phase/version
* format
2019-04-22 10:20:44 -07:00
tomer doron 6db51d5f32
overflow (#19)
motivation: highlight the need to address overflow in metric objects that are integer based

changes:
* add section in the readme about addressing woverflow
* fix timer's unit conversion to address potential overflow
2019-04-22 09:47:46 -07:00
Konrad `ktoso` Malawski d9f63df00c Introduce metric.destroy() to enable lifecycle management (#17)
motivation: allow middleware libraries better control of metric object lifecycle to reduce potential memory footprint when using metrics libraries that use some kind of registry or cache (eg polling backends)

changes:
* Introduce metric.destroy() to enable lifecycle management
* Add destroy functions to example impl in readme
2019-04-19 10:33:58 -07:00
tomer doron 6337a9f30f add git commit template (#18)
motivation: missing the template mentioned in the contribution guides

changes: add dev directory with the git commit template
2019-04-19 10:51:54 +01:00
tomer doron 604059db20
add contribution guidelines and github default config (#16)
motivation: adopt contribution guidelines and github PR conventions

changes:
* add contributing guidelines, including commit message template
* add github PR guidelines, including PR message template
2019-04-15 22:28:45 -07:00
Konrad `ktoso` Malawski b17a8a9f0f Fix incorrect bootstrap invocation in README (#15)
The bootstrap used to be invoked using `MyFactory.init` but nowadays we changed it to accepting an factory instance.

**Problem:**

- snippet was misleading and would not compile

**Solution:**

- change to snippet that will work with current shape of API
- make the code snippet more visible and not in-line, so it is easier to spot "so what do I need to do to bootstrap again...?"
2019-04-15 09:36:39 -07:00
tomer doron feafca5bb9
fix linux tests formatting (#13)
motivation: use consistent formatting

changes: update generate_linux_tests to match the formatting rules we use: `swiftformat --self insert --patternlet inline --stripunusedargs unnamed-only --comments ignore`
2019-04-12 10:57:04 -07:00
tomer doron c730d4e761
unexport Foundation (#9)
motivation: Foundation was accidently exported

changes: remove @_exported of Foundation in Metrics module
2019-04-11 10:14:31 -07:00
tomer doron 4977a20e55
Retain SwiftNIO copyright header (#10)
motivation: retain copyrights

changes:
* add notice file with references to derived work
* add swift-nio license header to locks
2019-04-11 10:12:49 -07:00
tomer doron 867072f4cb
use consistent, swifty naming convention (#6)
motivation: prepare to release

changes: refer to package as SwiftMetrics across the board isntead of swift-metrics
2019-04-10 09:37:22 -07:00
tomer doron 0b2fb92ce9
update package name 2019-04-09 14:43:38 -07:00
tomer doron 6e2f29ea09
update email groups 2019-04-09 14:35:17 -07:00
tomer doron af4bfe2d4f
add code of conduct 2019-04-09 14:33:22 -07:00
tomer doron 0d1280716d
fix typo
remove redundant line
2019-04-09 09:08:41 -07:00
tomer doron 4729bac3a1
rename Counter::increment "value" parameter to "by" (#4)
* rename Counter::increment "value" parameter to "by"

motivation: nicer API signature

changes: rename Counter::increment and  CounterHandler::increment "value" parameter to "by"
2019-04-08 19:59:15 -07:00
tomer doron 585a41d684
prepare to release (#1)
* prepare to release

motivation: the sswg voted to adopt the API. this is to prepare to a release

changes:
* rewrite readme
* add API docs
* add utilitiy scripts and docker setup for CI
* adjust linux tests
2019-04-08 18:58:55 -07:00
tomer doron 5c1c739969
make protocol functions data type specific
motivation: it's very beneficial for the protocols to use functions with concrete types because then there's no need for specialisation. At compile time, the compiler can often not know what concrete type will be used so it needs to create a 'generic at runtime' version of the function. If however all functions on the protocol do not use generics, there's no need for a 'generic at runtime' version of the function

changes:
* change CounterHandler::increment to take Int64 instead of <DataType: BinaryInteger>
* change RecorderHandler::record to take Int64 and Double instead of <DataType: BinaryInteger> and <DataType: BinaryFloatingPoint>
* adjust example and test implementation
* adjust docs
2019-04-05 10:30:46 -07:00
tomer doron 187653d466
address feedback (#13)
motivation: address feedback from community, prepare for moving api to official repo

changes:
* add reset method to counter
* do not force the user facing metric object to implement the mteric handler protocol. this was done for convinience and confuses matters
* adjust tests
* fix a few typos
2019-04-05 07:28:52 -07:00
Jari (LotU) 20b998220e make MetricSystem factory property public
motivation: make it possible to create extensions that want to expose specific implementations  

changes: make MetricSystem factory property public
2019-03-31 13:36:36 +01:00
tomer doron b24e6b2fb3 fixing typos
motivation: documentation cleanup

changes: fix various typos in method documentation
2019-03-07 16:05:36 -08:00
tomer doron a5aa28873c
update readme to reflect API changes (#10)
motivation: prepare to final pitch to community

changes: adjust readme with latest API changes
2019-02-27 07:17:20 -08:00
tomer doron 1f44332af3
refactor APIs to make them closer to swift-log APIs
motivation: after much discussion around logging API, we settled on a different API style, primairly the fact that we will use initializers instead of factories

changes:
* introduce intermediate classes for Counter, Timer and Recorder which are designed to replace the Metrics.makeCounter, Metrics.makeTimer and Metrics.makeRecorder APIs and wrap corresponding CounterHandler, TimerHandler and ReorderHandler coming from the metrics implmentation
* rename Metrics to MetricsSystem
* rename  MetricsHandler -> MetricsFactory
* remove Metrics.withCounter, Metrics.withTimer and Metrics.withRecorder syntactic sugar
* rename Metrics.timed with Timer.measure
* make sure metrics system can only be initialized/bootstrapped once per process
* adjust and add tests
* add a bit of docs on key APIs
2019-02-25 15:04:43 -08:00
tomer doron 2953390316
remove CachingMetricsHandler
motivation: CachingMetricsHandler represents an optimization that is better handled by implementations than dictated by the API

see: https://forums.swift.org/t/discussion-server-metrics-api/19600/2?u=tomerd

changes:
* remove CachingMetricsHandler
* adjust tests
2019-02-24 18:03:07 -08:00
tomer doron 02eeee08d9 license 2019-02-21 19:47:50 -08:00
Konrad `ktoso` Malawski 4554b8eea6 Align proposal code with proposal README, add missing make* on Metrics (#5)
May resolve #4 if that was the original intent of using the API
2019-01-17 23:09:00 -08:00
Konrad `ktoso` Malawski ac6fe4405f Fix small typos in proposal README (#3)
* Fix small typo

* Slight rewording, if things are cached depends on the handler
2019-01-17 23:08:02 -08:00
Cory Benfield edb434ef6b Minor language cleanup. (#1) 2019-01-14 12:56:39 -08:00
tomer doron 9907101ff8 format 2019-01-14 02:00:18 -08:00
tomer doron da46fbb762 better caching
motivation: better metrics cache, seperate mutex per type

changes:
* seperate mutex per metric type
* more tests
2019-01-11 10:51:57 -08:00
tomer doron 3112831cb3 update readme with more details and add a simpler example for handler implementation 2019-01-10 19:50:15 -08:00
tomer doron d01123e590 initial commit 2019-01-08 13:25:21 -08:00