Skip to content
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
10 changes: 9 additions & 1 deletion src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,13 +374,21 @@ function logger(): Logs
}

/**
* @deprecated use `trace_metrics` instead
* @deprecated use `traceMetrics` instead
*/
function metrics(): Metrics
{
return Metrics::getInstance();
}

function traceMetrics(): TraceMetrics
{
return TraceMetrics::getInstance();
}

/**
* @deprecated use `traceMetrics` instead
*/
function trace_metrics(): TraceMetrics
{
return TraceMetrics::getInstance();
Expand Down
40 changes: 20 additions & 20 deletions tests/Metrics/TraceMetricsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Sentry\Options;
use Sentry\State\HubAdapter;

use function Sentry\trace_metrics;
use function Sentry\traceMetrics;

final class TraceMetricsTest extends TestCase
{
Expand All @@ -26,9 +26,9 @@ protected function setUp(): void

public function testCounterMetrics(): void
{
trace_metrics()->count('test-count', 2, ['foo' => 'bar']);
trace_metrics()->count('test-count', 2, ['foo' => 'bar']);
trace_metrics()->flush();
traceMetrics()->count('test-count', 2, ['foo' => 'bar']);
traceMetrics()->count('test-count', 2, ['foo' => 'bar']);
traceMetrics()->flush();

$this->assertCount(1, StubTransport::$events);
$event = StubTransport::$events[0];
Expand All @@ -43,8 +43,8 @@ public function testCounterMetrics(): void

public function testGaugeMetrics(): void
{
trace_metrics()->gauge('test-gauge', 10, ['foo' => 'bar']);
trace_metrics()->flush();
traceMetrics()->gauge('test-gauge', 10, ['foo' => 'bar']);
traceMetrics()->flush();

$this->assertCount(1, StubTransport::$events);
$event = StubTransport::$events[0];
Expand All @@ -59,8 +59,8 @@ public function testGaugeMetrics(): void

public function testDistributionMetrics(): void
{
trace_metrics()->distribution('test-distribution', 10, ['foo' => 'bar']);
trace_metrics()->flush();
traceMetrics()->distribution('test-distribution', 10, ['foo' => 'bar']);
traceMetrics()->flush();
$this->assertCount(1, StubTransport::$events);
$event = StubTransport::$events[0];
$this->assertCount(1, $event->getMetrics());
Expand All @@ -75,9 +75,9 @@ public function testDistributionMetrics(): void
public function testMetricsBufferFull(): void
{
for ($i = 0; $i < MetricsAggregator::METRICS_BUFFER_SIZE + 100; ++$i) {
trace_metrics()->count('test', 1, ['foo' => 'bar']);
traceMetrics()->count('test', 1, ['foo' => 'bar']);
}
trace_metrics()->flush();
traceMetrics()->flush();
$this->assertCount(1, StubTransport::$events);
$event = StubTransport::$events[0];
$metrics = $event->getMetrics();
Expand All @@ -90,8 +90,8 @@ public function testEnableMetrics(): void
'enable_metrics' => false,
]), StubTransport::getInstance()));

trace_metrics()->count('test-count', 2, ['foo' => 'bar']);
trace_metrics()->flush();
traceMetrics()->count('test-count', 2, ['foo' => 'bar']);
traceMetrics()->flush();

$this->assertEmpty(StubTransport::$events);
}
Expand All @@ -106,8 +106,8 @@ public function testBeforeSendMetricAltersContent()
},
]), StubTransport::getInstance()));

trace_metrics()->count('test-count', 2, ['foo' => 'bar']);
trace_metrics()->flush();
traceMetrics()->count('test-count', 2, ['foo' => 'bar']);
traceMetrics()->flush();

$this->assertCount(1, StubTransport::$events);
$event = StubTransport::$events[0];
Expand All @@ -119,8 +119,8 @@ public function testBeforeSendMetricAltersContent()

public function testIntType()
{
trace_metrics()->count('test-count', 2, ['foo' => 'bar']);
trace_metrics()->flush();
traceMetrics()->count('test-count', 2, ['foo' => 'bar']);
traceMetrics()->flush();

$this->assertCount(1, StubTransport::$events);
$event = StubTransport::$events[0];
Expand All @@ -134,8 +134,8 @@ public function testIntType()

public function testFloatType(): void
{
trace_metrics()->gauge('test-gauge', 10.50, ['foo' => 'bar']);
trace_metrics()->flush();
traceMetrics()->gauge('test-gauge', 10.50, ['foo' => 'bar']);
traceMetrics()->flush();

$this->assertCount(1, StubTransport::$events);
$event = StubTransport::$events[0];
Expand All @@ -150,8 +150,8 @@ public function testFloatType(): void
public function testInvalidTypeIsDiscarded(): void
{
// @phpstan-ignore-next-line
trace_metrics()->count('test-count', 'test-value');
trace_metrics()->flush();
traceMetrics()->count('test-count', 'test-value');
traceMetrics()->flush();

$this->assertEmpty(StubTransport::$events);
}
Expand Down