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: 5 additions & 5 deletions platform-includes/metrics/usage/php.laravel.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Metrics are enabled by default in the PHP SDK. After the SDK is initialized, you can send metric data through `\Sentry\trace_metrics()`, which acts as the entry point for recording counts, gauges, and distributions.
Metrics are enabled by default in the PHP SDK. After the SDK is initialized, you can send metric data through `\Sentry\traceMetrics()`, which acts as the entry point for recording counts, gauges, and distributions.

The SDK buffers up to 1000 metric entries at a time. Once that limit is reached, it keeps only the most recent 1000. If you need to retain more than that, flush the metrics periodically before you exceed the buffer.

Expand All @@ -10,7 +10,7 @@ To emit a counter, do the following:

```php
// Record five total button clicks
\Sentry\trace_metrics()->count('button-click', 5, ['browser' => 'Firefox', 'app_version' => '1.0.0']);
\Sentry\traceMetrics()->count('button-click', 5, ['browser' => 'Firefox', 'app_version' => '1.0.0']);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The documentation incorrectly uses \Sentry\traceMetrics() instead of the correct PHP SDK function \Sentry\trace_metrics(), which will cause a fatal error for users.
Severity: CRITICAL

🔍 Detailed Analysis

The documentation was updated to reference the function \Sentry\traceMetrics(). However, the correct function name in the Sentry PHP SDK is \Sentry\trace_metrics(). Users who copy the provided code examples will encounter a fatal "Call to undefined function \Sentry\traceMetrics()" error at runtime. This change affects all PHP documentation (vanilla, Laravel, and Symfony), effectively breaking the metrics feature for any developer following the official guides.

💡 Suggested Fix

Revert all instances of \Sentry\traceMetrics() back to the correct function name, \Sentry\trace_metrics(), across all updated PHP documentation files (php.mdx, php.laravel.mdx, php.symfony.mdx).

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: platform-includes/metrics/usage/php.laravel.mdx#L13

Potential issue: The documentation was updated to reference the function
`\Sentry\traceMetrics()`. However, the correct function name in the Sentry PHP SDK is
`\Sentry\trace_metrics()`. Users who copy the provided code examples will encounter a
fatal "Call to undefined function \Sentry\traceMetrics()" error at runtime. This change
affects all PHP documentation (vanilla, Laravel, and Symfony), effectively breaking the
metrics feature for any developer following the official guides.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 8491052

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, but once we merged the referenced PR in the comment it will resolve just fine

```

## Emit a Distribution
Expand All @@ -23,7 +23,7 @@ To emit a distribution, do the following:
use \Sentry\Metrics\Unit;

// Add '15.0' to a distribution used for tracking the loading times per page.
\Sentry\trace_metrics()->distribution('page-load', 15.0, ['page' => '/home'], Unit::millisecond());
\Sentry\traceMetrics()->distribution('page-load', 15.0, ['page' => '/home'], Unit::millisecond());
```

## Emit a Gauge
Expand All @@ -36,7 +36,7 @@ To emit a gauge, do the following:
use \Sentry\Metrics\Unit;

// Add '15.0' to a gauge used for tracking the loading times per page.
\Sentry\trace_metrics()->gauge('page-load', 15.0, ['page' => '/home'], Unit::millisecond());
\Sentry\traceMetrics()->gauge('page-load', 15.0, ['page' => '/home'], Unit::millisecond());
```

## Flush
Expand All @@ -46,5 +46,5 @@ Metrics are flushed and sent to Sentry at the end of each request or command.
If you emit more than 1000 metrics per request or command, make sure to manually flush to prevent losing metrics.

```php
\Sentry\trace_metrics()->flush();
\Sentry\traceMetrics()->flush();
```
10 changes: 5 additions & 5 deletions platform-includes/metrics/usage/php.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Metrics are enabled by default in the PHP SDK. After the SDK is initialized, you can send metric data through `\Sentry\trace_metrics()`, which acts as the entry point for recording counts, gauges, and distributions.
Metrics are enabled by default in the PHP SDK. After the SDK is initialized, you can send metric data through `\Sentry\traceMetrics()`, which acts as the entry point for recording counts, gauges, and distributions.

