Tags: swift-server/swift-prometheus
Tags
Update minimum required Swift version to 5.2 (#51) Motivation: - SwiftNIO will soon raise it's minimum supported version of Swift from 5.0 to 5.2 (see: apple/swift-nio#1860) - Swift 5.0 and 5.1 users will not be able to use future versions of NIO (most likely from version 2.30.0). - Since Prometheus depends on NIO and NIO is so pervasive in the ecosystem it makes sense to follow NIOs lead in terms of supported Swift versions. Modifications: - Update Package.swift to change the tools version to 5.2 - Use the newer syntax for specifying target dependencies - Remove Package.resolved since it has little value for libraries - Update circle.yml to update CI jobs - Update Swift version badge in README.md Co-authored-by: Jari (LotU) <j.koopman@jarict.nl>
Perf improvements (#50) Motivation: Metrics collecting systems should be efficient enough so that their impact on the system being instrumented is negligible. Modifications: - Store `PromMetric`s in a dictionary keyed by label in `PrometheusClient`; this gives fast lookup when checking if a metric already exists - Remove the `metricTypeMap`, we can recover the same information from `PromMetric` - Remove calls to `getMetricInstrumet` in `PrometheusMetricsFactory` these were redundant as the same check is done in `createCounter` etc. - In each `createCounter` (etc.) call we now hold the lock for the duration of the call to avoid races between checking the cache and creating and storing a new metric. - The `PrometheusLabelSanitizer` now checks whether input needs santizing instead of santizing all input - Sanitizing is done in one step, mapping each utf8 code point to a sanitized code point rather than lowercasing and then checking the validity of each character. Result: - Sanitizing pre-sanitized labels is ~100x faster - Sanitizing non-sanitized label is ~20x faster - Incrementing 10 counters is ~20x faster - Incrementing 100 counters is ~40x faster - Incrementing 1000 counters is ~250x faster - (Similar results for other metrics.)