Recorder

public class Recorder
extension Recorder: CustomStringConvertible

A recorder collects observations within a time window (usually things like response sizes) and can provide aggregated information about the data sample, for example, count, sum, min, max and various quantiles.

This is the user-facing Recorder API.

Its behavior depends on the RecorderHandler implementation.

  • Undocumented

    Declaration

    Swift

    public let label: String
  • Undocumented

    Declaration

    Swift

    public let dimensions: [(String, String)]
  • Undocumented

    Declaration

    Swift

    public let aggregate: Bool
  • Alternative way to create a new Recorder, while providing an explicit RecorderHandler.

    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 Recorder instances using the configured metrics backend.

    Declaration

    Swift

    public init(label: String, dimensions: [(String, String)], aggregate: Bool, handler: RecorderHandler)

    Parameters

    label

    The label for the Recorder.

    dimensions

    The dimensions for the Recorder.

    handler

    The custom backend.

  • Record a value.

    Recording a value is meant to have “set” semantics, rather than “add” semantics. This means that the value of this Recorder will match the passed in value, rather than accumulate and sum the values up.

    Declaration

    Swift

    @inlinable
    public func record<DataType>(_ value: DataType) where DataType : BinaryInteger

    Parameters

    value

    Value to record.

  • Record a value.

    Recording a value is meant to have “set” semantics, rather than “add” semantics. This means that the value of this Recorder will match the passed in value, rather than accumulate and sum the values up.

    Declaration

    Swift

    @inlinable
    public func record<DataType>(_ value: DataType) where DataType : BinaryFloatingPoint

    Parameters

    value

    Value to record.

User API

  • Create a new Recorder.

    Declaration

    Swift

    convenience init(label: String, dimensions: [(String, String)] = [], aggregate: Bool = true)

    Parameters

    label

    The label for the Recorder.

    dimensions

    The dimensions for the Recorder.

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

    Declaration

    Swift

    @inlinable
    func destroy()
  • Declaration

    Swift

    public var description: String { get }