Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Sentry Developer Metrics #823

cleptric started this conversation in Features / Ideas
Discussion options

291973014-e1e981e3-f656-4a8c-ac75-281040fc5391

Sentry now has alpha support for Sentry Developer Metrics in the Laravel SDK. You can now flush metrics directly to Sentry via the newly introduced APIs.

To use metrics, you need a minimum Laravel SDK version of 4.0.0 as well as a minimum PHP SDK version of 4.3.0.

You can update the underlying PHP SDK with composer.

composer update sentry/sentry-laravel -W

If you're on self-hosted, you'll also need to enable the feature flags.

Then, you'll be able to add counters, sets, distributions, and gauges.

use function Sentry\metrics;
// Add 4 to a counter named `hits`
metrics()->increment(key: 'hits', value: 4);
// Add 25 to a distribution named `response_time` with unit milliseconds
metrics()->distribution(key: 'response_time', value: 25, unit: MetricsUnit::millisecond());
// Add 2 to gauge named `parallel_requests`, tagged with `type: "a"`
metrics()->gauge(key: 'parallel_requests', value: 2, tags: ['type' => 'a']);
// Add a user's email to a set named users.sessions, tagged with role admin
metrics()->set(key: 'users.sessions', value: 'jane.doe@example.com', tags: ['role' => User::admin()]);
// Meassure the duration of process()
metrics()->timing(key: 'duration', callback: fn() => process());

To attach the code location of your metrics, add the new attach_metric_code_locations option to your config/sentry.php file.

'attach_metric_code_locations' => true, 

In case you're not already enrolled on our Metrics alpha program, please sign up here.

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /