Skip to content
This repository has been archived by the owner on Oct 22, 2019. It is now read-only.

Add Interfaces to Boundaries #61

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Prometheus/CollectorRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Prometheus\Storage\Adapter;
use Prometheus\Storage\Redis;

class CollectorRegistry
class CollectorRegistry implements RegistryInterface
{
/**
* @var CollectorRegistry
Expand Down
106 changes: 106 additions & 0 deletions src/Prometheus/RegistryInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?php

namespace Prometheus;

use Prometheus\Exception\MetricNotFoundException;
use Prometheus\Exception\MetricsRegistrationException;

interface RegistryInterface
{
/**
* @return MetricFamilySamples[]
*/
public function getMetricFamilySamples();

/**
* @param string $namespace e.g. cms
* @param string $name e.g. duration_seconds
* @param string $help e.g. The duration something took in seconds.
* @param array $labels e.g. ['controller', 'action']
*
* @return Gauge
* @throws MetricsRegistrationException
*/
public function registerGauge($namespace, $name, $help, $labels = []);

/**
* @param string $namespace
* @param string $name
*
* @return Gauge
* @throws MetricNotFoundException
*/
public function getGauge($namespace, $name);

/**
* @param string $namespace e.g. cms
* @param string $name e.g. duration_seconds
* @param string $help e.g. The duration something took in seconds.
* @param array $labels e.g. ['controller', 'action']
*
* @return Gauge
*/
public function getOrRegisterGauge($namespace, $name, $help, $labels = []);

/**
* @param string $namespace e.g. cms
* @param string $name e.g. requests
* @param string $help e.g. The number of requests made.
* @param array $labels e.g. ['controller', 'action']
*
* @return Counter
* @throws MetricsRegistrationException
*/
public function registerCounter($namespace, $name, $help, $labels = []);

/**
* @param string $namespace
* @param string $name
*
* @return Counter
* @throws MetricNotFoundException
*/
public function getCounter($namespace, $name);

/**
* @param string $namespace e.g. cms
* @param string $name e.g. requests
* @param string $help e.g. The number of requests made.
* @param array $labels e.g. ['controller', 'action']
*
* @return Counter
*/
public function getOrRegisterCounter($namespace, $name, $help, $labels = []);

/**
* @param string $namespace e.g. cms
* @param string $name e.g. duration_seconds
* @param string $help e.g. A histogram of the duration in seconds.
* @param array $labels e.g. ['controller', 'action']
* @param array $buckets e.g. [100, 200, 300]
*
* @return Histogram
* @throws MetricsRegistrationException
*/
public function registerHistogram($namespace, $name, $help, $labels = [], $buckets = null);

/**
* @param string $namespace
* @param string $name
*
* @return Histogram
* @throws MetricNotFoundException
*/
public function getHistogram($namespace, $name);

/**
* @param string $namespace e.g. cms
* @param string $name e.g. duration_seconds
* @param string $help e.g. A histogram of the duration in seconds.
* @param array $labels e.g. ['controller', 'action']
* @param array $buckets e.g. [100, 200, 300]
*
* @return Histogram
*/
public function getOrRegisterHistogram($namespace, $name, $help, $labels = [], $buckets = null);
}
2 changes: 1 addition & 1 deletion src/Prometheus/RenderTextFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Prometheus;


class RenderTextFormat
class RenderTextFormat implements RendererInterface
{
const MIME_TYPE = 'text/plain; version=0.0.4';

Expand Down
14 changes: 14 additions & 0 deletions src/Prometheus/RendererInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);

namespace Prometheus;

interface RendererInterface
{
/**
* @param MetricFamilySamples[] $metrics
*
* @return string
*/
public function render(array $metrics);
}