承接 previousnext/php-prometheus 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

previousnext/php-prometheus

最新稳定版本:1.3.0

Composer 安装命令:

composer require previousnext/php-prometheus

包简介

A PHP library for serializing to the prometheus text format.

README 文档

README

A PHP library for serializing to the prometheus text format.

CircleCI

NOTE This library does not keep state. It is intended purely as a serialization library. Therefore, there are no methods into increment or decrement values for metrics, only to set them in order to be serialized.

Installation

composer require previousnext/php-prometheus

Usage

Gauge

$gauge = new Gauge("foo", "bar", "A test gauge");
$gauge->set(100, ['baz' => 'wiz']);
$gauge->set(90, ['wobble' => 'wibble', 'bing' => 'bong']);
$gauge->set(0);

$serializer = MetricSerializerFactory::create();
$output = $serializer->serialize($gauge, 'prometheus');

Expected output:

# HELP foo_bar A test gauge
# TYPE foo_bar gauge
foo_bar{baz="wiz"} 100
foo_bar{wobble="wibble",bing="bong"} 90
foo_bar 0

Counter

$counter = new Counter("foo", "bar", "A counter for testing");
$counter->set(100, ['baz' => 'wiz']);

$serializer = MetricSerializerFactory::create();
$output = $serializer->serialize($counter, 'prometheus');

Expected output:

# HELP foo_bar A counter for testing
# TYPE foo_bar counter
foo_bar{baz="wiz"} 100

Summary

$summary = new Summary("foo", "bar", "Summary help text", 'baz');
$buckets = [0, 0.25, 0.5, 0.75, 1];
$values = [2, 4, 6, 8, 10];
$summary->setValues($buckets, $values);
$summary->setSum(54321);
$summary->setCount(212);

$serializer = MetricSerializerFactory::create();
$output = $serializer->serialize($summary, 'prometheus');

Expected output:

# HELP foo_bar Summary help text
# TYPE foo_bar summary
foo_bar{baz="0"} 2
foo_bar{baz="0.25"} 4
foo_bar{baz="0.5"} 6
foo_bar{baz="0.75"} 8
foo_bar{baz="1"} 10
foo_bar_sum 54321
foo_bar_count 212

Developing

PHP CodeSniffer

./bin/phpcs

PHPUnit

./bin/phpunit

统计信息

  • 总下载量: 412.1k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 6
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2018-10-04