Skip to content

Commit

Permalink
Remove deprecated codes (#5812)
Browse files Browse the repository at this point in the history
  • Loading branch information
huangdijia authored Jun 7, 2023
1 parent f412e51 commit e8060a7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 19 deletions.
15 changes: 2 additions & 13 deletions src/Adapter/Prometheus/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,9 @@

class Redis implements Adapter
{
/**
* @deprecated since 3.1, use `$metricGatherKeySuffix` instead
*/
public const PROMETHEUS_METRIC_KEYS_SUFFIX = '_METRIC_KEYS';
private static string $metricGatherKeySuffix = ':metric_keys';

/**
* @notice TODO: since 3.1, default value will be changed to ':metric_keys'
*/
private static string $metricGatherKeySuffix = '_METRIC_KEYS';

/**
* @notice TODO: since 3.1, default value will be changed to 'prometheus:' and should be non static
*/
private static string $prefix = 'PROMETHEUS_';
private static string $prefix = 'prometheus:';

/**
* @param \Redis $redis
Expand Down
7 changes: 1 addition & 6 deletions tests/Adapter/Prometheus/RedisTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,13 @@ public function testToMetricKey()
Redis::setPrefix('prometheus:');
$method = new ReflectionMethod(Redis::class, 'toMetricKey');
self::assertEquals('prometheus:counter:hyperf_metric{counter}', $method->invoke(new Redis(new \Redis()), $data));

// 兼容 < v3.1
Redis::setPrefix('PROMETHEUS_');
$method = new ReflectionMethod(Redis::class, 'toMetricKey');
self::assertEquals('PROMETHEUS_:counter:hyperf_metric{counter}', $method->invoke(new Redis(new \Redis()), $data));
}

public function testGetMetricGatherKey()
{
$method = new ReflectionMethod(Redis::class, 'getMetricGatherKey');

self::assertEquals('PROMETHEUS_counter_METRIC_KEYS{counter}', $method->invoke(new Redis(new \Redis()), Counter::TYPE));
self::assertEquals('prometheus:counter:metric_keys{counter}', $method->invoke(new Redis(new \Redis()), Counter::TYPE));
}

public function testCollectSamples()
Expand Down

0 comments on commit e8060a7

Please sign in to comment.