till / services_librato
Librato度量服务的PHP API包装器
1.0.0-alpha1
2012-10-23 16:25 UTC
Requires
- php: >=5.3.0
- pear-pear/http_request2: 2.1.1
This package is auto-updated.
Last update: 2024-09-11 13:46:15 UTC
README
这是一个正在进行中的工作,我们在前进的过程中实现Librato API。
当前进行中的工作:Services\Librato\Metrics
- 删除度量
- 发布度量
- 获取度量
Services\Librato\Metrics
最有趣的部分是发布度量。目前,您可以发布单个度量或多个。
以下代码创建了一个度量
<?php
use Services\Librato\Metrics\Metric;
$metric = new Metric('counter);
$metric->value = 1;
$metric->source = 'production'; // this is optional
默认情况下,我的代码假设为'仪表',因此为了发送计数器,您必须执行以下操作
<?php
use Services\Librato\Metrics;
use Services\Librato\Metrics\Counters;
// create metric
$counters = new Counters();
$counters->accept($metric);
$metrics = new Metrics('youremail', 'yourapikey');
var_dump($metrics->update($counters)); // should output 'true'
如果您想混合计数器和仪表并在一个请求中提交它们(更受欢迎)使用一个SuperCollection
<?php
use Services\Librato\Metrics;
use Services\Librato\Metrics\Counters;
use Services\Librato\Metrics\Gauges;
use Services\Librato\Metrics\SuperCollection;
// create metrics
$counters = new Counters;
$counters->accept($metric);
$gauges = new Gauges;
$gauges->accept($anotherMetric);
$collection = new SuperCollection;
$collection->accept($counters)->accept($gauges);
$metrics = new Metrics('youremail', 'yourapikey');
var_dump($metrics->update($counters)); // should output 'true'
更多内容,请查看示例目录!
Services\Librato\Annotations
您还可以创建和检索注释。以下是一个示例
<?php
use Services\Librato\Annotations;
$annotations = new Annotations($user, $apiKey);
$annotations->create('streamName', 'title', 'source', 'desc', time() - 60, time() - 5);
许可证
新BSD许可证。