EventMetricType
public class EventMetricType<ExtraKeysEnum> where ExtraKeysEnum : ExtraKeys
This implements the developer facing API for recording events.
Instances of this class type are automatically generated by the parsers at built time, allowing developers to record events that were previously registered in the metrics.yaml file.
The Events API only exposes the EventMetricType.record(extra:)
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( category: String, name: String, sendInPings: [String], lifetime: Lifetime, disabled: Bool, allowedExtraKeys: [String]? = nil )
-
Record an event by using the information provided by the instance of this class.
Declaration
Swift
public func record(extra: [ExtraKeysEnum : String]? = nil)
Parameters
extra
(optional) A map of extra keys. Keys are identiifers and mapped to their registered name, values need to be strings. This is used for events where additional richer context is needed. The maximum length for values is defined by
MAX_LENGTH_EXTRA_KEY_VALUE
. -
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 -> [RecordedEventData]
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.