-
-
Notifications
You must be signed in to change notification settings - Fork 198
Sentry Developer Metrics #823
-
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.
Beta Was this translation helpful? Give feedback.