There exists a generic metrics collection framework in Gecko applications.
At the lowest level we have the concept of measurements. These are effectively data structures containing strongly-typed fields with values. These are how actual data is modeled.
Managing measurements are entities called providers. The role of a provider is to emit measurement instances.
Managing providers is a collector. Its job is to collect and manage measurements from multiple providers.
Measurements represent obtained data. An individual measurement consists of some metadata describing the measurement itself plus a set of fields and their values.
The most important metadata in a measurement are the name and version. Providers are expected to emit a known/named set of measurements. Emitted measurements are identified primarily through their string name. Each measurement name/type has a numeric version associated with it. The version defines the behavior of this measurement.
Versions enforce no particular behavior in code. Instead, they allow an implementation to self-identify with a policy that governs what versions mean.
An individual measurement can be encoded as JSON:
{
"name": "measurement-a",
"version": 1,
"fields": {
"foo": "value-of-foo",
"bar": 42
}
}
It consists of the following fields: