JweMetricType

public class JweMetricType

This implements the developer facing API for recording JWE 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 JWE API exposes the JweMetricType.set(_:) and JweMetricType.setWithCompactRepresentation(_:) methods, which takes care of validating the input data.

  • The public constructor used by automatically generated metrics.

    Declaration

    Swift

    public init(category: String, name: String, sendInPings: [String], lifetime: Lifetime, disabled: Bool)
  • Set a JWE value.

    Declaration

    Swift

    public func setWithCompactRepresentation(_ value: String)

    Parameters

    header

    value The compact representation of a JWE value.

  • Build a JWE value from it’s elements and set to it.

    Declaration

    Swift

    public func set(_ header: String, _ key: String, _ initVector: String, _ cipherText: String, _ authTag: String)

    Parameters

    header

    A variable-size JWE protected header.

    key

    A variable-size encrypted key. This can be an empty octet sequence.

    initVector

    A fixed-size, 96-bit, base64 encoded Jwe initialization vector. If not required by the encryption algorithm, can be an empty octet sequence.

    cipherText

    The variable-size base64 encoded cipher text.

    authTag

    A fixed-size, 132-bit, base64 encoded authentication tag. Can be an empty octet sequence.

  • Tests whether a value is stored for the metric 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 testHasValue(_ pingName: String? = nil) -> Bool

    Parameters

    pingName

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

    Return Value

    true if metric value exists, otherwise false

  • 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.

    Throws a “Missing value” exception if no value is stored.

    Declaration

    Swift

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

    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 in the compact representation for testing purposes only. This function will attempt to await the last task (if any) writing to the metric’s storage engine before returning a value.

    Throws a “Missing value” exception if no value is stored.

    Declaration

    Swift

    public func testGetCompactRepresentation(_ pingName: String? = nil) throws -> 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 number of errors recorded for the given metric.

    Declaration

    Swift

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

    Parameters

    errorType

    The type of 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 for the given error type.