WRStats is a library for production-compatible metric storage and retrieval. ## Data model Currently, only counters are supported, in the RRDTool sense of an increment-only value with some support for calculating derivatives (rates). Memcached is the intended data store. Since memcached does not support floating-point increment, metrics can be transparently scaled by a resolution factor. Each metric can contain multiple time-series sequences. A sequence is a set of counter values, equally spaced in time, with a fixed retention period. So for example, a metric might contain a sequence with a value for each second, expiring after one minute, and a sequence with a value for each minute, expiring after one hour. To read a rate, a sequence is selected, then all buckets in the requested time range are fetched. When the boundary of the time range does not exactly coincide with the boundary of a bucket, interpolation is applied, to scale down the counter value from the bucket. Interpolation assumes that the rate of events in the time window is constant. If the end of the bucket would be after the current time, the current time is used as the bucket end time for interpolation purposes. In other words, the number of events in the future is assumed to be zero; all events are assumed to be in the past. ## Storage keys Storage keys are composed of an array of components, conventionally joined by the storage class into a string key separated by colons: : : :