RateConstraint Function

Throttle a point from being produced more than once during a certain period.

import { Period, RateConstraint, createState, refine } from 'full-metal-alchemy'

let metricState = createState([
  {
    name: 'Products: performed a search',
    events: [ 'products/search' ],
    constraints: [
      RateConstraint({ period: Period.days(1) })
    ]
  }
])

metricState = refine(metricState, [{ name: 'products/search' }])
metricState.points.length // => 1

metricState = refine(metricState, [{ name: 'products/search' }])
metricState.points.length // => 0

// one day later
metricState = refine(metricState, [{ name: 'products/search' }])
metricState.points.length // => 1

Signature

RateConstraint(config: Object) -> Constraint

Parameters (2)

config
Object
config.period
Period

The period during which only one point may be produced.