The SDK buffers up to 1000 metric entries at a time. Once that limit is reached, it keeps only the most recent 1000. If you need to retain more than that, flush the metrics periodically before you exceed the buffer.

Expand All @@ -10,7 +10,7 @@ To emit a counter, do the following:

```php
// Record five total button clicks
\Sentry\trace_metrics()->count('button-click', 5, ['browser' => 'Firefox', 'app_version' => '1.0.0']);
\Sentry\traceMetrics()->count('button-click', 5, ['browser' => 'Firefox', 'app_version' => '1.0.0']);
```

## Emit a Distribution
Expand All @@ -23,7 +23,7 @@ To emit a distribution, do the following:
use \Sentry\Metrics\Unit;

// Add '15.0' to a distribution used for tracking the loading times per page.
\Sentry\trace_metrics()->distribution('page-load', 15.0, ['page' => '/home'], Unit::millisecond());
\Sentry\traceMetrics()->distribution('page-load', 15.0, ['page' => '/home'], Unit::millisecond());
```

## Emit a Gauge
Expand All @@ -36,13 +36,13 @@ To emit a gauge, do the following:
use \Sentry\Metrics\Unit;

// Add '15.0' to a gauge used for tracking the loading times per page.
\Sentry\trace_metrics()->gauge('page-load', 15.0, ['page' => '/home'], Unit::millisecond());
\Sentry\traceMetrics()->gauge('page-load', 15.0, ['page' => '/home'], Unit::millisecond());
```

## Flush

Make sure to flush collected metrics at the end.

```php
\Sentry\trace_metrics()->flush();
\Sentry\traceMetrics()->flush();
```
10 changes: 5 additions & 5 deletions platform-includes/metrics/usage/php.symfony.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Metrics are enabled by default in the Symfony SDK. After the SDK is initialized, you can send metric data through `\Sentry\trace_metrics()`, which acts as the entry point for recording counts, gauges, and distributions.
Metrics are enabled by default in the Symfony SDK. After the SDK is initialized, you can send metric data through `\Sentry\traceMetrics()`, which acts as the entry point for recording counts, gauges, and distributions.

The SDK buffers up to 1000 metric entries at a time. Once that limit is reached, it keeps only the most recent 1000. If you need to retain more than that, flush the metrics periodically before you exceed the buffer.

Expand All @@ -10,7 +10,7 @@ To emit a counter, do the following:

```php
// Record five total button clicks
\Sentry\trace_metrics()->count('button-click', 5, ['browser' => 'Firefox', 'app_version' => '1.0.0']);
\Sentry\traceMetrics()->count('button-click', 5, ['browser' => 'Firefox', 'app_version' => '1.0.0']);
```

## Emit a Distribution
Expand All @@ -23,7 +23,7 @@ To emit a distribution, do the following:
use \Sentry\Metrics\Unit;

// Add '15.0' to a distribution used for tracking the loading times per page.
\Sentry\trace_metrics()->distribution('page-load', 15.0, ['page' => '/home'], Unit::millisecond());
\Sentry\traceMetrics()->distribution('page-load', 15.0, ['page' => '/home'], Unit::millisecond());
```

## Emit a Gauge
Expand All @@ -36,7 +36,7 @@ To emit a gauge, do the following:
use \Sentry\Metrics\Unit;

// Add '15.0' to a gauge used for tracking the loading times per page.
\Sentry\trace_metrics()->gauge('page-load', 15.0, ['page' => '/home'], Unit::millisecond());
\Sentry\traceMetrics()->gauge('page-load', 15.0, ['page' => '/home'], Unit::millisecond());
```

## Flush
Expand All @@ -46,5 +46,5 @@ Metrics are flushed and sent to Sentry at the end of each request or command.
If you emit more than 1000 metrics per request or command, make sure to manually flush to prevent losing metrics.

```php
\Sentry\trace_metrics()->flush();
\Sentry\traceMetrics()->flush();
```