FloatingPointCounter

public class FloatingPointCounter
extension FloatingPointCounter: CustomStringConvertible

A FloatingPointCounter is a cumulative metric that represents a single monotonically increasing FloatingPointCounter whose value can only increase or be reset to zero. For example, you can use a FloatingPointCounter to represent the number of requests served, tasks completed, or errors. FloatingPointCounter is not supported by all metrics backends, however a default implementation is provided which accumulates floating point values and records increments to a standard Counter after crossing integer boundaries.

This is the user-facing FloatingPointCounter API.

Its behavior depends on the FloatingCounterHandler implementation.

  • Undocumented

    Declaration

    Swift

    public let label: String
  • Undocumented

    Declaration

    Swift

    public let dimensions: [(String, String)]
  • Alternative way to create a new FloatingPointCounter, while providing an explicit FloatingPointCounterHandler.

    Warning

    This initializer provides an escape hatch for situations where one must use a custom factory instead of the global one. We do not expect this API to be used in normal circumstances, so if you find yourself using it make sure it’s for a good reason.

    See also

    Use init(label:dimensions:) to create FloatingPointCounter instances using the configured metrics backend.

    Declaration

    Swift

    public init(label: String, dimensions: [(String, String)], handler: FloatingPointCounterHandler)

    Parameters

    label

    The label for the FloatingPointCounter.

    dimensions

    The dimensions for the FloatingPointCounter.

    handler

    The custom backend.

  • Increment the FloatingPointCounter.

    Declaration

    Swift

    @inlinable
    public func increment<DataType>(by amount: DataType) where DataType : BinaryFloatingPoint

    Parameters

    by

    Amount to increment by.

  • Increment the FloatingPointCounter by one.

    Declaration

    Swift

    @inlinable
    public func increment()
  • Reset the FloatingPointCounter back to zero.

    Declaration

    Swift

    @inlinable
    public func reset()

User API

  • Create a new FloatingPointCounter.

    Declaration

    Swift

    public convenience init(label: String, dimensions: [(String, String)] = [])

    Parameters

    label

    The label for the FloatingPointCounter.

    dimensions

    The dimensions for the FloatingPointCounter.

  • Signal the underlying metrics library that this FloatingPointCounter will never be updated again. In response the library MAY decide to eagerly release any resources held by this FloatingPointCounter.

    Declaration

    Swift

    @inlinable
    public func destroy()
  • Declaration

    Swift

    public var description: String { get }