Skip to content
Merged
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
23 changes: 23 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ jobs:

name: P${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }} - ${{ matrix.redis-version }}

# Service container with PostgreSQL
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: root
POSTGRES_USER: root
POSTGRES_DB: test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

env:
# The hostname used to communicate with the Redis service container
REDIS_HOST: redis
Expand Down Expand Up @@ -64,4 +80,11 @@ jobs:
TEST_PDO_DSN: 'mysql:host=localhost;dbname=test'
TEST_PDO_USERNAME: 'root'
TEST_PDO_PASSWORD: 'root'
run: vendor/bin/phpunit tests/Test/Prometheus/PDO

- name: Execute PDO tests with PostgreSQL
env:
TEST_PDO_DSN: 'pgsql:host=localhost;dbname=test'
TEST_PDO_USERNAME: 'root'
TEST_PDO_PASSWORD: 'root'
run: vendor/bin/phpunit tests/Test/Prometheus/PDO
2 changes: 2 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ parameters:
paths:
- src
- tests
ignoreErrors:
- '#Call to method Redis::[a-zA-Z0-9_]+\(\) with incorrect case: [a-zA-Z0-9_]+#'
20 changes: 10 additions & 10 deletions src/Prometheus/CollectorRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function getMetricFamilySamples(bool $sortMetrics = true): array
* @return Gauge
* @throws MetricsRegistrationException
*/
public function registerGauge(string $namespace, string $name, string $help, $labels = []): Gauge
public function registerGauge(string $namespace, string $name, string $help, array $labels = []): Gauge
{
$metricIdentifier = self::metricIdentifier($namespace, $name);
if (isset($this->gauges[$metricIdentifier])) {
Expand Down Expand Up @@ -136,7 +136,7 @@ public function getGauge(string $namespace, string $name): Gauge
* @return Gauge
* @throws MetricsRegistrationException
*/
public function getOrRegisterGauge(string $namespace, string $name, string $help, $labels = []): Gauge
public function getOrRegisterGauge(string $namespace, string $name, string $help, array $labels = []): Gauge
{
try {
$gauge = $this->getGauge($namespace, $name);
Expand All @@ -155,7 +155,7 @@ public function getOrRegisterGauge(string $namespace, string $name, string $help
* @return Counter
* @throws MetricsRegistrationException
*/
public function registerCounter(string $namespace, string $name, string $help, $labels = []): Counter
public function registerCounter(string $namespace, string $name, string $help, array $labels = []): Counter
{
$metricIdentifier = self::metricIdentifier($namespace, $name);
if (isset($this->counters[$metricIdentifier])) {
Expand Down Expand Up @@ -196,7 +196,7 @@ public function getCounter(string $namespace, string $name): Counter
* @return Counter
* @throws MetricsRegistrationException
*/
public function getOrRegisterCounter(string $namespace, string $name, string $help, $labels = []): Counter
public function getOrRegisterCounter(string $namespace, string $name, string $help, array $labels = []): Counter
{
try {
$counter = $this->getCounter($namespace, $name);
Expand All @@ -211,7 +211,7 @@ public function getOrRegisterCounter(string $namespace, string $name, string $he
* @param string $name e.g. duration_seconds
* @param string $help e.g. A histogram of the duration in seconds.
* @param string[] $labels e.g. ['controller', 'action']
* @param mixed[]|null $buckets e.g. [100, 200, 300]
* @param float[]|null $buckets e.g. [100.0, 200.0, 300.0]
*
* @return Histogram
* @throws MetricsRegistrationException
Expand All @@ -221,7 +221,7 @@ public function registerHistogram(
string $name,
string $help,
array $labels = [],
array $buckets = null
?array $buckets = null
): Histogram {
$metricIdentifier = self::metricIdentifier($namespace, $name);
if (isset($this->histograms[$metricIdentifier])) {
Expand Down Expand Up @@ -259,7 +259,7 @@ public function getHistogram(string $namespace, string $name): Histogram
* @param string $name e.g. duration_seconds
* @param string $help e.g. A histogram of the duration in seconds.
* @param string[] $labels e.g. ['controller', 'action']
* @param float[]|null $buckets e.g. [100, 200, 300]
* @param float[]|null $buckets e.g. [100.0, 200.0, 300.0]
*
* @return Histogram
* @throws MetricsRegistrationException
Expand All @@ -269,7 +269,7 @@ public function getOrRegisterHistogram(
string $name,
string $help,
array $labels = [],
array $buckets = null
?array $buckets = null
): Histogram {
try {
$histogram = $this->getHistogram($namespace, $name);
Expand Down Expand Up @@ -297,7 +297,7 @@ public function registerSummary(
string $help,
array $labels = [],
int $maxAgeSeconds = 600,
array $quantiles = null
?array $quantiles = null
): Summary {
$metricIdentifier = self::metricIdentifier($namespace, $name);
if (isset($this->summaries[$metricIdentifier])) {
Expand Down Expand Up @@ -348,7 +348,7 @@ public function getOrRegisterSummary(
string $help,
array $labels = [],
int $maxAgeSeconds = 600,
array $quantiles = null
?array $quantiles = null
): Summary {
try {
$summary = $this->getSummary($namespace, $name);
Expand Down
2 changes: 1 addition & 1 deletion src/Prometheus/Counter.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function inc(array $labels = []): void

/**
* @param int|float $count e.g. 2
* @param mixed[] $labels e.g. ['status', 'opcode']
* @param string[] $labels e.g. ['status', 'opcode']
*/
public function incBy($count, array $labels = []): void
{
Expand Down
2 changes: 1 addition & 1 deletion src/Prometheus/Gauge.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Gauge extends Collector
const TYPE = 'gauge';

/**
* @param double $value e.g. 123
* @param float $value e.g. 123.0
* @param string[] $labels e.g. ['status', 'opcode']
*/
public function set(float $value, array $labels = []): void
Expand Down
4 changes: 2 additions & 2 deletions src/Prometheus/Histogram.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct(
string $name,
string $help,
array $labels = [],
array $buckets = null
?array $buckets = null
) {
parent::__construct($adapter, $namespace, $name, $help, $labels);

Expand Down Expand Up @@ -113,7 +113,7 @@ public static function exponentialBuckets(float $start, float $growthFactor, int
}

/**
* @param double $value e.g. 123
* @param float $value e.g. 123.0
* @param string[] $labels e.g. ['status', 'opcode']
*/
public function observe(float $value, array $labels = []): void
Expand Down
Loading