我仔细查看了Tawaspin Surveys样本的Wasabi自动缩放块。 TenantCountOperandElement类中实现了Tailspin_TenantCount_Avg_10m规则,该规则又提供了用于收集数据的TenantCountDataPointsCollector类实例。
后者有
public IEnumerable<DataPoint> Collect(DateTimeOffset collectionTime)
方法,实际检索度量数据。 该方法由Wasabi块调用。
该方法多久调用一次?
编写自定义操作数时,您指定了要多久收集一次Collect方法。 芥末将检查IDataPointsCollection.SamplingRate propery(由您的收藏家实施)。
这可能是开发人员所具有的知识(因为他知道什么时候可以收集新的数据),但是你也可以让这个参数明确地用XML来指定(虽然我不会在生产中推荐它)。
您甚至可以根据集合函数中使用的时间范围推导出这个采样率,例如,如果操作数的平均值是最近2小时的数据,那么每隔2分钟对数据进行一次采样就可能是矫枉过正。
Collect方法(即Wasabi将调用IDataPointsCollector时)的调用周期由数据收集器上的SamplingRate属性进行管理。
当它创建IDataPointsCollector时,这个间隔最终通过操作数 传递 。 您在XML中指定的Operand元素始终可以应用一个时间跨度属性。 所以举个例子,我可以使用类似simething来定义上面列出的操作数。
<rules ...> ... <operands> <tenantCountOperand alias="Tailspin_TenantCount_Avg_2m" timespan="00:2:00" aggregate="Average" xmlns="http://Tailspin/TenantCount" /> </operands> </rules>