LabeledMetricType

public class LabeledMetricType<T>

This implements the developer facing API for labeled metrics.

Instances of this class type are automatically generated by the parsers at build time, allowing developers to record values that were previously registered in the metrics.yaml file.

Unlike most metric types, LabeledMetricType does not have its own corresponding storage engine, but records metrics for the underlying metric type T in the storage engine for that type. The only difference is that labeled metrics are stored with the special key $category.$name/$label.

  • The public constructor used by automatically generated metrics.

    Supports the following types as sub-metrics:

    Throws an exception when used with unsupported sub-metrics.

    Declaration

    Swift

    public init(
        category: String,
        name: String,
        sendInPings: [String],
        lifetime: Lifetime,
        disabled: Bool,
        subMetric: T,
        labels: Set<String>? = nil
    ) throws
  • Get the specific metric for a given label.

    If a set of acceptable labels was specified in the metrics.yaml file, and the given label is not in the set, it will be recorded under the special OTHER_LABEL.

    If a set of acceptable labels was not specified in the metrics.yaml file, only the first 16 unique labels will be used. After that, any additional labels will be recorded under the special OTHER_LABEL label.

    Labels must be snake_case and less than 30 characters. If an invalid label is used, the metric will be recorded in the special OTHER_LABEL label.

    Declaration

    Swift

    public subscript(label: String) -> T { get }

    Parameters

    label

    The label

    Return Value

    The specific metric for that label

  • Returns the number of errors recorded for the given metric.

    Declaration

    Swift

    public func testGetNumRecordedErrors(_ errorType: ErrorType, pingName: String? = nil) -> Int32

    Parameters

    errorType

    The type of the error recorded.

    pingName

    represents the name of the ping to retrieve the metric for. Defaults to the first value in sendInPings.

    Return Value

    the number of errors recorded for the metric.