_handler
_handler
is only public to allow access from MetricsTestKit
. Do not consider it part of the public API.
let _handler: CounterHandler
_handler
is only public to allow access from MetricsTestKit
. Do not consider it part of the public API.
let _handler: CounterHandler
import CoreMetrics
A Metrics API package for Swift.
final class Counter
A counter is a cumulative metric that represents a single monotonically increasing counter whose value can only increase or be reset to zero. For example, you can use a counter to represent the number of requests served, tasks completed, or errors.
protocol CounterHandler : AnyObject, _SwiftMetricsSendableProtocol
A CounterHandler
represents a backend implementation of a Counter
.
convenience init(label: String, dimensions: [(String, String)] = [])
Create a new Counter
.
init(label: String, dimensions: [(String, String)], handler: CounterHandler)
Alternative way to create a new Counter
, while providing an explicit CounterHandler
.
var description: String { get }
let dimensions: [(String, String)]
let label: String
func destroy()
Signal the underlying metrics library that this counter will never be updated again. In response the library MAY decide to eagerly release any resources held by this Counter
.
func increment()
Increment the counter by one.
func increment<DataType>(by amount: DataType) where DataType : BinaryInteger
Increment the counter.
func reset()
Reset the counter back to zero.