DatetimeMetricType

public class DatetimeMetricType

This implements the developer facing API for recording datetime 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.

The datetime API only exposes the DatetimeMetricType.set(_:) method, which takes care of validating the input data and making sure that limits are enforced.

  • The public constructor used by automatically generated metrics.

    Declaration

    Swift

    public init(_ meta: CommonMetricData, _ timeUnit: TimeUnit)
  • Set a datetime value, truncating it to the metric’s resolution.

    Declaration

    Swift

    public func set(_ value: Date = Date())

    Parameters

    value

    The [Date] value to set. If not provided, will record the current time.

  • Returns the string representation of the stored value for testing purposes only. This function will attempt to await the last task (if any) writing to the the metric’s storage engine before returning a value.

    Declaration

    Swift

    public func testGetValueAsString(_ pingName: String? = nil) -> String?

    Parameters

    pingName

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

    Return Value

    value of the stored metric

  • Returns the stored value for testing purposes only. This function will attempt to await the last task (if any) writing to the the metric’s storage engine before returning a value.

    Declaration

    Swift

    public func testGetValue(_ pingName: String? = nil) -> Date?

    Parameters

    pingName

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

    Return Value

    value of the stored metric

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

    Declaration

    Swift

    public func testGetNumRecordedErrors(_ error: ErrorType) -> Int32

    Parameters

    errorType

    The type of error recorded.

    Return Value

    The number of errors recorded for the metric for the given error type.