addMetadata(_:completion:)
Adds metadata to the sample.
Declaration
func addMetadata(_ metadata: [String : Any], completion: @escaping @Sendable (Bool, (any Error)?) -> Void)func addMetadata(_ metadata: [String : Any]) async throwsParameters
- metadata:
The metadata dictionary contains extra information describing all the samples created by the builder. The dictionary’s keys are all strings. The values may be strings, numbers, or date objects. For a complete list of predefined metadata keys, see Metadata Keys.
Using predefined keys helps facilitate sharing data between apps; however, you are also encouraged to create your own, custom keys as needed to extend the samples’ capabilities.
- completion:
The completion handler called by the builder after it attempts to add the metadata to the series. The completion handler takes the following parameters:
successA Boolean value that indicates whether the builder successfully added the heartbeat.
errorIf the
successparameter is False, this contains an object that describes the error; otherwise,nil.
Discussion
The builder adds the metadata to the resulting series sample. It incorporates new data using addEntries(from:).